CVE-2023-53116: nvmet: avoid potential UAF in nvmet_req_complete()
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
nvmet: avoid potential UAF in nvmet_req_complete()
An nvme target ->queue_response() operation implementation may free the request passed as argument. Such implementation potentially could result in a use after free of the request pointer when percpu_ref_put() is called in nvmet_req_complete().
Avoid such problem by using a local variable to save the sq pointer before calling __nvmet_req_complete(), thus avoiding dereferencing the req pointer after that function call.
The Linux kernel CVE team has assigned CVE-2023-53116 to this issue.
Affected and fixed versions
===========================
Issue introduced in 4.8 with commit a07b4970f464f13640e28e16dad6cfa33647cc99 and fixed in 4.14.311 with commit e5d99b29012bbf0e86929403209723b2806500c1 Issue introduced in 4.8 with commit a07b4970f464f13640e28e16dad6cfa33647cc99 and fixed in 4.19.279 with commit fafcb4b26393870c45462f9af6a48e581dbbcf7e Issue introduced in 4.8 with commit a07b4970f464f13640e28e16dad6cfa33647cc99 and fixed in 5.4.238 with commit 04c394208831d5e0d5cfee46722eb0f033cd4083 Issue introduced in 4.8 with commit a07b4970f464f13640e28e16dad6cfa33647cc99 and fixed in 5.10.176 with commit a6317235da8aa7cb97529ebc8121cc2a4c4c437a Issue introduced in 4.8 with commit a07b4970f464f13640e28e16dad6cfa33647cc99 and fixed in 5.15.104 with commit f1d5888a5efe345b63c430b256e95acb0a475642 Issue introduced in 4.8 with commit a07b4970f464f13640e28e16dad6cfa33647cc99 and fixed in 6.1.21 with commit bcd535f07c58342302a2cd2bdd8894fe0872c8a9 Issue introduced in 4.8 with commit a07b4970f464f13640e28e16dad6cfa33647cc99 and fixed in 6.2.8 with commit 8ed9813871038b25a934b21ab76b5b7dbf44fc3a Issue introduced in 4.8 with commit a07b4970f464f13640e28e16dad6cfa33647cc99 and fixed in 6.3 with commit 6173a77b7e9d3e202bdb9897b23f2a8afe7bf286
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-2023-53116
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/nvme/target/core.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/e5d99b29012bbf0e86929403209723b2806500c1 https://git.kernel.org/stable/c/fafcb4b26393870c45462f9af6a48e581dbbcf7e https://git.kernel.org/stable/c/04c394208831d5e0d5cfee46722eb0f033cd4083 https://git.kernel.org/stable/c/a6317235da8aa7cb97529ebc8121cc2a4c4c437a https://git.kernel.org/stable/c/f1d5888a5efe345b63c430b256e95acb0a475642 https://git.kernel.org/stable/c/bcd535f07c58342302a2cd2bdd8894fe0872c8a9 https://git.kernel.org/stable/c/8ed9813871038b25a934b21ab76b5b7dbf44fc3a https://git.kernel.org/stable/c/6173a77b7e9d3e202bdb9897b23f2a8afe7bf286