Skip to content

Commit 4f68332

Browse files
matt-auldtursulin
authored andcommitted
drm/i915/ttm: fix uaf with lmem_userfault_list handling
In the fault handler, make sure we check if the BO maps lmem after we schedule the migration, since the current resource might change from lmem to smem, if the pages are in the non-cpu visible portion of lmem. This then leads to adding the object to the lmem_userfault_list even though the current resource is no longer lmem. If we then destroy the object, the list might still contain a link to the now free object, since we only remove it if the object is still in lmem. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7469 Fixes: ad74457 ("drm/i915/dgfx: Release mmap on rpm suspend") Signed-off-by: Matthew Auld <[email protected]> Cc: Anshuman Gupta <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Nirmoy Das <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 625b744) Signed-off-by: Tvrtko Ursulin <[email protected]>
1 parent 094226a commit 4f68332

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/gpu/drm/i915/gem/i915_gem_ttm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,6 @@ static vm_fault_t vm_fault_ttm(struct vm_fault *vmf)
10131013
return VM_FAULT_SIGBUS;
10141014
}
10151015

1016-
if (i915_ttm_cpu_maps_iomem(bo->resource))
1017-
wakeref = intel_runtime_pm_get(&to_i915(obj->base.dev)->runtime_pm);
1018-
10191016
if (!i915_ttm_resource_mappable(bo->resource)) {
10201017
int err = -ENODEV;
10211018
int i;
@@ -1042,6 +1039,9 @@ static vm_fault_t vm_fault_ttm(struct vm_fault *vmf)
10421039
}
10431040
}
10441041

1042+
if (i915_ttm_cpu_maps_iomem(bo->resource))
1043+
wakeref = intel_runtime_pm_get(&to_i915(obj->base.dev)->runtime_pm);
1044+
10451045
if (drm_dev_enter(dev, &idx)) {
10461046
ret = ttm_bo_vm_fault_reserved(vmf, vmf->vma->vm_page_prot,
10471047
TTM_BO_VM_NUM_PREFAULT);

0 commit comments

Comments
 (0)