summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Auld <matthew.auld@intel.com>2026-09-08 17:50:54 +0100
committerMatthew Auld <matthew.auld@intel.com>2026-09-09 10:57:10 +0100
commit7cf85c190814c209cb182eaba39e184c1655faa9 (patch)
treef20bb7181e6512f76406ba071473ccf1e2c1d7d8
parentfb2ee38bab8025ad6a7a9cbb4635c5a178e4a7bc (diff)
downloadlinux-next-7cf85c190814c209cb182eaba39e184c1655faa9.tar.gz
linux-next-7cf85c190814c209cb182eaba39e184c1655faa9.zip
drm/xe/mmio_gem: reject VM_EXEC and drop VM_DONTCOPY
Hardware MMIO registers should never be executable; reject VM_EXEC at mmap time and clear VM_MAYEXEC to prevent later mprotect attempts. Also drop VM_DONTCOPY so that child processes across fork() can inherit the mapping and lazily fault in the PFNs, matching standard DRM GEM semantics and making the existing drm_gem_vm_open() callback functional. This aligns with existing PCI_BARRIER, which will use this in the next patch. We don't want any noticeable behaviour change there, since this will be user visible. This will also be the first user. Assisted-by: LLM Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: Tejas Upadhyay <tejas.upadhyay@intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Cc: Ilia Levi <ilia.levi@intel.com> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Link: https://patch.msgid.link/20260908165046.1393557-17-matthew.auld@intel.com
-rw-r--r--drivers/gpu/drm/xe/xe_mmio_gem.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/gpu/drm/xe/xe_mmio_gem.c b/drivers/gpu/drm/xe/xe_mmio_gem.c
index 5ffe03d36190..3cdc9538957d 100644
--- a/drivers/gpu/drm/xe/xe_mmio_gem.c
+++ b/drivers/gpu/drm/xe/xe_mmio_gem.c
@@ -177,9 +177,12 @@ static int xe_mmio_gem_mmap(struct drm_gem_object *base, struct vm_area_struct *
if ((vma->vm_flags & VM_SHARED) == 0)
return -EINVAL;
+ if (vma->vm_flags & VM_EXEC)
+ return -EINVAL;
+
vma->vm_page_prot = pgprot_noncached(vma_get_page_prot(vma));
- vm_flags_set(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP |
- VM_DONTCOPY | VM_NORESERVE);
+ vm_flags_mod(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP |
+ VM_NORESERVE, VM_MAYEXEC);
/* Defer actual mapping to the fault handler. */
return 0;