{"id":65757,"date":"2025-07-08T13:31:54","date_gmt":"2025-07-08T10:01:54","guid":{"rendered":"https:\/\/afaghhosting.net\/blog\/cve-2025-38236-linux-unix-af_unix-use-after-free-vulnerability\/"},"modified":"2025-07-08T13:31:54","modified_gmt":"2025-07-08T10:01:54","slug":"cve-2025-38236-linux-unix-af_unix-use-after-free-vulnerability","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/cve-2025-38236-linux-unix-af_unix-use-after-free-vulnerability\/","title":{"rendered":"CVE-2025-38236 &#8211; Linux Unix af_unix Use-After-Free Vulnerability"},"content":{"rendered":"<p><strong>CVE ID : <\/strong>CVE-2025-38236<br \/>\n<br \/>\n<strong>Published : <\/strong> July 8, 2025, 8:15 a.m. | 1\u00a0hour ago<br \/>\n<br \/>\n<strong>Description : <\/strong>In the Linux kernel, the following vulnerability has been resolved:<\/p>\n<p>af_unix: Don&#8217;t leave consecutive consumed OOB skbs.<\/p>\n<p>Jann Horn reported a use-after-free in unix_stream_read_generic().<\/p>\n<p>The following sequences reproduce the issue:<\/p>\n<p>  $ python3<br \/>\n  from socket import *<br \/>\n  s1, s2 = socketpair(AF_UNIX, SOCK_STREAM)<br \/>\n  s1.send(b&#8217;x&#8217;, MSG_OOB)<br \/>\n  s2.recv(1, MSG_OOB)     # leave a consumed OOB skb<br \/>\n  s1.send(b&#8217;y&#8217;, MSG_OOB)<br \/>\n  s2.recv(1, MSG_OOB)     # leave a consumed OOB skb<br \/>\n  s1.send(b&#8217;z&#8217;, MSG_OOB)<br \/>\n  s2.recv(1)              # recv &#8216;z&#8217; illegally<br \/>\n  s2.recv(1, MSG_OOB)     # access &#8216;z&#8217; skb (use-after-free)<\/p>\n<p>Even though a user reads OOB data, the skb holding the data stays on<br \/>\nthe recv queue to mark the OOB boundary and break the next recv().<\/p>\n<p>After the last send() in the scenario above, the sk2&#8217;s recv queue has<br \/>\n2 leading consumed OOB skbs and 1 real OOB skb.<\/p>\n<p>Then, the following happens during the next recv() without MSG_OOB<\/p>\n<p>  1. unix_stream_read_generic() peeks the first consumed OOB skb<br \/>\n  2. manage_oob() returns the next consumed OOB skb<br \/>\n  3. unix_stream_read_generic() fetches the next not-yet-consumed OOB skb<br \/>\n  4. unix_stream_read_generic() reads and frees the OOB skb<\/p>\n<p>, and the last recv(MSG_OOB) triggers KASAN splat.<\/p>\n<p>The 3. above occurs because of the SO_PEEK_OFF code, which does not<br \/>\nexpect unix_skb_len(skb) to be 0, but this is true for such consumed<br \/>\nOOB skbs.<\/p>\n<p>  while (skip &gt;= unix_skb_len(skb)) {<br \/>\n    skip -= unix_skb_len(skb);<br \/>\n    skb = skb_peek_next(skb, &amp;sk-&gt;sk_receive_queue);<br \/>\n    &#8230;<br \/>\n  }<\/p>\n<p>In addition to this use-after-free, there is another issue that<br \/>\nioctl(SIOCATMARK) does not function properly with consecutive consumed<br \/>\nOOB skbs.<\/p>\n<p>So, nothing good comes out of such a situation.<\/p>\n<p>Instead of complicating manage_oob(), ioctl() handling, and the next<br \/>\nECONNRESET fix by introducing a loop for consecutive consumed OOB skbs,<br \/>\nlet&#8217;s not leave such consecutive OOB unnecessarily.<\/p>\n<p>Now, while receiving an OOB skb in unix_stream_recv_urg(), if its<br \/>\nprevious skb is a consumed OOB skb, it is freed.<\/p>\n[0]:<br \/>\nBUG: KASAN: slab-use-after-free in unix_stream_read_actor (net\/unix\/af_unix.c:3027)<br \/>\nRead of size 4 at addr ffff888106ef2904 by task python3\/315<\/p>\n<p>CPU: 2 UID: 0 PID: 315 Comm: python3 Not tainted 6.16.0-rc1-00407-gec315832f6f9 #8 PREEMPT(voluntary)<br \/>\nHardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-4.fc42 04\/01\/2014<br \/>\nCall Trace:<\/p>\n<p> dump_stack_lvl (lib\/dump_stack.c:122)<br \/>\n print_report (mm\/kasan\/report.c:409 mm\/kasan\/report.c:521)<br \/>\n kasan_report (mm\/kasan\/report.c:636)<br \/>\n unix_stream_read_actor (net\/unix\/af_unix.c:3027)<br \/>\n unix_stream_read_generic (net\/unix\/af_unix.c:2708 net\/unix\/af_unix.c:2847)<br \/>\n unix_stream_recvmsg (net\/unix\/af_unix.c:3048)<br \/>\n sock_recvmsg (net\/socket.c:1063 (discriminator 20) net\/socket.c:1085 (discriminator 20))<br \/>\n __sys_recvfrom (net\/socket.c:2278)<br \/>\n __x64_sys_recvfrom (net\/socket.c:2291 (discriminator 1) net\/socket.c:2287 (discriminator 1) net\/socket.c:2287 (discriminator 1))<br \/>\n do_syscall_64 (arch\/x86\/entry\/syscall_64.c:63 (discriminator 1) arch\/x86\/entry\/syscall_64.c:94 (discriminator 1))<br \/>\n entry_SYSCALL_64_after_hwframe (arch\/x86\/entry\/entry_64.S:130)<br \/>\nRIP: 0033:0x7f8911fcea06<br \/>\nCode: 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  8b 5d f8 c9 c3 0f 1f 40 00 f3 0f 1e fa 55 48 89 e5 48 83 ec 08<br \/>\nRSP: 002b:00007fffdb0dccb0 EFLAGS: 00000202 ORIG_RAX: 000000000000002d<br \/>\nRAX: ffffffffffffffda RBX: 00007fffdb0dcdc8 RCX: 00007f8911fcea06<br \/>\nRDX: 0000000000000001 RSI: 00007f8911a5e060 RDI: 0000000000000006<br \/>\nRBP: 00007fffdb0dccd0 R08: 0000000000000000 R09: 0000000000000000<br \/>\nR10: 0000000000000001 R11: 0000000000000202 R12: 00007f89119a7d20<br \/>\nR13: ffffffffc4653600 R14: 0000000000000000 R15: 0000000000000000<\/p>\n<p>Allocated by task 315:<br \/>\n kasan_save_stack (mm\/kasan\/common.c:48)<br \/>\n kasan_save_track (mm\/kasan\/common.c:60 (discriminator 1) mm\/kasan\/common.c:69 (discriminator 1))<br \/>\n __kasan_slab_alloc (mm\/kasan\/common.c:348)<br \/>\n kmem_cache_alloc_<br \/>\n&#8212;truncated&#8212;<br \/>\n<br \/>\n<strong>Severity:<\/strong> 0.0 | NA<br \/>\n<br \/>\nVisit the link for more details, such as CVSS details, affected products, timeline, and more&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CVE ID : CVE-2025-38236 Published : July 8, 2025, 8:15 a.m. | 1\u00a0hour ago Description : In the Linux kernel, the following vulnerability has been resolved: af_unix: Don&#8217;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 = &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-65757","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/65757","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=65757"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/65757\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=65757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=65757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=65757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}