CVE-2024-35970·Kernel vulnerability
In the Linux kernel, the following vulnerability has been resolved: af_unix: Clear stale u->oob_skb. syzkaller started to report deadlock of unix_gc_lock after commit 4090fa373f0e ("af_unix: Replace garbage collection algorithm."), but it just uncovers the bug that has been there since commit 314001f0bf92 ("af_unix: Add OOB support"). The repro basically does the following. from socket import * from array import array c1, c2 = socketpair(AF_UNIX, SOCK_STREAM) c1.sendmsg([b'a'], [(SOL_SOCKET, SCM_RIGHTS, array("i", [c2.fileno()]))], MSG_OOB) c2.recv(1) # blocked as no normal data in recv queue c2.close() # done async and unblock recv() c1.close() # done async and trigger GC A socket sends its file descriptor to itself as OOB data and tries to receive normal data, but finally recv() fails due to async close(). The problem here is wrong handling of OOB skb in manage_oob(). When recvmsg() is called without MSG_OOB, manage_oob() is called to check if the peeked skb is OOB skb. In such a case, manage_oob() pops it out of the receive queue but does not clear unix_sock(sk)->oob_skb. This is wrong in terms of uAPI. Let's say we send "hello" with MSG_OOB, and "world" without MSG_OOB. The 'o' is handled as OOB data. When recv() is called twice without MSG_OOB, the OOB data should be lost. >>> from socket import * >>> c1, c2 = socketpair(AF_UNIX, SOCK_STREAM, 0) >>> c1.send(b'hello', MSG_OOB) # 'o' is OOB data 5 >>> c1.send(b'world') 5 >>> c2.recv(5) # OOB data is not received b'hell' >>> c2.recv(5) # OOB date is skipped b'world' >>> c2.recv(5, MSG_OOB) # This should return an error b'o' In the same situation, TCP actually returns -EINVAL for the last recv(). Also, if we do not clear unix_sk(sk)->oob_skb, unix_poll() always set EPOLLPRI even though the data has passed through by previous recv(). To avoid these issues, we must clear unix_sk(sk)->oob_skb when dequeuing it from recv queue. The reason why the old GC did not trigger the deadlock is because the old GC relied on the receive queue to detect the loop. When it is triggered, the socket with OOB data is marked as GC candidate because file refcount == inflight count (1). However, after traversing all inflight sockets, the socket still has a positive inflight count (1), thus the socket is excluded from candidates. Then, the old GC lose the chance to garbage-collect the socket. With the old GC, the repro continues to create true garbage that will never be freed nor detected by kmemleak as it's linked to the global inflight list. That's why we couldn't even notice the issue.
- Severity
- medium
- Software
- Kernel
- Fixed in
- 6.8.7
- Published
How likely is exploitation
FIRST's Exploit Prediction Scoring System puts the probability of this CVE being exploited in the next 30 days at <0.1% — higher than 22% of all published CVEs. EPSS is an independent forecast of exploitation, not a severity rating: it says nothing about how much damage a successful attack does, which is what a CVSS score measures.
Affected versions
From: 6.7
Until: 6.8.7
Fixed in: 6.8.7
How to fix this CVE
Update your Linux kernel to version 6.8.7 or later to address a socket handling vulnerability in the af_unix subsystem. This patch ensures that out-of-band (OOB) socket data is properly cleared during receive operations, preventing deadlock conditions and resource leaks. Kernel updates are critical and should be applied promptly, followed by a system reboot.
sudo dnf update kernel kernel-devel && sudo rebootDefensia detects this vulnerability
How to check if you are affected
- Check current kernel version: uname -r
- Verify if your kernel version is between 6.7 and 6.8.6: if output shows version in affected range, system is vulnerable
- Monitor system logs for deadlock or hang messages: grep -i 'deadlock\|unix_gc_lock\|hung_task' /var/log/kern.log /var/log/messages
- After patching, confirm kernel update: uname -r should show 6.8.7 or later
FAQ
What is CVE-2024-35970?
CVE-2024-35970 is a Linux kernel vulnerability in the af_unix socket implementation where out-of-band (OOB) data is not properly cleared from the receive queue, leading to potential deadlocks during garbage collection and incorrect socket behavior. This affects the kernel's ability to correctly manage file descriptors passed between Unix domain sockets.
Is CVE-2024-35970 being actively exploited?
No, CVE-2024-35970 is not listed on the CISA Known Exploited Vulnerabilities (KEV) catalog and no public exploits are currently available. However, it can be triggered deliberately through specific socket operations and poses a stability risk.
What versions of Kernel are affected by CVE-2024-35970?
Linux kernel versions 6.7.0 through 6.8.6 are affected. Kernel 6.8.7 and later versions contain the fix.
How do I check if my server is vulnerable to CVE-2024-35970?
Run 'uname -r' and compare the output to the affected range (6.7 to 6.8.6). If your kernel version falls within this range, your system is vulnerable and requires immediate patching.
Does Defensia detect CVE-2024-35970?
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-35970 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
- https://git.kernel.org/stable/c/601a89ea24d05089debfa2dc896ea9f5937ac7a6
- https://git.kernel.org/stable/c/698a95ade1a00e6494482046902b986dfffd1caf
- https://git.kernel.org/stable/c/84a352b7eba1142a95441380058985ff19f25ec9
- https://git.kernel.org/stable/c/b46f4eaa4f0ec38909fb0072eea3aeddb32f954e
- https://git.kernel.org/stable/c/b4bc99d04c689b5652665394ae8d3e02fb754153
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2024-35970. Free for 1 server.
Get started free