Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C714C431A57 for ; Wed, 29 Jul 2026 12:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785329410; cv=none; b=usWUDTpHVNcKDSGWd/YvbRBZRiAOjH8/6yIkSPRL9B4H3q2IxHpHOkEng5CrdlRxTZJhxJ33oRSGh1F2uQyx+rxDXywexOtsOJFiEfkHwNNQZtyklDXlguZxhsBDygH+ENtYA2b4vYyYAHxifus9ki51lJKf84jSK6FWkHtuH2A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785329410; c=relaxed/simple; bh=h/LdD/UgoJnjWIgVqkm6J/1cPG7l8f7pb4Vwm3LyYuQ=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=jKs437p2y2Suo2QFm3pA0O0LPJOasiz7jqg4rYJmKGHfV2h/9ii920HmsRDjJDgVu23bLE/ag4XdQ81X2/ohe6lDgATbsU9e5I9OvNY9ZFLzil4PanX13v10jRHvlR0xRPNRkblTMJRvs5tcwfN4sSI8stZ6oVgk8UrrF/Jnhds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wEUL5iY8; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wEUL5iY8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 779EA1F00A3A; Wed, 29 Jul 2026 12:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785329408; bh=m6iuIdGEHFIl8hZcinlYuq08W2ZG8MYmBtBzZpQyEEo=; h=Subject:To:Cc:From:Date; b=wEUL5iY852RHBczlcjCEwp41dCfhhF8v0thKT3Fev7RLuELZGw+vWwvxPH7exT6Y9 NvDAUtR399sc3R4lbbZDCkZVh7SqYy/heZ/NOy+LIgTzNyUIpCQuxlrcyB8w+QEuvK wcxWiIewO951CSY8kyEmDY4P1wgtaJd3u115bgSQ= Subject: FAILED: patch "[PATCH] drm/vc4: Prevent shader BO mappings from becoming writable" failed to apply to 6.1-stable tree To: lilinmao@kylinos.cn,mcanal@igalia.com,sashiko-bot@kernel.org Cc: From: Date: Wed, 29 Jul 2026 14:49:54 +0200 Message-ID: <2026072954-snippet-rebuff-2752@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x 0c9e6367639548307d3f578f6943ce72c9d39087 # git commit -s git send-email --to '' --in-reply-to '2026072954-snippet-rebuff-2752@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ From 0c9e6367639548307d3f578f6943ce72c9d39087 Mon Sep 17 00:00:00 2001 From: Linmao Li Date: Tue, 21 Jul 2026 09:15:58 +0800 Subject: [PATCH] drm/vc4: Prevent shader BO mappings from becoming writable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vc4_gem_object_mmap() rejects a writable mapping of a validated shader BO, but leaves VM_MAYWRITE set. Userspace can map the BO read-only and then turn it writable with mprotect(). Validated shader BOs must stay read-only: the validator checks the instructions once and the GPU trusts them afterwards. A writable mapping lets userspace rewrite the code after validation, bypassing the validator. Clear VM_MAYWRITE on the read-only path so the mapping cannot be upgraded, as i915 already does for its read-only objects. Fixes: 463873d57014 ("drm/vc4: Add an API for creating GPU shaders in GEM BOs.") Cc: stable@vger.kernel.org Reported-by: Sashiko Closes: https://lore.kernel.org/dri-devel/20260720085554.B0AF01F000E9@smtp.kernel.org/ Signed-off-by: Linmao Li Link: https://patch.msgid.link/20260721011558.1672477-1-lilinmao@kylinos.cn Reviewed-by: Maíra Canal Signed-off-by: Maíra Canal diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c index 2161761b1f22..5e7c46dd7823 100644 --- a/drivers/gpu/drm/vc4/vc4_bo.c +++ b/drivers/gpu/drm/vc4/vc4_bo.c @@ -732,9 +732,13 @@ static int vc4_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_struct { struct vc4_bo *bo = to_vc4_bo(obj); - if (bo->validated_shader && (vma->vm_flags & VM_WRITE)) { - DRM_DEBUG("mmapping of shader BOs for writing not allowed.\n"); - return -EINVAL; + if (bo->validated_shader) { + if (vma->vm_flags & VM_WRITE) { + DRM_DEBUG("mmapping of shader BOs for writing not allowed.\n"); + return -EINVAL; + } + + vm_flags_clear(vma, VM_MAYWRITE); } mutex_lock(&bo->madv_lock);