Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe: Fix error cleanup in xe_exec_queue_create_ioctl()

Two error handling issues exist in xe_exec_queue_create_ioctl():

1. When xe_hw_engine_group_add_exec_queue() fails, the error path jumps
to put_exec_queue which skips xe_exec_queue_kill(). If the VM is in
preempt fence mode, xe_vm_add_compute_exec_queue() has already added
the queue to the VM's compute exec queue list. Skipping the kill
leaves the queue on that list, leading to a dangling pointer after
the queue is freed.

2. When xa_alloc() fails after xe_hw_engine_group_add_exec_queue() has
succeeded, the error path does not call
xe_hw_engine_group_del_exec_queue() to remove the queue from the hw
engine group list. The queue is then freed while still linked into
the hw engine group, causing a use-after-free.

Fix both by:
- Changing the xe_hw_engine_group_add_exec_queue() failure path to jump
to kill_exec_queue so that xe_exec_queue_kill() properly removes the
queue from the VM's compute list.
- Adding a del_hw_engine_group label before kill_exec_queue for the
xa_alloc() failure path, which removes the queue from the hw engine
group before proceeding with the rest of the cleanup.

Fixes: 7970cb36966c ("'drm/xe/hw_engine_group: Register hw engine group's exec queues")
Cc: Francois Dugast <francois.dugast@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Assisted-by: Claude:claude-opus-4.6
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260408020647.3397933-1-shuicheng.lin@intel.com
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
(cherry picked from commit 37c831f401746a45d510b312b0ed7a77b1e06ec8)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Shuicheng Lin and committed by
Rodrigo Vivi
f3cc22d4 111ab678

+5 -2
+5 -2
drivers/gpu/drm/xe/xe_exec_queue.c
··· 1405 1405 if (q->vm && q->hwe->hw_engine_group) { 1406 1406 err = xe_hw_engine_group_add_exec_queue(q->hwe->hw_engine_group, q); 1407 1407 if (err) 1408 - goto put_exec_queue; 1408 + goto kill_exec_queue; 1409 1409 } 1410 1410 } 1411 1411 ··· 1416 1416 /* user id alloc must always be last in ioctl to prevent UAF */ 1417 1417 err = xa_alloc(&xef->exec_queue.xa, &id, q, xa_limit_32b, GFP_KERNEL); 1418 1418 if (err) 1419 - goto kill_exec_queue; 1419 + goto del_hw_engine_group; 1420 1420 1421 1421 args->exec_queue_id = id; 1422 1422 1423 1423 return 0; 1424 1424 1425 + del_hw_engine_group: 1426 + if (q->vm && q->hwe && q->hwe->hw_engine_group) 1427 + xe_hw_engine_group_del_exec_queue(q->hwe->hw_engine_group, q); 1425 1428 kill_exec_queue: 1426 1429 xe_exec_queue_kill(q); 1427 1430 delete_queue_group: