syzbot


linux-next boot error: KASAN: slab-out-of-bounds Read in page_to_skb

Status: fixed on 2021/11/10 00:50
Reported-by: syzbot+@syzkaller.appspotmail.com
Fix commit: af39c8f72301 virtio-net: fix use-after-free in page_to_skb()
First crash: 658d, last: 656d

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in memcpy include/linux/fortify-string.h:191 [inline]
BUG: KASAN: slab-out-of-bounds in page_to_skb+0x5cf/0xb70 drivers/net/virtio_net.c:480
Read of size 12 at addr ffff8880151e7800 by task systemd-udevd/6419

CPU: 0 PID: 6419 Comm: systemd-udevd Not tainted 5.12.0-rc8-next-20210420-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x141/0x1d7 lib/dump_stack.c:120
 print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:233
 __kasan_report mm/kasan/report.c:419 [inline]
 kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:436
 check_region_inline mm/kasan/generic.c:180 [inline]
 kasan_check_range+0x13d/0x180 mm/kasan/generic.c:186
 memcpy+0x20/0x60 mm/kasan/shadow.c:65
 memcpy include/linux/fortify-string.h:191 [inline]
 page_to_skb+0x5cf/0xb70 drivers/net/virtio_net.c:480
 receive_mergeable drivers/net/virtio_net.c:1009 [inline]
 receive_buf+0x2bc0/0x6250 drivers/net/virtio_net.c:1119
 virtnet_receive drivers/net/virtio_net.c:1411 [inline]
 virtnet_poll+0x568/0x10b0 drivers/net/virtio_net.c:1516
 __napi_poll+0xaf/0x440 net/core/dev.c:6962
 napi_poll net/core/dev.c:7029 [inline]
 net_rx_action+0x801/0xb40 net/core/dev.c:7116
 __do_softirq+0x29b/0x9fe kernel/softirq.c:559
 invoke_softirq kernel/softirq.c:433 [inline]
 __irq_exit_rcu+0x136/0x200 kernel/softirq.c:637
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:649
 common_interrupt+0xa4/0xd0 arch/x86/kernel/irq.c:240
 </IRQ>
 asm_common_interrupt+0x1e/0x40 arch/x86/include/asm/idtentry.h:623
RIP: 0010:unwind_get_return_address arch/x86/kernel/unwind_orc.c:318 [inline]
RIP: 0010:unwind_get_return_address+0x46/0x90 arch/x86/kernel/unwind_orc.c:313
Code: 74 04 3c 03 7e 51 8b 03 85 c0 75 05 5b 31 c0 5d c3 48 8d 6b 48 48 b8 00 00 00 00 00 fc ff df 48 89 ea 48 c1 ea 03 80 3c 02 00 <75> 32 48 8b 7b 48 e8 9f 45 19 00 85 c0 74 d3 48 b8 00 00 00 00 00
RSP: 0018:ffffc900056375a0 EFLAGS: 00000246
RAX: dffffc0000000000 RBX: ffffc900056375b8 RCX: 0000000000000000
RDX: 1ffff92000ac6ec0 RSI: ffffc90005637ef0 RDI: ffffc900056375b8
RBP: ffffc90005637600 R08: ffffffff8e4d45e0 R09: 0000000000000001
R10: fffff52000ac6ec2 R11: 0000000000084087 R12: ffffc90005637670
R13: 0000000000000000 R14: ffff888012fe1c80 R15: 0000000000000000
 arch_stack_walk+0x93/0xe0 arch/x86/kernel/stacktrace.c:26
 stack_trace_save+0x8c/0xc0 kernel/stacktrace.c:121
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:357
 ____kasan_slab_free mm/kasan/common.c:360 [inline]
 ____kasan_slab_free mm/kasan/common.c:325 [inline]
 __kasan_slab_free+0xfb/0x130 mm/kasan/common.c:368
 kasan_slab_free include/linux/kasan.h:212 [inline]
 slab_free_hook mm/slub.c:1593 [inline]
 slab_free_freelist_hook+0xdf/0x240 mm/slub.c:1618
 slab_free mm/slub.c:3178 [inline]
 kfree+0xe5/0x7f0 mm/slub.c:4245
 tomoyo_path2_perm+0x28a/0x6b0 security/tomoyo/file.c:946
 tomoyo_path_rename+0xd2/0x130 security/tomoyo/tomoyo.c:279
 security_path_rename+0x1b5/0x2e0 security/security.c:1189
 do_renameat2+0x96f/0xcb0 fs/namei.c:4683
 __do_sys_rename fs/namei.c:4745 [inline]
 __se_sys_rename fs/namei.c:4743 [inline]
 __x64_sys_rename+0x7d/0xa0 fs/namei.c:4743
 do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fd8527abd47
