CVE-2024-50200
maple_tree: correct tree corruption on spanning store
Check your servers for CVE-2024-50200
The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2024-50200 affects the running kernel, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.
Description
In the Linux kernel, the following vulnerability has been resolved:
maple_tree: correct tree corruption on spanning store
Patch series "maple_tree: correct tree corruption on spanning store", v3.
There has been a nasty yet subtle maple tree corruption bug that appears to have been in existence since the inception of the algorithm.
This bug seems far more likely to happen since commit f8d112a4e657 ("mm/mmap: avoid zeroing vma tree in mmap_region()"), which is the point at which reports started to be submitted concerning this bug.
We were made definitely aware of the bug thanks to the kind efforts of Bert Karwatzki who helped enormously in my being able to track this down and identify the cause of it.
The bug arises when an attempt is made to perform a spanning store across two leaf nodes, where the right leaf node is the rightmost child of the shared parent, AND the store completely consumes the right-mode node.
This results in mas_wr_spanning_store() mitakenly duplicating the new and existing entries at the maximum pivot within the range, and thus maple tree corruption.
The fix patch corrects this by detecting this scenario and disallowing the mistaken duplicate copy.
The fix patch commit message goes into great detail as to how this occurs.
This series also includes a test which reliably reproduces the issue, and asserts that the fix works correctly.
Bert has kindly tested the fix and confirmed it resolved his issues. Also Mikhail Gavrilov kindly reported what appears to be precisely the same bug, which this fix should also resolve.
This patch (of 2):
There has been a subtle bug present in the maple tree implementation from its inception.
This arises from how stores are performed - when a store occurs, it will overwrite overlapping ranges and adjust the tree as necessary to accommodate this.
A range may always ultimately span two leaf nodes. In this instance we walk the two leaf nodes, determine which elements are not overwritten to the left and to the right of the start and end of the ranges respectively and then rebalance the tree to contain these entries and the newly inserted one.
This kind of store is dubbed a 'spanning store' and is implemented by mas_wr_spanning_store().
In order to reach this stage, mas_store_gfp() invokes mas_wr_preallocate(), mas_wr_store_type() and mas_wr_walk() in turn to walk the tree and update the object (mas) to traverse to the location where the write should be performed, determining its store type.
When a spanning store is required, this function returns false stopping at the parent node which contains the target range, and mas_wr_store_type() marks the mas->store_type as wr_spanning_store to denote this fact.
When we go to perform the store in mas_wr_spanning_store(), we first determine the elements AFTER the END of the range we wish to store (that is, to the right of the entry to be inserted) - we do this by walking to the NEXT pivot in the tree (i.e. r_mas.last + 1), starting at the node we have just determined contains the range over which we intend to write.
We then turn our attention to the entries to the left of the entry we are inserting, whose state is represented by l_mas, and copy these into a 'big node', which is a special node which contains enough slots to contain two leaf node's worth of data.
We then copy the entry we wish to store immediately after this - the copy and the insertion of the new entry is performed by mas_store_b_node().
After this we copy the elements to the right of the end of the range which we are inserting, if we have not exceeded the length of the node (i.e. r_mas.offset <= r_mas.end).
Herein lies the bug - under very specific circumstances, this logic can break and corrupt the maple tree.
Consider the following tree:
Height 0 Root Node / \ pivot = 0xffff / \ pivot = ULONG_MAX / ---truncated---
Severity (CVSS)
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Attack vector
- local: the attacker needs local access, or a user has to open a prepared file
- Attack complexity
- low: an attack works without special conditions
- Privileges required
- low: the attacker needs an ordinary user account
- User interaction
- none: nobody has to click or open anything
- Scope
- unchanged: the damage stays inside the vulnerable component
- Impact
- confidentiality high, integrity high, availability high: what an attacker can read (confidentiality), change (integrity) or stop (availability)
Exploitation
EPSS 0.21%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 12.3% of all scored CVEs. Scores of 1 Dec 2026.
Affected products
As the CNA lists them.
| Product | Versions |
|---|---|
| Linux |
affected from 54a611b605901c7d5d05b6b8f5d04a6ceb0962aa, before 7c7874977da9e47ca0f53d8b9a5b17385fed83f2 affected from 54a611b605901c7d5d05b6b8f5d04a6ceb0962aa, before 677f1df179cb68c12ddf7707ec325eb50e99c7d9 affected from 54a611b605901c7d5d05b6b8f5d04a6ceb0962aa, before 982dd0d26d1f015ed34866579480d2be5250b0ef affected from 54a611b605901c7d5d05b6b8f5d04a6ceb0962aa, before bea07fd63192b61209d48cbb81ef474cc3ee4c62
Other versions: unaffected
|
| Linux |
affected 6.1 unaffected before 6.1 unaffected from 6.1.114 up to and including 6.1.* unaffected from 6.6.58 up to and including 6.6.* unaffected from 6.11.5 up to and including 6.11.* unaffected 6.12 and later
Other versions: affected
|
Is my server affected?
This CVE is in the Linux kernel. Compare the running kernel with the fixed kernel version of your distribution, and reboot after a kernel update:
uname -r
# Debian, Ubuntu: does the changelog of the running kernel name the CVE?
zgrep -l CVE-2024-50200 /usr/share/doc/linux-image-$(uname -r)/changelog.Debian.gz
# RHEL, Rocky, Alma
rpm -q --changelog kernel | grep CVE-2024-50200
With Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:
trivy rootfs --scanners vuln / | grep CVE-2024-50200
trivy image --scanners vuln IMAGE | grep CVE-2024-50200
Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.
References
Other references
- https://git.kernel.org/stable/c/7c7874977da9e47ca0f53d8b9a5b17385fed83f2 git.kernel.org
- https://git.kernel.org/stable/c/677f1df179cb68c12ddf7707ec325eb50e99c7d9 git.kernel.org
- https://git.kernel.org/stable/c/982dd0d26d1f015ed34866579480d2be5250b0ef git.kernel.org
- https://git.kernel.org/stable/c/bea07fd63192b61209d48cbb81ef474cc3ee4c62 git.kernel.org
- https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html lists.debian.org
Source: the record CVE-2024-50200 of the CVE List (CVE Program), CVE Terms of Use; EPSS of FIRST. The text of the record is shown as published. Data sources and licences.
Vulnpocalypse