Skip to content

Commit 1d8c055

Browse files
Thomas Hellströmlucasdemarchi
Thomas Hellström
authored andcommitted
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] (cherry picked from commit c9db07cab766b665c8fa1184649cef452f448dc8) Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 5529df9 commit 1d8c055

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
@@ -696,11 +696,14 @@ static int xe_svm_alloc_vram(struct xe_vm *vm, struct xe_tile *tile,
696696
list_for_each_entry(block, blocks, link)
697697
block->private = vr;
698698

699+
xe_bo_get(bo);
699700
err = drm_gpusvm_migrate_to_devmem(&vm->svm.gpusvm, &range->base,
700701
&bo->devmem_allocation, ctx);
701-
xe_bo_unlock(bo);
702702
if (err)
703-
xe_bo_put(bo); /* Creation ref */
703+
xe_svm_devmem_release(&bo->devmem_allocation);
704+
705+
xe_bo_unlock(bo);
706+
xe_bo_put(bo);
704707

705708
unlock:
706709
mmap_read_unlock(mm);

0 commit comments

Comments
 (0)