mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 23:52:08 +02:00
drm/xe/svm: Fix a potential bo UAF
If drm_gpusvm_migrate_to_devmem() succeeds, if a cpu access happens to the range the bo may be freed before xe_bo_unlock(), causing a UAF. Since the reference is transferred, use xe_svm_devmem_release() to release the reference on drm_gpusvm_migrate_to_devmem() failure, and hold a local reference to protect the UAF. Fixes:2f118c9491("drm/xe: Add SVM VRAM migration") Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://lore.kernel.org/r/20250326080551.40201-3-thomas.hellstrom@linux.intel.com (cherry picked from commitc9db07cab7) Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
This commit is contained in:
parent
5529df92b8
commit
1d8c055792
|
|
@ -696,11 +696,14 @@ static int xe_svm_alloc_vram(struct xe_vm *vm, struct xe_tile *tile,
|
|||
list_for_each_entry(block, blocks, link)
|
||||
block->private = vr;
|
||||
|
||||
xe_bo_get(bo);
|
||||
err = drm_gpusvm_migrate_to_devmem(&vm->svm.gpusvm, &range->base,
|
||||
&bo->devmem_allocation, ctx);
|
||||
xe_bo_unlock(bo);
|
||||
if (err)
|
||||
xe_bo_put(bo); /* Creation ref */
|
||||
xe_svm_devmem_release(&bo->devmem_allocation);
|
||||
|
||||
xe_bo_unlock(bo);
|
||||
xe_bo_put(bo);
|
||||
|
||||
unlock:
|
||||
mmap_read_unlock(mm);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user