Skip to content

Commit c9db07c

Browse files
author
Thomas Hellström
committed
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: 2f118c9 ("drm/xe: Add SVM VRAM migration") Signed-off-by: Thomas Hellström <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6c55404 commit c9db07c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/gpu/drm/xe/xe_svm.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,14 @@ static int xe_svm_alloc_vram(struct xe_vm *vm, struct xe_tile *tile,
702702
list_for_each_entry(block, blocks, link)
703703
block->private = vr;
704704

705+
xe_bo_get(bo);
705706
err = drm_gpusvm_migrate_to_devmem(&vm->svm.gpusvm, &range->base,
706707
&bo->devmem_allocation, ctx);
707-
xe_bo_unlock(bo);
708708
if (err)
709-
xe_bo_put(bo); /* Creation ref */
709+
xe_svm_devmem_release(&bo->devmem_allocation);
710+
711+
xe_bo_unlock(bo);
712+
xe_bo_put(bo);
710713

711714
unlock:
712715
mmap_read_unlock(mm);

0 commit comments

Comments
 (0)