Skip to content

Commit 790533e

Browse files
matt-auldlucasdemarchi
authored andcommitted
drm/xe/guc_submit: add missing locking in wedged_fini
Any non-wedged queue can have a zero refcount here and can be running concurrently with an async queue destroy, therefore dereferencing the queue ptr to check wedge status after the lookup can trigger UAF if queue is not wedged. Fix this by keeping the submission_state lock held around the check to postpone the free and make the check safe, before dropping again around the put() to avoid the deadlock. Fixes: 8ed9aaa ("drm/xe: Force wedged state and block GT reset upon any GPU hang") Signed-off-by: Matthew Auld <[email protected]> Cc: Matthew Brost <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit d28af0b) Signed-off-by: Lucas De Marchi <[email protected]>
1 parent cffa8e8 commit 790533e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,15 @@ static void guc_submit_wedged_fini(void *arg)
290290
struct xe_exec_queue *q;
291291
unsigned long index;
292292

293-
xa_for_each(&guc->submission_state.exec_queue_lookup, index, q)
294-
if (exec_queue_wedged(q))
293+
mutex_lock(&guc->submission_state.lock);
294+
xa_for_each(&guc->submission_state.exec_queue_lookup, index, q) {
295+
if (exec_queue_wedged(q)) {
296+
mutex_unlock(&guc->submission_state.lock);
295297
xe_exec_queue_put(q);
298+
mutex_lock(&guc->submission_state.lock);
299+
}
300+
}
301+
mutex_unlock(&guc->submission_state.lock);
296302
}
297303

298304
static const struct xe_exec_queue_ops guc_exec_queue_ops;

0 commit comments

Comments
 (0)