Skip to contentSkip to conversation

CVE-2023-53171: vfio/type1: prevent underflow of locked_vm via exec()

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Sep 15, 2025

lore
Share & tools
lore
#0 lore raw

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

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

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

vfio/type1: prevent underflow of locked_vm via exec()

When a vfio container is preserved across exec, the task does not change, but it gets a new mm with locked_vm=0, and loses the count from existing dma mappings. If the user later unmaps a dma mapping, locked_vm underflows to a large unsigned value, and a subsequent dma map request fails with ENOMEM in __account_locked_vm.

To avoid underflow, grab and save the mm at the time a dma is mapped. Use that mm when adjusting locked_vm, rather than re-acquiring the saved task's mm, which may have changed. If the saved mm is dead, do nothing.

locked_vm is incremented for existing mappings in a subsequent patch.

The Linux kernel CVE team has assigned CVE-2023-53171 to this issue.

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

	Issue introduced in 3.6 with commit 73fa0d10d077d9521ee2dace2307ae2c9a965336 and fixed in 5.10.173 with commit 5a271242716846cc016736fb76be2b40ee49b0c3
	Issue introduced in 3.6 with commit 73fa0d10d077d9521ee2dace2307ae2c9a965336 and fixed in 5.15.99 with commit eafb81c50da899dd80b340c841277acc4a1945b7
	Issue introduced in 3.6 with commit 73fa0d10d077d9521ee2dace2307ae2c9a965336 and fixed in 6.1.16 with commit a6b2aabe664098d5cf877ae0fd96459464a30e17
	Issue introduced in 3.6 with commit 73fa0d10d077d9521ee2dace2307ae2c9a965336 and fixed in 6.2.3 with commit b0790dff0760b7734cf0961f497ad64628ca550b
	Issue introduced in 3.6 with commit 73fa0d10d077d9521ee2dace2307ae2c9a965336 and fixed in 6.3 with commit 046eca5018f8a5dd1dc2cedf87fb5843b9ea3026

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-53171

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/vfio/vfio_iommu_type1.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/5a271242716846cc016736fb76be2b40ee49b0c3
	https://git.kernel.org/stable/c/eafb81c50da899dd80b340c841277acc4a1945b7
	https://git.kernel.org/stable/c/a6b2aabe664098d5cf877ae0fd96459464a30e17
	https://git.kernel.org/stable/c/b0790dff0760b7734cf0961f497ad64628ca550b
	https://git.kernel.org/stable/c/046eca5018f8a5dd1dc2cedf87fb5843b9ea3026