syzbot


KASAN: use-after-free Read in consume_skb

Status: auto-obsoleted due to no activity on 2024/02/15 15:09
Reported-by: syzbot+667c0f2f1a7b3f2cd327@syzkaller.appspotmail.com
First crash: 438d, last: 380d
Cause bisection: failed (error log, bisect log)
  
Fix bisection: fixed by (bisect log) :
commit 923877254f002ae87d441382bb1096d9e773d56d
Author: John Fastabend <john.fastabend@gmail.com>
Date: Fri Sep 1 20:21:37 2023 +0000

  bpf, sockmap: Fix skb refcnt race after locking changes

  
Bug presence (2)
Date Name Commit Repro Result
2023/12/09 lts (merge base) 082280fe94a0 C Didn't crash
2023/12/09 upstream (ToT) f2e8a57ee903 C Didn't crash
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-15 KASAN: use-after-free Read in consume_skb origin:lts C 38 1d18h 427d 0/2 upstream: reported C repro on 2023/09/21 02:29
linux-5.15 KASAN: use-after-free Read in consume_skb origin:lts-only C error 3 83d 104d 0/3 upstream: reported C repro on 2024/08/09 08:33
upstream KASAN: use-after-free Read in consume_skb bpf net C done inconclusive 33 859d 1138d 0/28 closed as invalid on 2022/10/12 18:37
upstream KASAN: slab-use-after-free Read in consume_skb net bpf C error 6 442d 443d 0/28 closed as invalid on 2023/10/04 10:50
Last patch testing requests (3)
Created Duration User Patch Repo Result
2023/10/08 00:42 7m retest repro android14-6.1 report log
2023/10/08 00:42 5m retest repro android14-6.1 report log
2023/10/08 00:42 11m retest repro android14-6.1 report log
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2023/12/08 01:25 3h59m bisect fix android14-6.1 OK (1) job log
2023/11/07 14:00 1h09m bisect fix android14-6.1 OK (0) job log log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:72 [inline]
BUG: KASAN: use-after-free in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in refcount_read include/linux/refcount.h:147 [inline]
BUG: KASAN: use-after-free in skb_unref include/linux/skbuff.h:1207 [inline]
BUG: KASAN: use-after-free in consume_skb+0x3c/0x250 net/core/skbuff.c:1029
Read of size 4 at addr ffff888121dc00f4 by task kworker/0:1/19

CPU: 0 PID: 19 Comm: kworker/0:1 Not tainted 6.1.25-syzkaller-00013-gd3212c2dbaba #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
Workqueue: events sk_psock_destroy
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x158/0x4e0 mm/kasan/report.c:427
 kasan_report+0x13c/0x170 mm/kasan/report.c:531
 kasan_check_range+0x294/0x2a0 mm/kasan/generic.c:189
 __kasan_check_read+0x11/0x20 mm/kasan/shadow.c:31
 instrument_atomic_read include/linux/instrumented.h:72 [inline]
 atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
 refcount_read include/linux/refcount.h:147 [inline]
 skb_unref include/linux/skbuff.h:1207 [inline]
 consume_skb+0x3c/0x250 net/core/skbuff.c:1029
 __sk_msg_free+0x2dd/0x370 net/core/skmsg.c:205
 sk_msg_free net/core/skmsg.c:218 [inline]
 __sk_psock_purge_ingress_msg net/core/skmsg.c:769 [inline]
 __sk_psock_zap_ingress net/core/skmsg.c:782 [inline]
 sk_psock_destroy+0x351/0x810 net/core/skmsg.c:814
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2296
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2443
 kthread+0x26d/0x300 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
 </TASK>

Allocated by task 304:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505
 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:333
 kasan_slab_alloc include/linux/kasan.h:202 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:768
 slab_alloc_node mm/slub.c:3418 [inline]
 kmem_cache_alloc_node+0x18a/0x2d0 mm/slub.c:3463
 __alloc_skb+0xcc/0x2c0 net/core/skbuff.c:497
 alloc_skb include/linux/skbuff.h:1275 [inline]
 alloc_skb_with_frags+0xa6/0x680 net/core/skbuff.c:6128
 sock_alloc_send_pskb+0x915/0xa50 net/core/sock.c:2727
 unix_dgram_sendmsg+0x5b1/0x2050 net/unix/af_unix.c:1943
 sock_sendmsg_nosec net/socket.c:716 [inline]
 sock_sendmsg net/socket.c:736 [inline]
 ____sys_sendmsg+0x5dc/0x9d0 net/socket.c:2482
 ___sys_sendmsg net/socket.c:2536 [inline]
 __sys_sendmmsg+0x3b9/0x6f0 net/socket.c:2622
 __do_sys_sendmmsg net/socket.c:2651 [inline]
 __se_sys_sendmmsg net/socket.c:2648 [inline]
 __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2648
 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+0x63/0xcd

