Subject: CVE-2024-49943: drm/xe/guc_submit: add missing locking in wedged_fini

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

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.

(cherry picked from commit d28af0b6b9580b9f90c265a7da0315b0ad20bbfd)

The Linux kernel CVE team has assigned CVE-2024-49943 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 6.11 with commit 8ed9aaae39f3 and fixed in 6.11.3 with commit d88f9bab7e62
	Issue introduced in 6.11 with commit 8ed9aaae39f3 and fixed in 6.12-rc2 with commit 790533e44bfc

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2024-49943
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	drivers/gpu/drm/xe/xe_guc_submit.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/d88f9bab7e62dd0dbe983fa70cf040042a60cc84
	https://git.kernel.org/stable/c/790533e44bfc7af929842fccd9674c9f424d4627