Vulnerability · Published May 20, 2024 · Assigned by Linux

CVE-2024-35970af_unix: Clear stale u->oob_skb.

Medium 6.3

In plain English

A medium-severity security flaw in Linux from Linux. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.5% (higher than 43% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)6.3Medium
Exploit odds (30 days)0.5%top 56.8% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official description

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.

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Debian:12linux6.1.90-1DEBIAN-CVE-2024-35970
Debian:13linux6.8.9-1DEBIAN-CVE-2024-35970
Debian:14linux6.8.9-1DEBIAN-CVE-2024-35970
Ubuntu:22.04:LTSlinux5.15.0-116.126UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux6.8.0-38.38UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-allwinner-5.19no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-aws5.15.0-1065.71UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-aws6.8.0-1011.12UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-aws-5.19no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-aws-6.2no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-aws-6.5no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-aws-6.86.8.0-1011.12~22.04.1UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-azure5.15.0-1068.77UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-azure6.8.0-1010.10UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-azure-5.19no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-azure-6.2no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-azure-6.5no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-azure-6.86.8.0-1010.10~22.04.1UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-azure-fde5.15.0-1068.77.1UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-azure-fde-5.19no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-azure-fde-6.2no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-gcp5.15.0-1064.72UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-gcp6.8.0-1010.11UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-gcp-5.19no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-gcp-6.2no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-gcp-6.5no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-gke5.15.0-1062.68UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-gke6.8.0-1006.9UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-gkeop5.15.0-1048.55UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-hwe-5.19no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-hwe-6.2no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-hwe-6.5no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-ibm5.15.0-1058.61UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-ibm6.8.0-1008.8UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-intel6.8.0-1007.14UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-intel-iotg5.15.0-1060.66UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-kvm5.15.0-1062.67UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-lowlatency5.15.0-116.126UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-lowlatency6.8.0-38.38.1UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-lowlatency-hwe-5.19no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.2no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.5no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-nvidia5.15.0-1060.61UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-nvidia6.8.0-1009.9UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-nvidia-6.2no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-nvidia-6.5no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-nvidia-6.86.8.0-1009.9~22.04.1UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-nvidia-tegra5.15.0-1026.26UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-nvidia-tegra-igx5.15.0-1015.15UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-oem-5.17no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-oem-6.0no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-oem-6.1no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-oem-6.5no fix listedUBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-oem-6.86.8.0-1008.8UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-oracle5.15.0-1063.69UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-oracle6.8.0-1008.8UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-oracle-6.5no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-oracle-6.86.8.0-1008.8~22.04.1UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-raspi5.15.0-1058.61UBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-raspi6.8.0-1007.7UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-realtimeno fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-riscvno fix listedUBUNTU-CVE-2024-35970
Ubuntu:24.04:LTSlinux-riscv6.8.0-38.38.1UBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-riscv-5.19no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-riscv-6.5no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-starfive-5.19no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-starfive-6.2no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-starfive-6.5no fix listedUBUNTU-CVE-2024-35970
Ubuntu:22.04:LTSlinux-xilinx-zynqmp5.15.0-1035.39UBUNTU-CVE-2024-35970

Affected products (as reported)

VendorProductVersions
Linux Linux 314001f0bf927015e459c9d387d62a231fe93af3 – before b4bc99d04c689b5652665394ae8d3e02fb754153314001f0bf927015e459c9d387d62a231fe93af3 – before 84a352b7eba1142a95441380058985ff19f25ec9314001f0bf927015e459c9d387d62a231fe93af3 – before 601a89ea24d05089debfa2dc896ea9f5937ac7a6314001f0bf927015e459c9d387d62a231fe93af3 – before 698a95ade1a00e6494482046902b986dfffd1caf314001f0bf927015e459c9d387d62a231fe93af3 – before b46f4eaa4f0ec38909fb0072eea3aeddb32f954e
Linux Linux 5.15

References