Code: 75 12 48 89 df e8 19 84 07 00 85 c0 0f 95 c0 0f b6 c0 f7 d8 5b c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 b8 52 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 21 41 33 00 f7 d8 64 89 01 48
RSP: 002b:00007fff322cc928 EFLAGS: 00000246 ORIG_RAX: 0000000000000052
RAX: ffffffffffffffda RBX: 000055f5105f8940 RCX: 00007fd8527abd47
RDX: 0000000000000000 RSI: 00007fff322cc930 RDI: 000055f5105fe560
RBP: 00007fff322cc9f0 R08: 000055f5105fbbb0 R09: 000055f5105fbad0
R10: 00007fd8539b08c0 R11: 0000000000000246 R12: 00007fff322cc930
R13: 0000000000000001 R14: 000055f50edfb6cb R15: 0000000000000000

Allocated by task 1:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:428 [inline]
 ____kasan_kmalloc mm/kasan/common.c:507 [inline]
 ____kasan_kmalloc mm/kasan/common.c:466 [inline]
 __kasan_kmalloc+0x9b/0xd0 mm/kasan/common.c:516
 kmalloc include/linux/slab.h:563 [inline]
 tomoyo_realpath_from_path+0xc3/0x620 security/tomoyo/realpath.c:254
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x21b/0x400 security/tomoyo/file.c:822
 security_inode_getattr+0xcf/0x140 security/security.c:1332
 vfs_getattr fs/stat.c:139 [inline]
 vfs_statx+0x164/0x390 fs/stat.c:207
 vfs_fstatat fs/stat.c:225 [inline]
 vfs_lstat include/linux/fs.h:3384 [inline]
 __do_sys_newlstat+0x91/0x110 fs/stat.c:380
 do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 1:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:357
 ____kasan_slab_free mm/kasan/common.c:360 [inline]
 ____kasan_slab_free mm/kasan/common.c:325 [inline]
 __kasan_slab_free+0xfb/0x130 mm/kasan/common.c:368
 kasan_slab_free include/linux/kasan.h:212 [inline]
 slab_free_hook mm/slub.c:1593 [inline]
 slab_free_freelist_hook+0xdf/0x240 mm/slub.c:1618
 slab_free mm/slub.c:3178 [inline]
 kfree+0xe5/0x7f0 mm/slub.c:4245
 tomoyo_realpath_from_path+0x191/0x620 security/tomoyo/realpath.c:291
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x21b/0x400 security/tomoyo/file.c:822
 security_inode_getattr+0xcf/0x140 security/security.c:1332
 vfs_getattr fs/stat.c:139 [inline]
 vfs_statx+0x164/0x390 fs/stat.c:207
 vfs_fstatat fs/stat.c:225 [inline]
 vfs_lstat include/linux/fs.h:3384 [inline]
 __do_sys_newlstat+0x91/0x110 fs/stat.c:380
 do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff8880151e6000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 2048 bytes to the right of
 4096-byte region [ffff8880151e6000, ffff8880151e7000)
The buggy address belongs to the page:
page:ffffea0000547800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x151e0
head:ffffea0000547800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888011042140
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880151e7700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880151e7780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880151e7800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                   ^
 ffff8880151e7880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880151e7900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (5):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci-upstream-linux-next-kasan-gce-root 2021/04/21 08:15 linux-next 593ef1658ecf 95777977 .config console log report linux-next boot error: KASAN: slab-out-of-bounds Read in page_to_skb
ci-upstream-linux-next-kasan-gce-root 2021/04/20 10:57 linux-next 593ef1658ecf c0ced557 .config console log report linux-next boot error: KASAN: slab-out-of-bounds Read in page_to_skb
ci-upstream-linux-next-kasan-gce-root 2021/04/20 10:08 linux-next 593ef1658ecf 4285c989 .config console log report linux-next boot error: KASAN: slab-out-of-bounds Read in page_to_skb
ci-upstream-linux-next-kasan-gce-root 2021/04/20 10:08 linux-next 593ef1658ecf 4285c989 .config console log report linux-next boot error: KASAN: slab-out-of-bounds Read in page_to_skb
ci-upstream-linux-next-kasan-gce-root 2021/04/19 22:36 linux-next 50b8b1d699ac 4285c989 .config console log report linux-next boot error: KASAN: slab-out-of-bounds Read in page_to_skb
* Struck through repros no longer work on HEAD.