syzbot


KASAN: slab-out-of-bounds Read in packet_recvmsg

Status: fixed on 2022/03/23 23:19
Reported-by: syzbot+a45f9db3596007552a19@syzkaller.appspotmail.com
Fix commit: 70b7b3c055fd net/packet: fix slab-out-of-bounds access in packet_recvmsg()
First crash: 808d, last: 808d
Cause bisection: failed (error log, bisect log)
  
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-out-of-bounds Read in packet_recvmsg net C inconclusive 12 808d 1210d 22/26 fixed on 2023/02/24 13:50
Last patch testing requests (3)
Created Duration User Patch Repo Result
2022/03/21 20:19 14m tadeusz.struk@linaro.org git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master OK
2022/03/18 01:38 10m tadeusz.struk@linaro.org git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git master OK
2022/03/17 19:36 0m tadeusz.struk@linaro.org git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git tags/net-5.17-final error OK

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in packet_recvmsg+0xb5b/0x1930 net/packet/af_packet.c:3459
Read of size 241 at addr ffff88811e36c668 by task syz-executor270/420

CPU: 1 PID: 420 Comm: syz-executor270 Not tainted 5.10.102-syzkaller-00171-ge1b86e7f5cbb #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233
 __kasan_report+0x142/0x220 mm/kasan/report.c:419
 kasan_report+0x51/0x70 mm/kasan/report.c:436
 check_region_inline mm/kasan/generic.c:135 [inline]
 kasan_check_range+0x2b6/0x2f0 mm/kasan/generic.c:186
 memcpy+0x2d/0x70 mm/kasan/shadow.c:65
 packet_recvmsg+0xb5b/0x1930 net/packet/af_packet.c:3459
 sock_recvmsg_nosec net/socket.c:886 [inline]
 sock_recvmsg net/socket.c:904 [inline]
 ____sys_recvmsg+0x2b0/0x5e0 net/socket.c:2566
 ___sys_recvmsg net/socket.c:2608 [inline]
 __sys_recvmsg+0x310/0x850 net/socket.c:2644
 __do_sys_recvmsg net/socket.c:2654 [inline]
 __se_sys_recvmsg net/socket.c:2651 [inline]
 __x64_sys_recvmsg+0x7f/0x90 net/socket.c:2651
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f3df847ec29
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 41 15 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffee9c7f798 EFLAGS: 00000246 ORIG_RAX: 000000000000002f
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f3df847ec29
RDX: 0000000000000000 RSI: 0000000020000500 RDI: 0000000000000005
RBP: 0000000000000000 R08: 000000000000000d R09: 000000000000000d
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffee9c7f7b0
R13: 00000000000f4240 R14: 00000000000051a6 R15: 00007ffee9c7f7a4

Allocated by task 108:
 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:428 [inline]
 __kasan_slab_alloc+0xb2/0xe0 mm/kasan/common.c:461
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:583 [inline]
 slab_alloc_node mm/slub.c:2954 [inline]
 slab_alloc mm/slub.c:2962 [inline]
 kmem_cache_alloc+0x1a2/0x380 mm/slub.c:2967
 skb_clone+0x1cc/0x370 net/core/skbuff.c:1459
 dev_queue_xmit_nit+0x27a/0xa80 net/core/dev.c:2350
 xmit_one+0x88/0x480 net/core/dev.c:3584
 dev_hard_start_xmit+0xad/0x1c0 net/core/dev.c:3605
 sch_direct_xmit+0x28f/0x9b0 net/sched/sch_generic.c:336
 qdisc_restart net/sched/sch_generic.c:401 [inline]
 __qdisc_run+0x245/0x3e0 net/sched/sch_generic.c:409
 qdisc_run include/net/pkt_sched.h:127 [inline]
 net_tx_action+0x6d2/0x9e0 net/core/dev.c:4962
 __do_softirq+0x27e/0x598 kernel/softirq.c:305

The buggy address belongs to the object at ffff88811e36c640
 which belongs to the cache skbuff_head_cache of size 240
