syzbot


KASAN: use-after-free Read in consume_skb

Status: upstream: reported C repro on 2024/08/09 08:33
Bug presence: origin:lts-only
[Documentation on labels]
Reported-by: syzbot+0a1590c9227146cfa13f@syzkaller.appspotmail.com
First crash: 67d, last: 46d
Fix bisection: failed (error log, bisect log)
  
Bug presence (2)
Date Name Commit Repro Result
2024/08/09 linux-5.15.y (ToT) 7e89efd3ae1c C [report] KASAN: use-after-free Read in consume_skb
2024/08/09 upstream (ToT) ee9a43b7cfe2 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 29 18h17m 390d 0/2 upstream: reported C repro on 2023/09/21 02:29
android-6-1 KASAN: use-after-free Read in consume_skb C error done 4 343d 402d 0/2 auto-obsoleted due to no activity on 2024/02/15 15:09
upstream KASAN: use-after-free Read in consume_skb bpf net C done inconclusive 33 822d 1101d 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 405d 406d 0/28 closed as invalid on 2023/10/04 10:50
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2024/10/15 03:15 0m fix candidate upstream error job log
2024/10/14 23:15 0m bisect fix linux-5.15.y error job log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:71 [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:1107 [inline]
BUG: KASAN: use-after-free in consume_skb+0x35/0x140 net/core/skbuff.c:910
Read of size 4 at addr ffff888070ce30dc by task kworker/1:4/3568

CPU: 1 PID: 3568 Comm: kworker/1:4 Not tainted 5.15.164-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Workqueue: events sk_psock_destroy
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
 instrument_atomic_read include/linux/instrumented.h:71 [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:1107 [inline]
 consume_skb+0x35/0x140 net/core/skbuff.c:910
 __sk_msg_free+0x2cd/0x350 net/core/skmsg.c:205
 sk_msg_free net/core/skmsg.c:218 [inline]
 __sk_psock_purge_ingress_msg net/core/skmsg.c:764 [inline]
 __sk_psock_zap_ingress net/core/skmsg.c:777 [inline]
 sk_psock_destroy+0x3ab/0x870 net/core/skmsg.c:809
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Allocated by task 3567:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x8e/0xc0 mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
 skb_clone+0x1bb/0x350 net/core/skbuff.c:1523
 sk_psock_verdict_recv+0x51/0x5b0 net/core/skmsg.c:1176
 unix_read_sock+0x124/0x360 net/unix/af_unix.c:2428
 sk_psock_verdict_data_ready+0x147/0x1a0 net/core/skmsg.c:1219
 unix_dgram_sendmsg+0x15fc/0x2090 net/unix/af_unix.c:1942
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2431
 ___sys_sendmsg+0x252/0x2e0 net/socket.c:2485
 __sys_sendmsg net/socket.c:2514 [inline]
 __do_sys_sendmsg net/socket.c:2523 [inline]
 __se_sys_sendmsg+0x19a/0x260 net/socket.c:2521
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 3568:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kmem_cache_free+0x91/0x1f0 mm/slub.c:3515
 kfree_skb include/linux/skbuff.h:1123 [inline]
 sock_drop include/linux/skmsg.h:313 [inline]
 __sk_psock_zap_ingress net/core/skmsg.c:775 [inline]
 sk_psock_destroy+0x1a8/0x870 net/core/skmsg.c:809
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

The buggy address belongs to the object at ffff888070ce3000
 which belongs to the cache skbuff_head_cache of size 232
The buggy address is located 220 bytes inside of
 232-byte region [ffff888070ce3000, ffff888070ce30e8)
The buggy address belongs to the page:
page:ffffea0001c338c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x70ce3
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff888016be4140
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 3567, ts 52315128637, free_ts 52314155286
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5423
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x18e/0x280 mm/slub.c:3233
 skb_clone+0x1bb/0x350 net/core/skbuff.c:1523
 sk_psock_verdict_recv+0x51/0x5b0 net/core/skmsg.c:1176
 unix_read_sock+0x124/0x360 net/unix/af_unix.c:2428
 sk_psock_verdict_data_ready+0x147/0x1a0 net/core/skmsg.c:1219
 unix_dgram_sendmsg+0x15fc/0x2090 net/unix/af_unix.c:1942
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2431
 ___sys_sendmsg+0x252/0x2e0 net/socket.c:2485
 __sys_sendmsg net/socket.c:2514 [inline]
 __do_sys_sendmsg net/socket.c:2523 [inline]
 __se_sys_sendmsg+0x19a/0x260 net/socket.c:2521
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 __vunmap+0x8d4/0xa20 mm/vmalloc.c:2621
 adjust_insn_aux_data kernel/bpf/verifier.c:12050 [inline]
 bpf_patch_insn_data+0x828/0xe00 kernel/bpf/verifier.c:12103
 convert_ctx_accesses kernel/bpf/verifier.c:12645 [inline]
 bpf_check+0x5ffd/0x12d00 kernel/bpf/verifier.c:14142
 bpf_prog_load+0x12b3/0x1b60 kernel/bpf/syscall.c:2353
 __sys_bpf+0x343/0x670 kernel/bpf/syscall.c:4651
 __do_sys_bpf kernel/bpf/syscall.c:4755 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4753 [inline]
 __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4753
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
 ffff888070ce2f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888070ce3000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888070ce3080: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
                                                    ^
 ffff888070ce3100: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
 ffff888070ce3180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/09 10:12 linux-5.15.y 7e89efd3ae1c 61405512 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf KASAN: use-after-free Read in consume_skb
2024/08/30 00:21 linux-5.15.y fa93fa65db6e 9bd464fc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf KASAN: use-after-free Read in consume_skb
2024/08/09 08:32 linux-5.15.y 7e89efd3ae1c 61405512 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf KASAN: use-after-free Read in consume_skb
* Struck through repros no longer work on HEAD.