Subject: CVE-2024-39493: crypto: qat - Fix ADF_DEV_RESET_SYNC memory leak

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

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

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

crypto: qat - Fix ADF_DEV_RESET_SYNC memory leak

Using completion_done to determine whether the caller has gone
away only works after a complete call.  Furthermore it's still
possible that the caller has not yet called wait_for_completion,
resulting in another potential UAF.

Fix this by making the caller use cancel_work_sync and then freeing
the memory safely.

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

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

	Issue introduced in 4.19.312 with commit daba62d9eedd and fixed in 4.19.316 with commit 0ce5964b82f2
	Issue introduced in 5.4.274 with commit 8e81cd58aee1 and fixed in 5.4.278 with commit 6396b33e98c0
	Issue introduced in 5.10.215 with commit d03092550f52 and fixed in 5.10.219 with commit a718b6d2a329
	Issue introduced in 5.15.154 with commit 4ae5a97781ce and fixed in 5.15.161 with commit 3fb4601e0db1
	Issue introduced in 6.1.84 with commit 226fc408c5fc and fixed in 6.1.94 with commit e7428e7e3fe9
	Issue introduced in 6.6.24 with commit 8a5a7611ccc7 and fixed in 6.6.34 with commit c2d443aa1ae3
	Issue introduced in 6.9 with commit 7d42e097607c and fixed in 6.9.5 with commit d0fd12497272
	Issue introduced in 6.9 with commit 7d42e097607c and fixed in 6.10 with commit d3b17c6d9ddd
	Issue introduced in 6.7.12 with commit 0c2cf5142bfb
	Issue introduced in 6.8.3 with commit bb279ead4226

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-39493
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/crypto/intel/qat/qat_common/adf_aer.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/0ce5964b82f212f4df6a9813f09a0b5de15bd9c8
	https://git.kernel.org/stable/c/6396b33e98c096bff9c253ed49c008247963492a
	https://git.kernel.org/stable/c/a718b6d2a329e069b27d9049a71be5931e71d960
	https://git.kernel.org/stable/c/3fb4601e0db10d4fe25e46f3fa308d40d37366bd
	https://git.kernel.org/stable/c/e7428e7e3fe94a5089dc12ffe5bc31574d2315ad
	https://git.kernel.org/stable/c/c2d443aa1ae3175c13a665f3a24b8acd759ce9c3
	https://git.kernel.org/stable/c/d0fd124972724cce0d48b9865ce3e273ef69e246
	https://git.kernel.org/stable/c/d3b17c6d9dddc2db3670bc9be628b122416a3d26