syzbot


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

Status: internal: reported C repro on 2022/03/30 17:01
Reported-by: syzbot+@syzkaller.appspotmail.com
Fix commit: 9d570741aec1 vxlan: do not feed vxlan_vnifilter_dump_dev with non vxlan devices
Patched on: [ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm32 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-leak ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-kmsan-gce ci-upstream-kmsan-gce-386 ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-kcsan-gce ci2-upstream-usb], missing on: [ci-qemu2-riscv64]
First crash: 90d, last: 89d

Cause bisection: introduced by (bisect log) :
commit f9c4bb0b245cee35ef66f75bf409c9573d934cf9
Author: Roopa Prabhu <roopa@nvidia.com>
Date: Tue Mar 1 05:04:36 2022 +0000

  vxlan: vni filtering support on collect metadata device

Crash: KASAN: use-after-free Read in vxlan_vnifilter_dump_dev (log)
Repro: C syz .config

Sample crash report:
netdevsim netdevsim0 netdevsim1: set [1, 0] type 2 family 0 port 6081 - 0
netdevsim netdevsim0 netdevsim2: set [1, 0] type 2 family 0 port 6081 - 0
netdevsim netdevsim0 netdevsim3: set [1, 0] type 2 family 0 port 6081 - 0
==================================================================
BUG: KASAN: slab-out-of-bounds in vxlan_vnifilter_dump_dev+0x9a0/0xb40 drivers/net/vxlan/vxlan_vnifilter.c:349
Read of size 4 at addr ffff88801f1e0e70 by task syz-executor720/3590

CPU: 0 PID: 3590 Comm: syz-executor720 Tainted: G        W         5.17.0-syzkaller-13034-gd888c83fcec7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 vxlan_vnifilter_dump_dev+0x9a0/0xb40 drivers/net/vxlan/vxlan_vnifilter.c:349
 vxlan_vnifilter_dump+0x3ff/0x650 drivers/net/vxlan/vxlan_vnifilter.c:428
 netlink_dump+0x4b5/0xb70 net/netlink/af_netlink.c:2270
 __netlink_dump_start+0x647/0x900 net/netlink/af_netlink.c:2375
 netlink_dump_start include/linux/netlink.h:245 [inline]
 rtnetlink_rcv_msg+0x70c/0xb80 net/core/rtnetlink.c:5953
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2496
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1921
 sock_sendmsg_nosec net/socket.c:705 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:725
 ____sys_sendmsg+0x6e2/0x800 net/socket.c:2413
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2467
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2496
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0x80 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f4bbf2e5049
Code: 9d 01 00 85 c0 b8 00 00 00 00 48 0f 44 c3 5b c3 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:00007f4bbf471f38 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f4bbf2e5049
RDX: 0000000000000000 RSI: 00000000200003c0 RDI: 0000000000000004
RBP: 00007f4bbf471f70 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f4bbf471f70
R13: 00007f4bbf471f50 R14: 0000000000000001 R15: 00007ffde15e068a
 </TASK>

Allocated by task 1:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 __kasan_slab_alloc+0x90/0xc0 mm/kasan/common.c:469
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:749 [inline]
 slab_alloc_node mm/slub.c:3217 [inline]
 slab_alloc mm/slub.c:3225 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3232 [inline]
 kmem_cache_alloc+0x204/0x3b0 mm/slub.c:3242
 kmem_cache_zalloc include/linux/slab.h:704 [inline]
 __kernfs_new_node+0xd4/0x8b0 fs/kernfs/dir.c:585
 kernfs_new_node+0x93/0x120 fs/kernfs/dir.c:647
 __kernfs_create_file+0x51/0x350 fs/kernfs/file.c:987
 sysfs_add_file_mode_ns+0x20f/0x3f0 fs/sysfs/file.c:294
 sysfs_create_file_ns+0x127/0x1c0 fs/sysfs/file.c:355
 sysfs_create_file include/linux/sysfs.h:607 [inline]
 driver_create_file+0x48/0x70 drivers/base/driver.c:107
 bus_add_driver+0x309/0x630 drivers/base/bus.c:624
 driver_register+0x220/0x3a0 drivers/base/driver.c:171
 do_one_initcall+0x103/0x650 init/main.c:1298
 do_initcall_level init/main.c:1371 [inline]
 do_initcalls init/main.c:1387 [inline]
 do_basic_setup init/main.c:1406 [inline]
 kernel_init_freeable+0x6b1/0x73a init/main.c:1613
 kernel_init+0x1a/0x1d0 init/main.c:1502
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

The buggy address belongs to the object at ffff88801f1e0d98
 which belongs to the cache kernfs_node_cache of size 168
The buggy address is located 48 bytes to the right of
 168-byte region [ffff88801f1e0d98, ffff88801f1e0e40)

