CVE-2024-26958·Kernel vulnerability
In the Linux kernel, the following vulnerability has been resolved: nfs: fix UAF in direct writes In production we have been hitting the following warning consistently ------------[ cut here ]------------ refcount_t: underflow; use-after-free. WARNING: CPU: 17 PID: 1800359 at lib/refcount.c:28 refcount_warn_saturate+0x9c/0xe0 Workqueue: nfsiod nfs_direct_write_schedule_work [nfs] RIP: 0010:refcount_warn_saturate+0x9c/0xe0 PKRU: 55555554 Call Trace: <TASK> ? __warn+0x9f/0x130 ? refcount_warn_saturate+0x9c/0xe0 ? report_bug+0xcc/0x150 ? handle_bug+0x3d/0x70 ? exc_invalid_op+0x16/0x40 ? asm_exc_invalid_op+0x16/0x20 ? refcount_warn_saturate+0x9c/0xe0 nfs_direct_write_schedule_work+0x237/0x250 [nfs] process_one_work+0x12f/0x4a0 worker_thread+0x14e/0x3b0 ? ZSTD_getCParams_internal+0x220/0x220 kthread+0xdc/0x120 ? __btf_name_valid+0xa0/0xa0 ret_from_fork+0x1f/0x30 This is because we're completing the nfs_direct_request twice in a row. The source of this is when we have our commit requests to submit, we process them and send them off, and then in the completion path for the commit requests we have if (nfs_commit_end(cinfo.mds)) nfs_direct_write_complete(dreq); However since we're submitting asynchronous requests we sometimes have one that completes before we submit the next one, so we end up calling complete on the nfs_direct_request twice. The only other place we use nfs_generic_commit_list() is in __nfs_commit_inode, which wraps this call in a nfs_commit_begin(); nfs_commit_end(); Which is a common pattern for this style of completion handling, one that is also repeated in the direct code with get_dreq()/put_dreq() calls around where we process events as well as in the completion paths. Fix this by using the same pattern for the commit requests. Before with my 200 node rocksdb stress running this warning would pop every 10ish minutes. With my patch the stress test has been running for several hours without popping.
- Severity
- high
- Software
- Kernel
- Fixed in
- 6.8.3
- Published
- 2024-05-01
Affected versions
From: 6.8
Until: 6.8.3
Fixed in: 6.8.3
How to fix this CVE
Update your Linux kernel to version 6.8.3 or later to resolve this use-after-free vulnerability in NFS direct write operations. This patch corrects a reference counting issue that caused double-completion of NFS direct requests, leading to memory safety violations. Affected systems running kernel versions 6.8 through 6.8.2 should prioritize this update immediately.
sudo dnf update kernel kernel-develDefensia detects this vulnerability
How to check if you are affected
- Check your current kernel version: uname -r
- Verify if you are running an affected version (6.8.0 through 6.8.2): uname -r | grep -E '6\.8\.[0-2]($|-)'
- Search kernel logs for the refcount underflow warning: grep -i 'refcount_t: underflow' /var/log/kern.log /var/log/messages
- Monitor dmesg for nfs_direct_write_schedule_work warnings: dmesg | grep -A5 'nfs_direct_write_schedule_work'
- After patching, confirm the new kernel version: uname -r (should be 6.8.3 or later)
FAQ
What is CVE-2024-26958?
CVE-2024-26958 is a use-after-free vulnerability in the Linux kernel's NFS subsystem where asynchronous commit requests in direct write operations can cause double-completion of NFS requests, triggering reference count underflow warnings and potential memory corruption.
Is CVE-2024-26958 being actively exploited?
No, CVE-2024-26958 is not currently listed as being actively exploited in the CISA Known Exploited Vulnerabilities (KEV) catalog, and no public exploits are available.
What versions of Kernel are affected by CVE-2024-26958?
Linux kernel versions 6.8.0 through 6.8.2 are affected; the vulnerability is resolved in kernel 6.8.3 and later versions.
How do I check if my server is vulnerable to CVE-2024-26958?
Run 'uname -r' to check your kernel version; if it matches 6.8.0, 6.8.1, or 6.8.2, your system is vulnerable. You can also search your kernel logs with 'grep -i refcount_t: /var/log/kern.log' for exploitation indicators.
What is the root cause of this vulnerability?
The vulnerability stems from improper reference counting in NFS commit request handling where asynchronous completion callbacks can fire before all commit requests are submitted, causing the same NFS direct request to be completed twice.
Does Defensia detect CVE-2024-26958?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If the Linux kernel is installed on a monitored server, CVE-2024-26958 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
- https://git.kernel.org/stable/c/17f46b803d4f23c66cacce81db35fef3adb8f2af
- https://git.kernel.org/stable/c/1daf52b5ffb24870fbeda20b4967526d8f9e12ab
- https://git.kernel.org/stable/c/3abc2d160ed8213948b147295d77d44a22c88fa3
- https://git.kernel.org/stable/c/4595d90b5d2ea5fa4d318d13f59055aa4bf3e7f5
- https://git.kernel.org/stable/c/6cd3f13aaa62970b5169d990e936b2e96943bc6a
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2024-26958. Free for 1 server.
Get started free