Skip to content

Commit 67801fa

Browse files
matt-auldlucasdemarchi
authored andcommitted
drm/xe/queue: move xa_alloc to prevent UAF
Evil user can guess the next id of the queue before the ioctl completes and then call queue destroy ioctl to trigger UAF since create ioctl is still referencing the same queue. Move the xa_alloc all the way to the end to prevent this. v2: - Rebase Fixes: 2149ded ("drm/xe: Fix use after free when client stats are captured") Signed-off-by: Matthew Auld <[email protected]> Cc: Matthew Brost <[email protected]> Reviewed-by: Nirmoy Das <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 1653658) Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 7423187 commit 67801fa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,12 +635,14 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
635635
}
636636
}
637637

638+
q->xef = xe_file_get(xef);
639+
640+
/* user id alloc must always be last in ioctl to prevent UAF */
638641
err = xa_alloc(&xef->exec_queue.xa, &id, q, xa_limit_32b, GFP_KERNEL);
639642
if (err)
640643
goto kill_exec_queue;
641644

642645
args->exec_queue_id = id;
643-
q->xef = xe_file_get(xef);
644646

645647
return 0;
646648

0 commit comments

Comments
 (0)