syzbot


KASAN: use-after-free Read in __skb_datagram_iter

Status: auto-obsoleted due to no activity on 2024/03/22 20:57
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+ad5184ef1caf241e7c0d@syzkaller.appspotmail.com
First crash: 169d, last: 139d
Fix bisection: fixed by (bisect log) :
commit 75bcfc188abf4fae9c1d5f5dc0a03540be602eef
Author: Eric Dumazet <edumazet@google.com>
Date: Mon Nov 13 13:49:38 2023 +0000

  af_unix: fix use-after-free in unix_stream_read_actor()

  
Bug presence (3)
Date Name Commit Repro Result
2023/11/13 lts (merge base) 12952a23a5da C [report] KASAN: use-after-free Read in unix_stream_read_actor
2023/11/13 upstream (ToT) b85ea95d0864 C [report] KASAN: slab-use-after-free Read in unix_stream_read_actor
2023/12/28 upstream (ToT) f5837722ffec C Didn't crash
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in __skb_datagram_iter net 431 1092d 1100d 0/26 auto-closed as invalid on 2021/07/03 04:24
upstream KMSAN: kernel-infoleak in __skb_datagram_iter (2) net C 126 36d 88d 26/26 fixed on 2024/03/25 23:45
upstream KMSAN: kernel-infoleak in copyout (2) net C 6723 327d 1496d 22/26 fixed on 2023/06/08 14:41
upstream KMSAN: kernel-infoleak in __skb_datagram_iter (3) net C 18 4d22h 34d 25/26 internal: reported C repro on 2024/03/27 05:33
upstream KMSAN: kernel-infoleak in __skb_datagram_iter net 68 217d 322d 23/26 fixed on 2023/09/28 17:51
Last patch testing requests (1)
Created Duration User Patch Repo Result
2023/11/27 13:23 7m retest repro android13-5.15-lts report log
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2024/01/14 10:49 4h19m bisect fix android13-5.15-lts job log (1)
2023/12/13 20:08 48m bisect fix android13-5.15-lts job log (0) log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in skb_headlen include/linux/skbuff.h:2237 [inline]
BUG: KASAN: use-after-free in __skb_datagram_iter+0x6f8/0x760 net/core/datagram.c:417
Read of size 4 at addr ffff88811d973cf0 by task syz-executor347/394

CPU: 0 PID: 394 Comm: syz-executor347 Not tainted 5.15.137-syzkaller-01792-g61cfd264993d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description+0x87/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:427 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:444
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308
 skb_headlen include/linux/skbuff.h:2237 [inline]
 __skb_datagram_iter+0x6f8/0x760 net/core/datagram.c:417
 skb_copy_datagram_iter+0x43/0x170 net/core/datagram.c:533
 skb_copy_datagram_msg include/linux/skbuff.h:3748 [inline]
 unix_stream_read_actor+0x70/0xb0 net/unix/af_unix.c:2809
 unix_stream_recv_urg+0x1b4/0x2f0 net/unix/af_unix.c:2535
 unix_stream_read_generic+0x2147/0x2240 net/unix/af_unix.c:2615
 unix_stream_recvmsg+0x22d/0x2c0 net/unix/af_unix.c:2847
 ____sys_recvmsg+0x286/0x530
 ___sys_recvmsg+0x1ec/0x690 net/socket.c:2690
 __sys_recvmsg net/socket.c:2720 [inline]
 __do_sys_recvmsg net/socket.c:2730 [inline]
 __se_sys_recvmsg net/socket.c:2727 [inline]
 __x64_sys_recvmsg+0x1dc/0x2b0 net/socket.c:2727
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f34b71a1559
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 18 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f34b7120228 EFLAGS: 00000246 ORIG_RAX: 000000000000002f
RAX: ffffffffffffffda RBX: 0000000000000037 RCX: 00007f34b71a1559
RDX: 0000000040010083 RSI: 0000000020000140 RDI: 0000000000000004
RBP: 00007f34b722b348 R08: 00007f34b71206c0 R09: 00007f34b71206c0
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f34b722b340
R13: 00007f34b722b34c R14: 00007ffe9a5944f0 R15: 00007ffe9a5945d8
 </TASK>

