Skip to content

CVE-2025-38236 af_unix: Don't leave consecutive consumed OOB skbs.

HighCVSS 7.8 EPSS 0.30%
Published
Updated
Exploit status
No public exploit known
Technology
Linux KernelUbuntuDebian

Description

In the Linux kernel, the following vulnerability has been resolved:

af_unix: Don't leave consecutive consumed OOB skbs.

Jann Horn reported a use-after-free in unix_stream_read_generic().

The following sequences reproduce the issue:

$ python3
from socket import *
s1, s2 = socketpair(AF_UNIX, SOCK_STREAM)
s1.send(b'x', MSG_OOB)
s2.recv(1, MSG_OOB) # leave a consumed OOB skb
s1.send(b'y', MSG_OOB)
s2.recv(1, MSG_OOB) # leave a consumed OOB skb
s1.send(b'z', MSG_OOB)
s2.recv(1) # recv 'z' illegally
s2.recv(1, MSG_OOB) # access 'z' skb (use-after-free)

Even though a user reads OOB data, the skb holding the data stays on
the recv queue to mark the OOB boundary and break the next recv().

After the last send() in the scenario above, the sk2's recv queue has
2 leading consumed OOB skbs and 1 real OOB skb.

Then, the following happens during the next recv() without MSG_OOB

  1. unix_stream_read_generic() peeks the first consumed OOB skb
  2. manage_oob() returns the next consumed OOB skb
  3. unix_stream_read_generic() fetches the next not-yet-consumed OOB skb
  4. unix_stream_read_generic() reads and frees the OOB skb

, and the last recv(MSG_OOB) triggers KASAN splat.

The 3. above occurs because of the SO_PEEK_OFF code, which does not
expect unix_skb_len(skb) to be 0, but this is true for such consumed
OOB skbs.

while (skip >= unix_skb_len(skb)) {
skip -= unix_skb_len(skb);
skb = skb_peek_next(skb, &sk->sk_receive_queue);
...
}

In addition to this use-after-free, there is another issue that
ioctl(SIOCATMARK) does not function properly with consecutive consumed
OOB skbs.

So, nothing good comes out of such a situation.

Instead of complicating manage_oob(), ioctl() handling, and the next
ECONNRESET fix by introducing a loop for consecutive consumed OOB skbs,
let's not leave such consecutive OOB unnecessarily.

Now, while receiving an OOB skb in unix_stream_recv_urg(), if its
previous skb is a consumed OOB skb, it is freed.

[0]:
BUG: KASAN: slab-use-after-free in unix_stream_read_actor (net/unix/af_unix.c:3027)
Read of size 4 at addr ffff888106ef2904 by task python3/315

CPU: 2 UID: 0 PID: 315 Comm: python3 Not tainted 6.16.0-rc1-00407-gec315832f6f9 #8 PREEMPT(voluntary)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-4.fc42 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl (lib/dump_stack.c:122)
print_report (mm/kasan/report.c:409 mm/kasan/report.c:521)
kasan_report (mm/kasan/report.c:636)
unix_stream_read_actor (net/unix/af_unix.c:3027)
unix_stream_read_generic (net/unix/af_unix.c:2708 net/unix/af_unix.c:2847)
unix_stream_recvmsg (net/unix/af_unix.c:3048)
sock_recvmsg (net/socket.c:1063 (discriminator 20) net/socket.c:1085 (discriminator 20))
__sys_recvfrom (net/socket.c:2278)
__x64_sys_recvfrom (net/socket.c:2291 (discriminator 1) net/socket.c:2287 (discriminator 1) net/socket.c:2287 (discriminator 1))
do_syscall_64 (arch/x86/entry/syscall_64.c:63 (discriminator 1) arch/x86/entry/syscall_64.c:94 (discriminator 1))
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
RIP: 0033:0x7f8911fcea06
Code: 5d e8 41 8b 93 08 03 00 00 59 5e 48 83 f8 fc 75 19 83 e2 39 83 fa 08 75 11 e8 26 ff ff ff 66 0f 1f 44 00 00 48 8b 45 10 0f 05 <48> 8b 5d f8 c9 c3 0f 1f 40 00 f3 0f 1e fa 55 48 89 e5 48 83 ec 08
RSP: 002b:00007fffdb0dccb0 EFLAGS: 00000202 ORIG_RAX: 000000000000002d
RAX: ffffffffffffffda RBX: 00007fffdb0dcdc8 RCX: 00007f8911fcea06
RDX: 0000000000000001 RSI: 00007f8911a5e060 RDI: 0000000000000006
RBP: 00007fffdb0dccd0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000202 R12: 00007f89119a7d20
R13: ffffffffc4653600 R14: 0000000000000000 R15: 0000000000000000
</TASK>

