]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/xe_pagefault: Disallow writes to read-only VMAs
authorJonathan Cavitt <jonathan.cavitt@intel.com>
Tue, 24 Mar 2026 15:29:37 +0000 (15:29 +0000)
committerMatthew Brost <matthew.brost@intel.com>
Thu, 26 Mar 2026 01:05:55 +0000 (18:05 -0700)
The page fault handler should reject write/atomic access to read only
VMAs.  Add code to handle this in xe_pagefault_service after the VMA
lookup.

v2:
- Apply max line length (Matthew)

Fixes: fb544b844508 ("drm/xe: Implement xe_pagefault_queue_work")
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Suggested-by: Matthew Brost <matthew.brost@intel.com>
Cc: Shuicheng Lin <shuicheng.lin@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260324152935.72444-7-jonathan.cavitt@intel.com
drivers/gpu/drm/xe/xe_pagefault.c

index ea4857acf28d873155f7bf173614e1257ada67f9..918d595d1c1b765cc12b8e7ee433d20b86a4dd1f 100644 (file)
@@ -187,6 +187,12 @@ static int xe_pagefault_service(struct xe_pagefault *pf)
                goto unlock_vm;
        }
 
+       if (xe_vma_read_only(vma) &&
+           pf->consumer.access_type != XE_PAGEFAULT_ACCESS_TYPE_READ) {
+               err = -EPERM;
+               goto unlock_vm;
+       }
+
        atomic = xe_pagefault_access_is_atomic(pf->consumer.access_type);
 
        if (xe_vma_is_cpu_addr_mirror(vma))