Allocated by task 393:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:433 [inline]
 __kasan_slab_alloc+0xb1/0xe0 mm/kasan/common.c:466
 kasan_slab_alloc include/linux/kasan.h:217 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:550
 slab_alloc_node mm/slub.c:3240 [inline]
 slab_alloc mm/slub.c:3248 [inline]
 kmem_cache_alloc+0xf5/0x200 mm/slub.c:3253
 kmem_cache_alloc_node include/linux/slab.h:474 [inline]
 __alloc_skb+0xbe/0x550 net/core/skbuff.c:416
 alloc_skb include/linux/skbuff.h:1183 [inline]
 alloc_skb_with_frags+0xa6/0x680 net/core/skbuff.c:6156
 sock_alloc_send_pskb+0x915/0xa50 net/core/sock.c:2518
 sock_alloc_send_skb+0x32/0x40 net/core/sock.c:2535
 queue_oob+0xfd/0x8c0 net/unix/af_unix.c:1980
 unix_stream_sendmsg+0xe06/0x1060 net/unix/af_unix.c:2117
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2429
 ___sys_sendmsg+0x252/0x2e0 net/socket.c:2483
 __sys_sendmsg net/socket.c:2512 [inline]
 __do_sys_sendmsg net/socket.c:2521 [inline]
 __se_sys_sendmsg+0x19a/0x260 net/socket.c:2519
 __x64_sys_sendmsg+0x7b/0x90 net/socket.c:2519
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 393:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x126/0x160 mm/kasan/common.c:365
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:373
 kasan_slab_free include/linux/kasan.h:193 [inline]
 slab_free_hook mm/slub.c:1723 [inline]
 slab_free_freelist_hook+0xbd/0x190 mm/slub.c:1749
 slab_free mm/slub.c:3519 [inline]
 kmem_cache_free+0x116/0x2e0 mm/slub.c:3535
 kfree_skbmem+0x104/0x170
 __kfree_skb net/core/skbuff.c:758 [inline]
 consume_skb+0xb4/0x250 net/core/skbuff.c:930
 queue_oob+0x522/0x8c0 net/unix/af_unix.c:2011
 unix_stream_sendmsg+0xe06/0x1060 net/unix/af_unix.c:2117
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2429
 ___sys_sendmsg+0x252/0x2e0 net/socket.c:2483
 __sys_sendmsg net/socket.c:2512 [inline]
 __do_sys_sendmsg net/socket.c:2521 [inline]
 __se_sys_sendmsg+0x19a/0x260 net/socket.c:2519
 __x64_sys_sendmsg+0x7b/0x90 net/socket.c:2519
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff88811d973c80
 which belongs to the cache skbuff_head_cache of size 248
The buggy address is located 112 bytes inside of
 248-byte region [ffff88811d973c80, ffff88811d973d78)
The buggy address belongs to the page:
page:ffffea0004765cc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11d973
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 0000000000000000 dead000000000122 ffff888100350c00
raw: 0000000000000000 00000000000c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 382, ts 20077788698, free_ts 20017445560
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x1a3/0x1b0 mm/page_alloc.c:2602
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2608
 get_page_from_freelist+0x3550/0x35d0 mm/page_alloc.c:4482
 __alloc_pages+0x206/0x5e0 mm/page_alloc.c:5773
 allocate_slab mm/slub.c:1932 [inline]
 new_slab+0x9a/0x4e0 mm/slub.c:1995
 ___slab_alloc+0x39e/0x830 mm/slub.c:3028
 __slab_alloc+0x4a/0x90 mm/slub.c:3115
 slab_alloc_node mm/slub.c:3206 [inline]
 slab_alloc mm/slub.c:3248 [inline]
 kmem_cache_alloc+0x134/0x200 mm/slub.c:3253
 kmem_cache_alloc_node include/linux/slab.h:474 [inline]
 __alloc_skb+0xbe/0x550 net/core/skbuff.c:416
 alloc_skb include/linux/skbuff.h:1183 [inline]
 alloc_skb_with_frags+0xa6/0x680 net/core/skbuff.c:6156
 sock_alloc_send_pskb+0x915/0xa50 net/core/sock.c:2518
 sock_alloc_send_skb+0x32/0x40 net/core/sock.c:2535
 queue_oob+0xfd/0x8c0 net/unix/af_unix.c:1980
 unix_stream_sendmsg+0xe06/0x1060 net/unix/af_unix.c:2117
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2429
 ___sys_sendmsg+0x252/0x2e0 net/socket.c:2483
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1469 [inline]
 free_pcp_prepare mm/page_alloc.c:1541 [inline]
 free_unref_page_prepare+0x7c8/0x7d0 mm/page_alloc.c:3531
 free_unref_page+0xe6/0x730 mm/page_alloc.c:3613
 free_the_page mm/page_alloc.c:802 [inline]
 __free_pages+0x61/0xf0 mm/page_alloc.c:5849
 __vunmap+0x7bc/0x8f0 mm/vmalloc.c:2652
 free_work+0x5b/0x80 mm/vmalloc.c:96
 process_one_work+0x6bb/0xc10 kernel/workqueue.c:2317
 worker_thread+0xad5/0x12a0 kernel/workqueue.c:2464
 kthread+0x421/0x510 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Memory state around the buggy address:
 ffff88811d973b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88811d973c00: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
>ffff88811d973c80: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                             ^
 ffff88811d973d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc
 ffff88811d973d80: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/11/13 13:23 android13-5.15-lts 61cfd264993d 6d6dbf8a .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in __skb_datagram_iter
* Struck through repros no longer work on HEAD.