Freed by task 19:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249
 kasan_slab_free include/linux/kasan.h:178 [inline]
 slab_free_hook mm/slub.c:1744 [inline]
 slab_free_freelist_hook mm/slub.c:1770 [inline]
 slab_free mm/slub.c:3681 [inline]
 kmem_cache_free+0x291/0x510 mm/slub.c:3703
 kfree_skbmem+0x104/0x170
 __kfree_skb net/core/skbuff.c:869 [inline]
 kfree_skb_reason+0xdb/0x250 net/core/skbuff.c:891
 kfree_skb include/linux/skbuff.h:1224 [inline]
 sock_drop include/linux/skmsg.h:306 [inline]
 __sk_psock_zap_ingress net/core/skmsg.c:780 [inline]
 sk_psock_destroy+0x143/0x810 net/core/skmsg.c:814
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2296
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2443
 kthread+0x26d/0x300 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

The buggy address belongs to the object at ffff888121dc0000
 which belongs to the cache skbuff_head_cache of size 256
The buggy address is located 244 bytes inside of
 256-byte region [ffff888121dc0000, ffff888121dc0100)

The buggy address belongs to the physical page:
page:ffffea0004877000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x121dc0
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 0000000000000000 dead000000000122 ffff888100232a80
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 0x12a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY), pid 290, tgid 290 (sshd), ts 22473276328, free_ts 22473263972
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2582
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2589
 get_page_from_freelist+0x2762/0x27f0 mm/page_alloc.c:4387
 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5664
 allocate_slab mm/slub.c:1959 [inline]
 new_slab+0xce/0x4c0 mm/slub.c:2012
 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3200
 __slab_alloc+0x5d/0xa0 mm/slub.c:3299
 slab_alloc_node mm/slub.c:3384 [inline]
 slab_alloc mm/slub.c:3426 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3433 [inline]
 kmem_cache_alloc+0x1b9/0x2c0 mm/slub.c:3442
 skb_clone+0x1f8/0x380 net/core/skbuff.c:1650
 dev_queue_xmit_nit+0x248/0xa90 net/core/dev.c:2272
 xmit_one net/core/dev.c:3596 [inline]
 dev_hard_start_xmit+0x140/0x630 net/core/dev.c:3616
 sch_direct_xmit+0x298/0x9b0 net/sched/sch_generic.c:342
 __dev_xmit_skb net/core/dev.c:3827 [inline]
 __dev_queue_xmit+0x17df/0x3660 net/core/dev.c:4232
 dev_queue_xmit include/linux/netdevice.h:3072 [inline]
 neigh_hh_output include/net/neighbour.h:538 [inline]
 neigh_output include/net/neighbour.h:552 [inline]
 ip_finish_output2+0xb60/0xf90 net/ipv4/ip_output.c:228
 __ip_finish_output+0x162/0x370
 ip_finish_output+0x31/0x2a0 net/ipv4/ip_output.c:316
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1494 [inline]
 free_pcp_prepare mm/page_alloc.c:1568 [inline]
 free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3486
 free_unref_page+0x8d/0x480 mm/page_alloc.c:3582
 free_the_page+0x13/0x20 mm/page_alloc.c:794
 page_frag_free+0x108/0x120 mm/page_alloc.c:5892
 skb_free_frag include/linux/skbuff.h:3198 [inline]
 skb_free_head net/core/skbuff.c:758 [inline]
 skb_release_data+0x6ba/0x840 net/core/skbuff.c:789
 skb_release_all net/core/skbuff.c:854 [inline]
 __kfree_skb+0x50/0x70 net/core/skbuff.c:868
 tcp_rcv_established+0xe39/0x1c60 net/ipv4/tcp_input.c:5915
 tcp_v4_do_rcv+0x430/0xa20 net/ipv4/tcp_ipv4.c:1670
 sk_backlog_rcv include/net/sock.h:1123 [inline]
 __release_sock+0x145/0x410 net/core/sock.c:2915
 release_sock+0x65/0x1b0 net/core/sock.c:3489
 tcp_sendmsg+0x3a/0x50 net/ipv4/tcp.c:1485
 inet_sendmsg+0xa1/0xc0 net/ipv4/af_inet.c:830
 sock_sendmsg_nosec net/socket.c:716 [inline]
 sock_sendmsg net/socket.c:736 [inline]
 sock_write_iter+0x394/0x4e0 net/socket.c:1113
 call_write_iter include/linux/fs.h:2215 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x902/0xeb0 fs/read_write.c:584
 ksys_write+0x199/0x2c0 fs/read_write.c:637
 __do_sys_write fs/read_write.c:649 [inline]
 __se_sys_write fs/read_write.c:646 [inline]
 __x64_sys_write+0x7b/0x90 fs/read_write.c:646

Memory state around the buggy address:
 ffff888121dbff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888121dc0000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888121dc0080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                             ^
 ffff888121dc0100: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
 ffff888121dc0180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/09/17 21:01 android14-6.1 d3212c2dbaba 0b6a67ac .config strace log report syz C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in consume_skb
2023/09/09 22:21 android14-6.1 cd94fe67fd33 6654cf89 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in consume_skb
2023/09/09 21:38 android14-6.1 cd94fe67fd33 6654cf89 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in consume_skb
2023/09/23 22:58 android14-6.1 060ebb378d1c 0b6a67ac .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in consume_skb
* Struck through repros no longer work on HEAD.