Allocated by task 315:
kasan_save_stack (mm/kasan/common.c:48)
kasan_save_track (mm/kasan/common.c:60 (discriminator 1) mm/kasan/common.c:69 (discriminator 1))
_kasan_slab_alloc (mm/kasan/common.c:348)
kmem_cache_alloc

---truncated---

Upgrade path

15 packages: 11 fixed, 3 with no fix yet.

PackageAffectedFixed inStatus
Siemens SIMATIC S7-1500 CPU 1518-4 PN/DP MFP >= V3.1.5 No fix listed No fix yet
Siemens SIMATIC S7-1500 CPU 1518F-4 PN/DP MFP >= V3.1.5 No fix listed No fix yet
Siemens SIPLUS S7-1500 CPU 1518-4 PN/DP MFP >= V3.1.5 No fix listed No fix yet
azure linux kernel(Azure Linux 3.0) < 6.6.96.1-1 6.6.96.1-1 Fixed
cbl-mariner kernel(CBL-Mariner 2.0) < 5.15.200.1-1 5.15.200.1-1 Fixed
debian/linux(Debian 12) < 6.1.147-1; = 6.1.27-1; = 6.1.37-1; = 6.1.38-1 +38 more 6.1.147-1 Fixed
debian/linux(Debian 13) < 6.12.37-1 6.12.37-1 Fixed
debian/linux(Debian 14) < 6.12.37-1 6.12.37-1 Fixed
Linux kernel < 5.15.194; < 6.1.143; < 6.6.96; < 6.12.36 +17 more 5.15.194, 6.1.143, 6.6.96, 6.12.36, 6.15.5, 6.16, 8db4d2d026e6e3649832bfe23b96c4acff0756db, 32ca245464e1479bfea8592b9db227fdc1641705, 61a9ad7b69ce688697e5f63332f03e17725353bc, 523edfed4f68b7794d85b9ac828c5f8f4442e4c5, a12237865b48a73183df252029ff5065d73d305e, fad0a2c16062ac7c606b93166a7ce9d265bab976 Fixed
ubuntu/linux(Ubuntu 22.04) < 5.15.0-170.180 5.15.0-170.180 Fixed
ubuntu/linux(Ubuntu 24.04) < 6.8.0-100.100 6.8.0-100.100 Fixed
ubuntu/linux-kvm(Ubuntu 22.04) < 5.15.0-1092.97 5.15.0-1092.97 Fixed
ubuntu/linux-raspi(Ubuntu 22.04) < 5.15.0-1097.100 5.15.0-1097.100 Fixed
ubuntu/linux-raspi(Ubuntu 24.04) < 6.8.0-1047.51 6.8.0-1047.51 Fixed
debian linux = 11.0 No fix listed Versions listed

Affected products

