CVE-2024-53096: mm: resolve faulty mmap_region() error path behaviour
In the Linux kernel, the following vulnerability has been resolved:
mm: resolve faulty mmapregion() error path behaviour
The mmapregion() function is somewhat terrifying, with spaghetti-like control flow and numerous means by which issues can arise and incomplete state, memory leaks and other unpleasantness can occur.
A large amount of the complexity arises from trying to handle errors late in the process of mapping a VMA, which forms the basis of recently observed issues with resource leaks and observable inconsistent state.
Taking advantage of previous patches in this series we move a number of checks earlier in the code, simplifying things by moving the core of the logic into a static internal function mmapregion().
Doing this allows us to perform a number of checks up front before we do any real work, and allows us to unwind the writable unmap check unconditionally as required and to perform a CONFIGDEBUGVMMAPLETREE validation unconditionally also.
We move a number of things here:
1. We preallocate memory for the iterator before we call the file-backed memory hook, allowing us to exit early and avoid having to perform complicated and error-prone close/free logic. We carefully free iterator state on both success and error paths.
2. The enclosing mmapregion() function handles the mappingmapwritable() logic early. Previously the logic had the mappingmapwritable() at the point of mapping a newly allocated file-backed VMA, and a matching mappingunmapwritable() on success and error paths.
We now do this unconditionally if this is a file-backed, shared writable mapping. If a driver changes the flags to eliminate VMMAYWRITE, however doing so does not invalidate the seal check we just performed, and we in any case always decrement the counter in the wrapper.
We perform a debug assert to ensure a driver does not attempt to do the opposite.
3. We also move archvalidateflags() up into the mmapregion() function. This is only relevant on arm64 and sparc64, and the check is only meaningful for SPARC with ADI enabled. We explicitly add a warning for this arch if a driver invalidates this check, though the code ought eventually to be fixed to eliminate the need for this.
With all of these measures in place, we no longer need to explicitly close the VMA on error paths, as we place all checks which might fail prior to a call to any driver mmap hook.
This eliminates an entire class of errors, makes the code easier to reason about and more robust.
Other sources
This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.
— Launchpad
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.25-1 - Upgrade
Upgrade
debian/linux-6.1to a version that resolves this vulnerability.Fixed in 6.1.129-1~deb11u1
Event History
Frequently Asked Questions
What is the severity of CVE-2024-53096?
CVE-2024-53096 is classified as a medium-severity vulnerability in the Linux kernel.
How do I fix CVE-2024-53096?
To fix CVE-2024-53096, users should upgrade the Linux kernel to a version that includes the patch addressing this vulnerability.
Which versions of the Linux kernel are impacted by CVE-2024-53096?
CVE-2024-53096 affects various versions including those between 5.10.150 and 5.10.231, 5.15.75 and 5.15.174, and multiple other ranges up to 6.12.
What component of the Linux kernel is affected by CVE-2024-53096?
CVE-2024-53096 affects the mmap_region() function within the memory management subsystem of the Linux kernel.
Is there a known exploit for CVE-2024-53096?
As of now, there are no public exploits specifically targeting CVE-2024-53096, but the vulnerability requires prompt remediation.