drm/xe/guc_submit: add missing locking in wedged_fini
authorMatthew Auld <matthew.auld@intel.com>
Tue, 24 Sep 2024 15:09:48 +0000 (16:09 +0100)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 3 Oct 2024 06:13:54 +0000 (01:13 -0500)
commit790533e44bfc7af929842fccd9674c9f424d4627
tree57346bd57308f0fec69979d80752f30b4c408cdc
parentcffa8e83df9fe525afad1e1099097413f9174f57
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: 8ed9aaae39f3 ("drm/xe: Force wedged state and block GT reset upon any GPU hang")
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240924150947.118433-2-matthew.auld@intel.com
(cherry picked from commit d28af0b6b9580b9f90c265a7da0315b0ad20bbfd)
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_guc_submit.c