ProductAffected versionsFixed in
azure linux kernel(Azure Linux:3.0) < 6.6.96.1-1 6.6.96.1-1
cbl-mariner kernel(CBL-Mariner:2.0) < 5.15.200.1-1 5.15.200.1-1
debian/linux(Debian:12) < 6.1.147-1 6.1.147-1
debian/linux(Debian:12) = 6.1.106-1 No fix listed
debian/linux(Debian:12) = 6.1.106-2 No fix listed
debian/linux(Debian:12) = 6.1.106-3 No fix listed
debian/linux(Debian:12) = 6.1.112-1 No fix listed
debian/linux(Debian:12) = 6.1.115-1 No fix listed
debian/linux(Debian:12) = 6.1.119-1 No fix listed
debian/linux(Debian:12) = 6.1.123-1 No fix listed
debian/linux(Debian:12) = 6.1.124-1 No fix listed
debian/linux(Debian:12) = 6.1.128-1 No fix listed
debian/linux(Debian:12) = 6.1.129-1 No fix listed
debian/linux(Debian:12) = 6.1.133-1 No fix listed
debian/linux(Debian:12) = 6.1.135-1 No fix listed
debian/linux(Debian:12) = 6.1.137-1 No fix listed
debian/linux(Debian:12) = 6.1.139-1 No fix listed
debian/linux(Debian:12) = 6.1.140-1 No fix listed
debian/linux(Debian:12) = 6.1.27-1 No fix listed
debian/linux(Debian:12) = 6.1.37-1 No fix listed
debian/linux(Debian:12) = 6.1.38-1 No fix listed
debian/linux(Debian:12) = 6.1.38-2 No fix listed
debian/linux(Debian:12) = 6.1.38-2~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.38-3 No fix listed
debian/linux(Debian:12) = 6.1.38-4 No fix listed
Show 51 more
ProductAffected versionsFixed in
debian/linux(Debian:12) = 6.1.38-4~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.52-1 No fix listed
debian/linux(Debian:12) = 6.1.55-1 No fix listed
debian/linux(Debian:12) = 6.1.55-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.64-1 No fix listed
debian/linux(Debian:12) = 6.1.66-1 No fix listed
debian/linux(Debian:12) = 6.1.67-1 No fix listed
debian/linux(Debian:12) = 6.1.69-1 No fix listed
debian/linux(Debian:12) = 6.1.69-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.76-1 No fix listed
debian/linux(Debian:12) = 6.1.76-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.82-1 No fix listed
debian/linux(Debian:12) = 6.1.85-1 No fix listed
debian/linux(Debian:12) = 6.1.90-1 No fix listed
debian/linux(Debian:12) = 6.1.90-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.94-1 No fix listed
debian/linux(Debian:12) = 6.1.94-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.98-1 No fix listed
debian/linux(Debian:12) = 6.1.99-1 No fix listed
debian/linux(Debian:13) < 6.12.37-1 6.12.37-1
debian/linux(Debian:14) < 6.12.37-1 6.12.37-1
Linux kernel >= 314001f0bf927015e459c9d387d62a231fe93af3, < 523edfed4f68b7794d85b9ac828c5f8f4442e4c5 523edfed4f68b7794d85b9ac828c5f8f4442e4c5
Linux kernel >= 314001f0bf927015e459c9d387d62a231fe93af3, < a12237865b48a73183df252029ff5065d73d305e a12237865b48a73183df252029ff5065d73d305e
Linux kernel >= 314001f0bf927015e459c9d387d62a231fe93af3, < fad0a2c16062ac7c606b93166a7ce9d265bab976 fad0a2c16062ac7c606b93166a7ce9d265bab976
Linux kernel >= 314001f0bf927015e459c9d387d62a231fe93af3, < 61a9ad7b69ce688697e5f63332f03e17725353bc 61a9ad7b69ce688697e5f63332f03e17725353bc
Linux kernel >= 314001f0bf927015e459c9d387d62a231fe93af3, < 8db4d2d026e6e3649832bfe23b96c4acff0756db 8db4d2d026e6e3649832bfe23b96c4acff0756db
Linux kernel >= 314001f0bf927015e459c9d387d62a231fe93af3, < 32ca245464e1479bfea8592b9db227fdc1641705 32ca245464e1479bfea8592b9db227fdc1641705
Linux kernel = 5.15 No fix listed
Linux kernel < 5.15.194 5.15.194
Linux kernel < 6.1.143 6.1.143
Linux kernel < 6.6.96 6.6.96
Linux kernel < 6.12.36 6.12.36
Linux kernel < 6.15.5 6.15.5
Linux kernel < 6.16 6.16
Siemens SIMATIC S7-1500 CPU 1518-4 PN/DP MFP >= V3.1.5 No fix listed
Siemens SIMATIC S7-1500 CPU 1518F-4 PN/DP MFP >= V3.1.5 No fix listed
Siemens SIPLUS S7-1500 CPU 1518-4 PN/DP MFP >= V3.1.5 No fix listed
ubuntu/linux(Ubuntu:22.04) < 5.15.0-170.180 5.15.0-170.180
ubuntu/linux-kvm(Ubuntu:22.04) < 5.15.0-1092.97 5.15.0-1092.97
ubuntu/linux-raspi(Ubuntu:22.04) < 5.15.0-1097.100 5.15.0-1097.100
ubuntu/linux(Ubuntu:24.04) < 6.8.0-100.100 6.8.0-100.100
ubuntu/linux-raspi(Ubuntu:24.04) < 6.8.0-1047.51 6.8.0-1047.51
Linux kernel >= 5.15, < 5.15.194 5.15.194
Linux kernel >= 5.16, < 6.1.143 6.1.143
Linux kernel >= 6.2, < 6.6.96 6.6.96
Linux kernel >= 6.7, < 6.12.36 6.12.36
Linux kernel >= 6.13, < 6.15.5 6.15.5
Linux kernel = 6.16-rc1 No fix listed
Linux kernel = 6.16-rc2 No fix listed
Linux kernel = 6.16-rc3 No fix listed
debian linux = 11.0 No fix listed

References