The buggy address is located 40 bytes inside of
 240-byte region [ffff88811e36c640, ffff88811e36c730)
The buggy address belongs to the page:
page:ffffea000478db00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11e36c
flags: 0x8000000000000200(slab)
raw: 8000000000000200 dead000000000100 dead000000000122 ffff888107fe8f00
raw: 0000000000000000 00000000800c000c 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 108, ts 21048417509, free_ts 20918564837
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2385 [inline]
 prep_new_page mm/page_alloc.c:2391 [inline]
 get_page_from_freelist+0xa74/0xa90 mm/page_alloc.c:4063
 __alloc_pages_nodemask+0x3c8/0x820 mm/page_alloc.c:5107
 alloc_slab_page mm/slub.c:1813 [inline]
 allocate_slab+0x6b/0x350 mm/slub.c:1815
 new_slab mm/slub.c:1876 [inline]
 new_slab_objects mm/slub.c:2635 [inline]
 ___slab_alloc+0x143/0x2f0 mm/slub.c:2798
 __slab_alloc mm/slub.c:2838 [inline]
 slab_alloc_node mm/slub.c:2920 [inline]
 slab_alloc mm/slub.c:2962 [inline]
 kmem_cache_alloc+0x26f/0x380 mm/slub.c:2967
 skb_clone+0x1cc/0x370 net/core/skbuff.c:1459
 dev_queue_xmit_nit+0x27a/0xa80 net/core/dev.c:2350
 xmit_one+0x88/0x480 net/core/dev.c:3584
 dev_hard_start_xmit+0xad/0x1c0 net/core/dev.c:3605
 sch_direct_xmit+0x28f/0x9b0 net/sched/sch_generic.c:336
 qdisc_restart net/sched/sch_generic.c:401 [inline]
 __qdisc_run+0x245/0x3e0 net/sched/sch_generic.c:409
 qdisc_run include/net/pkt_sched.h:127 [inline]
 net_tx_action+0x6d2/0x9e0 net/core/dev.c:4962
 __do_softirq+0x27e/0x598 kernel/softirq.c:305
 asm_call_irq_on_stack+0xf/0x20
 __run_on_irqstack arch/x86/include/asm/irq_stack.h:26 [inline]
 run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:77 [inline]
 do_softirq_own_stack+0x60/0x80 arch/x86/kernel/irq_64.c:77
 invoke_softirq kernel/softirq.c:402 [inline]
 __irq_exit_rcu+0x128/0x150 kernel/softirq.c:432
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1331 [inline]
 __free_pages_ok+0xbe7/0xc20 mm/page_alloc.c:1611
 free_the_page mm/page_alloc.c:5168 [inline]
 __free_pages+0x2d6/0x4a0 mm/page_alloc.c:5174
 free_pages+0x7c/0x90 mm/page_alloc.c:5185
 free_pg_vec net/packet/af_packet.c:4253 [inline]
 packet_set_ring+0x18d1/0x2610 net/packet/af_packet.c:4472
 packet_release+0x781/0xd00 net/packet/af_packet.c:3091
 __sock_release net/socket.c:597 [inline]
 sock_close+0xdb/0x260 net/socket.c:1267
 __fput+0x348/0x7d0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x147/0x1b0 kernel/task_work.c:154
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:164 [inline]
 exit_to_user_mode_prepare+0xc3/0xe0 kernel/entry/common.c:191
 syscall_exit_to_user_mode+0x24/0x40 kernel/entry/common.c:266
 do_syscall_64+0x3d/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Memory state around the buggy address:
 ffff88811e36c600: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
 ffff88811e36c680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88811e36c700: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
                                     ^
 ffff88811e36c780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88811e36c800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/03/12 14:45 android12-5.10-lts e1b86e7f5cbb 9e8eaa75 .config console log report syz C ci2-android-5-10 KASAN: slab-out-of-bounds Read in packet_recvmsg
* Struck through repros no longer work on HEAD.