CVE-2024-35798: btrfs: fix race in read_extent_buffer_pages()
In the Linux kernel, the following vulnerability has been resolved:
btrfs: fix race in readextentbufferpages()
There are reports from tree-checker that detects corrupted nodes, without any obvious pattern so possibly an overwrite in memory. After some debugging it turns out there's a race when reading an extent buffer the uptodate status can be missed.
To prevent concurrent reads for the same extent buffer, readextentbufferpages() performs these checks:
/ (1) / if (testbit(EXTENTBUFFERUPTODATE, &eb->bflags)) return 0;
/ (2) / if (testandsetbit(EXTENTBUFFERREADING, &eb->bflags)) goto done;
At this point, it seems safe to start the actual read operation. Once that completes, endbbiometaread() does
/ (3) / setextentbufferuptodate(eb);
/ (4) / clearbit(EXTENTBUFFERREADING, &eb->bflags);
Normally, this is enough to ensure only one read happens, and all other callers wait for it to finish before returning. Unfortunately, there is a racey interleaving:
Thread A | Thread B | Thread C ---------+----------+--------- (1) | | | (1) | (2) | | (3) | | (4) | | | (2) | | | (1)
When this happens, thread B kicks of an unnecessary read. Worse, thread C will see UPTODATE set and return immediately, while the read from thread B is still in progress. This race could result in tree-checker errors like this as the extent buffer is concurrently modified:
BTRFS critical (device dm-0): corrupted node, root=256 block=8550954455682405139 owner mismatch, have 11858205567642294356 expect [256, 18446744073709551360]
Fix it by testing UPTODATE again after setting the READING bit, and if it's been set, skip the unnecessary read.
[ minor update of changelog ]
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.223-1Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.25-1Fixed in 6.12.27-1
Event History
Frequently Asked Questions
What is the severity of CVE-2024-35798?
The severity of CVE-2024-35798 is classified based on its potential impact on system integrity and security, particularly regarding memory overwrite issues.
How do I fix CVE-2024-35798?
To fix CVE-2024-35798, it is recommended to update to the patched versions of the Linux kernel: 5.10.223-1, 5.10.226-1, 6.1.119-1, 6.1.123-1, 6.12.11-1, or 6.12.12-1.
What software is affected by CVE-2024-35798?
CVE-2024-35798 affects specific versions of the Linux kernel, notably those on Debian systems.
What types of vulnerabilities does CVE-2024-35798 address?
CVE-2024-35798 addresses a race condition in the btrfs file system that may lead to memory corruption.
How can I verify if my system is vulnerable to CVE-2024-35798?
You can verify if your system is vulnerable to CVE-2024-35798 by checking the currently installed version of the Linux kernel against the affected versions.