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

28 views
Skip to first unread message

syzbot

unread,
Mar 12, 2022, 9:46:18 AM3/12/22
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: e1b86e7f5cbb Merge branch 'android12-5.10' into `android12..
git tree: android12-5.10-lts
console output: https://syzkaller.appspot.com/x/log.txt?x=13e4aa41700000
kernel config: https://syzkaller.appspot.com/x/.config?x=35d59e0f6d92b6d1
dashboard link: https://syzkaller.appspot.com/bug?extid=a45f9db3596007552a19
compiler: Debian clang version 11.0.1-2, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1066649d700000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14714dad700000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+a45f9d...@syzkaller.appspotmail.com

==================================================================
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
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Tadeusz Struk

unread,
Mar 13, 2022, 11:47:47 AM3/13/22
to syzbot+a45f9d...@syzkaller.appspotmail.com, syzkaller
#syz fix: net/packet: fix slab-out-of-bounds access in packet_recvmsg()

Tadeusz Struk

unread,
Mar 17, 2022, 3:36:35 PM3/17/22
to syzbot+a45f9d...@syzkaller.appspotmail.com, syzkaller
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
tags/net-5.17-final

syzbot

unread,
Mar 17, 2022, 8:56:08 PM3/17/22
to syzkaller-a...@googlegroups.com, tadeus...@linaro.org
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to checkout kernel repo git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/tags/net-5.17-final: failed to run ["git" "fetch" "--force" "675adff2843877c2da27b36b2517f827bc9915ea" "tags/net-5.17-final"]: exit status 128
fatal: couldn't find remote ref tags/net-5.17-final



Tested on:

commit: [unknown
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git tags/net-5.17-final
Note: no patches were applied.

Tadeusz Struk

unread,
Mar 17, 2022, 9:38:52 PM3/17/22
to syzbot+a45f9d...@syzkaller.appspotmail.com, syzkaller

syzbot

unread,
Mar 18, 2022, 5:20:08 AM3/18/22
to syzkaller-a...@googlegroups.com, tadeus...@linaro.org
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+a45f9d...@syzkaller.appspotmail.com

Tested on:

commit: 551acdc3 Merge tag 'net-5.17-final' of git://git.kerne..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git master
kernel config: https://syzkaller.appspot.com/x/.config?x=8e2dda835f422d5b
dashboard link: https://syzkaller.appspot.com/bug?extid=a45f9db3596007552a19
compiler: Debian clang version 11.0.1-2, GNU ld (GNU Binutils for Debian) 2.35.2

Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.

Tadeusz Struk

unread,
Mar 21, 2022, 4:19:27 PM3/21/22
to syzbot+a45f9d...@syzkaller.appspotmail.com, syzkaller

syzbot

unread,
Mar 21, 2022, 4:42:13 PM3/21/22
to syzkaller-a...@googlegroups.com, tadeus...@linaro.org
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+a45f9d...@syzkaller.appspotmail.com

Tested on:

commit: a04b1bf5 Merge tag 'for-5.18/parisc-1' of git://git.ke..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
kernel config: https://syzkaller.appspot.com/x/.config?x=da48becc9958c093
Reply all
Reply to author
Forward
0 new messages