The buggy address belongs to the physical page:
page:ffffea00007c7800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1f1e0
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff888010dccb40
raw: 0000000000000000 0000000000110011 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, tgid 1 (swapper/0), ts 8639632616, free_ts 8638600022
 prep_new_page mm/page_alloc.c:2438 [inline]
 get_page_from_freelist+0xba2/0x3df0 mm/page_alloc.c:4179
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5405
 alloc_page_interleave+0x1e/0x200 mm/mempolicy.c:2107
 alloc_pages+0x2b1/0x310 mm/mempolicy.c:2257
 alloc_slab_page mm/slub.c:1799 [inline]
 allocate_slab+0x26c/0x3c0 mm/slub.c:1944
 new_slab mm/slub.c:2004 [inline]
 ___slab_alloc+0x8df/0xf20 mm/slub.c:3005
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3092
 slab_alloc_node mm/slub.c:3183 [inline]
 slab_alloc mm/slub.c:3225 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3232 [inline]
 kmem_cache_alloc+0x360/0x3b0 mm/slub.c:3242
 kmem_cache_zalloc include/linux/slab.h:704 [inline]
 __kernfs_new_node+0xd4/0x8b0 fs/kernfs/dir.c:585
 kernfs_new_node+0x93/0x120 fs/kernfs/dir.c:647
 __kernfs_create_file+0x51/0x350 fs/kernfs/file.c:987
 sysfs_add_file_mode_ns+0x20f/0x3f0 fs/sysfs/file.c:294
 sysfs_create_file_ns+0x127/0x1c0 fs/sysfs/file.c:355
 sysfs_create_file include/linux/sysfs.h:607 [inline]
 driver_create_file+0x48/0x70 drivers/base/driver.c:107
 usb_create_newid_files drivers/usb/core/driver.c:192 [inline]
 usb_register_driver+0x380/0x460 drivers/usb/core/driver.c:1066
 do_one_initcall+0x103/0x650 init/main.c:1298
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1353 [inline]
 free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1403
 free_unref_page_prepare mm/page_alloc.c:3325 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3420
 mm_free_pgd kernel/fork.c:739 [inline]
 __mmdrop+0xcb/0x3f0 kernel/fork.c:790
 mmdrop include/linux/sched/mm.h:50 [inline]
 __mmput+0x3f1/0x4b0 kernel/fork.c:1194
 mmput+0x56/0x60 kernel/fork.c:1205
 free_bprm+0x65/0x2e0 fs/exec.c:1484
 kernel_execve+0x3a4/0x490 fs/exec.c:1999
 call_usermodehelper_exec_async+0x2e3/0x580 kernel/umh.c:112
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Memory state around the buggy address:
 ffff88801f1e0d00: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc
 ffff88801f1e0d80: fc fc fc 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88801f1e0e00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
                                                             ^
 ffff88801f1e0e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88801f1e0f00: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (30):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2022/03/30 20:26 upstream d888c83fcec7 42718dd6 .config log report syz C KASAN: slab-out-of-bounds Read in vxlan_vnifilter_dump_dev
ci-upstream-kasan-gce 2022/03/30 17:35 upstream d888c83fcec7 42718dd6 .config log report syz C KASAN: slab-out-of-bounds Read in vxlan_vnifilter_dump_dev
ci-upstream-net-kasan-gce 2022/03/30 17:32 net-next d717e4cae0fe 42718dd6 .config log report syz C KASAN: slab-out-of-bounds Read in vxlan_vnifilter_dump_dev
ci-upstream-kasan-gce 2022/03/30 21:21 upstream d888c83fcec7 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-kasan-gce 2022/03/30 21:02 upstream d888c83fcec7 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-kasan-gce-selinux-root 2022/03/30 17:30 upstream d888c83fcec7 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-kasan-gce-root 2022/03/30 17:27 upstream d888c83fcec7 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-kasan-gce-386 2022/03/30 21:49 upstream d888c83fcec7 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-this-kasan-gce 2022/03/30 18:57 net 77c9387c0c5b 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-this-kasan-gce 2022/03/30 18:40 net 77c9387c0c5b 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-this-kasan-gce 2022/03/30 18:18 net 77c9387c0c5b 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-this-kasan-gce 2022/03/30 17:57 net 77c9387c0c5b 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-this-kasan-gce 2022/03/30 17:26 net 77c9387c0c5b 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-kasan-gce 2022/03/30 20:34 net-next d717e4cae0fe 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-kasan-gce 2022/03/30 20:16 net-next d717e4cae0fe 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-kasan-gce 2022/03/30 19:52 net-next d717e4cae0fe 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-kasan-gce 2022/03/30 19:34 net-next d717e4cae0fe 42718dd6 .config log report syz C KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-qemu-upstream-386 2022/03/30 17:33 upstream d888c83fcec7 9d49f3a7 .config log report info KASAN: slab-out-of-bounds Read in vxlan_vnifilter_dump_dev
ci-upstream-net-this-kasan-gce 2022/03/30 17:00 net 77c9387c0c5b 42718dd6 .config log report info KASAN: slab-out-of-bounds Read in vxlan_vnifilter_dump_dev
ci-qemu-upstream 2022/03/30 22:36 upstream 74164d284b29 9d49f3a7 .config log report info general protection fault in vxlan_vnifilter_dump_dev
ci-qemu-upstream 2022/03/30 19:24 upstream 74164d284b29 9d49f3a7 .config log report info KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-kasan-gce 2022/03/30 17:14 upstream d888c83fcec7 42718dd6 .config log report info KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-kasan-gce-selinux-root 2022/03/30 17:12 upstream d888c83fcec7 42718dd6 .config log report info general protection fault in vxlan_vnifilter_dump_dev
ci-upstream-kasan-gce-root 2022/03/30 17:11 upstream d888c83fcec7 42718dd6 .config log report info KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-kasan-gce-386 2022/03/30 17:26 upstream d888c83fcec7 42718dd6 .config log report info KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-this-kasan-gce 2022/03/31 01:29 net c9ad266bbef5 9d49f3a7 .config log report info KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-this-kasan-gce 2022/03/30 23:50 net c9ad266bbef5 9d49f3a7 .config log report info KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-this-kasan-gce 2022/03/30 23:36 net c9ad266bbef5 42718dd6 .config log report info KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-net-kasan-gce 2022/03/30 17:14 net-next d717e4cae0fe 42718dd6 .config log report info KASAN: use-after-free Read in vxlan_vnifilter_dump_dev
ci-upstream-linux-next-kasan-gce-root 2022/03/31 14:23 linux-next fdcbcd1348f4 c4c32d8c .config log report info KASAN: use-after-free Read in vxlan_vnifilter_dump_dev