drm/vc4: Prevent shader BO mappings from becoming writable
authorLinmao Li <lilinmao@kylinos.cn>
Tue, 21 Jul 2026 01:15:58 +0000 (09:15 +0800)
committerMaíra Canal <mcanal@igalia.com>
Tue, 21 Jul 2026 12:53:28 +0000 (09:53 -0300)
commit0c9e6367639548307d3f578f6943ce72c9d39087
treef4f7fb12ef262c74d30aa00d32d7c3857c645033
parent67b8bfd4ec7dac6e79a7ad9ad19a7a9d6fc35a26
drm/vc4: Prevent shader BO mappings from becoming writable

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 <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/dri-devel/20260720085554.B0AF01F000E9@smtp.kernel.org/
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
Link: https://patch.msgid.link/20260721011558.1672477-1-lilinmao@kylinos.cn
Reviewed-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
drivers/gpu/drm/vc4/vc4_bo.c