================================================================== BUG: KASAN: slab-use-after-free in snapshot_ctr+0x1c20/0x1fd0 drivers/md/dm-snap.c:1284 Read of size 8 at addr ffff88802a1e7098 by task syz.3.72/6284 CPU: 2 UID: 0 PID: 6284 Comm: syz.3.72 Tainted: G L syzkaller #0 PREEMPT(full) Tainted: [L]=SOFTLOCKUP Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0x13d/0x4b0 mm/kasan/report.c:482 kasan_report+0xdf/0x1c0 mm/kasan/report.c:595 snapshot_ctr+0x1c20/0x1fd0 drivers/md/dm-snap.c:1284 dm_table_add_target+0x58b/0xee0 drivers/md/dm-table.c:749 populate_table drivers/md/dm-ioctl.c:1602 [inline] table_load+0x3b9/0x7b0 drivers/md/dm-ioctl.c:1645 ctl_ioctl+0x4d2/0xcc0 drivers/md/dm-ioctl.c:2221 dm_ctl_ioctl drivers/md/dm-ioctl.c:2243 [inline] dm_compat_ctl_ioctl+0x23/0x30 drivers/md/dm-ioctl.c:2249 __do_compat_sys_ioctl fs/ioctl.c:695 [inline] __se_compat_sys_ioctl fs/ioctl.c:638 [inline] __ia32_compat_sys_ioctl+0x2cf/0x360 fs/ioctl.c:638 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x14b/0x8c0 arch/x86/entry/syscall_32.c:282 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:307 entry_SYSENTER_compat_after_hwframe+0x84/0x8e RIP: 0023:0xf73aefbc Code: d2 74 05 c1 e8 0c 89 02 8b 5d fc 31 c0 c9 c3 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 2e 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00 58 b8 RSP: 002b:00000000f538450c EFLAGS: 00000292 ORIG_RAX: 0000000000000036 RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 00000000c138fd09 RDX: 00000000800015c0 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000292 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 6284: kasan_save_stack+0x30/0x50 mm/kasan/common.c:57 kasan_save_track+0x14/0x30 mm/kasan/common.c:78 poison_kmalloc_redzone mm/kasan/common.c:409 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:426 kasan_kmalloc include/linux/kasan.h:263 [inline] __kmalloc_cache_node_noprof+0x30c/0x710 mm/slub.c:5699 _kmalloc_node_noprof include/linux/slab.h:1196 [inline] open_table_device drivers/md/dm.c:733 [inline] dm_get_table_device+0x2fc/0x820 drivers/md/dm.c:821 dm_get_device+0x525/0x7e0 drivers/md/dm-table.c:388 snapshot_ctr+0x201/0x1fd0 drivers/md/dm-snap.c:1269 dm_table_add_target+0x58b/0xee0 drivers/md/dm-table.c:749 populate_table drivers/md/dm-ioctl.c:1602 [inline] table_load+0x3b9/0x7b0 drivers/md/dm-ioctl.c:1645 ctl_ioctl+0x4d2/0xcc0 drivers/md/dm-ioctl.c:2221 dm_ctl_ioctl drivers/md/dm-ioctl.c:2243 [inline] dm_compat_ctl_ioctl+0x23/0x30 drivers/md/dm-ioctl.c:2249 __do_compat_sys_ioctl fs/ioctl.c:695 [inline] __se_compat_sys_ioctl fs/ioctl.c:638 [inline] __ia32_compat_sys_ioctl+0x2cf/0x360 fs/ioctl.c:638 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x14b/0x8c0 arch/x86/entry/syscall_32.c:282 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:307 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Freed by task 6284: kasan_save_stack+0x30/0x50 mm/kasan/common.c:57 kasan_save_track+0x14/0x30 mm/kasan/common.c:78 kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584 poison_slab_object mm/kasan/common.c:264 [inline] __kasan_slab_free+0x5f/0x80 mm/kasan/common.c:296 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:2780 [inline] slab_free mm/slub.c:6630 [inline] kfree+0x22b/0x6d0 mm/slub.c:6923 close_table_device drivers/md/dm.c:798 [inline] dm_put_table_device+0x2bf/0x380 drivers/md/dm.c:841 upgrade_mode drivers/md/dm-table.c:326 [inline] dm_get_device+0x3f1/0x7e0 drivers/md/dm-table.c:399 snapshot_ctr+0x326/0x1fd0 drivers/md/dm-snap.c:1279 dm_table_add_target+0x58b/0xee0 drivers/md/dm-table.c:749 populate_table drivers/md/dm-ioctl.c:1602 [inline] table_load+0x3b9/0x7b0 drivers/md/dm-ioctl.c:1645 ctl_ioctl+0x4d2/0xcc0 drivers/md/dm-ioctl.c:2221 dm_ctl_ioctl drivers/md/dm-ioctl.c:2243 [inline] dm_compat_ctl_ioctl+0x23/0x30 drivers/md/dm-ioctl.c:2249 __do_compat_sys_ioctl fs/ioctl.c:695 [inline] __se_compat_sys_ioctl fs/ioctl.c:638 [inline] __ia32_compat_sys_ioctl+0x2cf/0x360 fs/ioctl.c:638 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline] __do_fast_syscall_32+0x14b/0x8c0 arch/x86/entry/syscall_32.c:282 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:307 entry_SYSENTER_compat_after_hwframe+0x84/0x8e The buggy address belongs to the object at ffff88802a1e7080 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 24 bytes inside of freed 96-byte region [ffff88802a1e7080, ffff88802a1e70e0) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2a1e7 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000000 ffff88801d442280 dead000000000100 dead000000000122 raw: 0000000000000000 0000000000200020 00000000f5000000 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 0x252800(GFP_NOWAIT|__GFP_NORETRY|__GFP_COMP|__GFP_THISNODE), pid 6089, tgid 6088 (syz.3.25), ts 50725962018 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1854 prep_new_page mm/page_alloc.c:1862 [inline] get_page_from_freelist+0x1113/0x35e0 mm/page_alloc.c:3933 __alloc_pages_slowpath mm/page_alloc.c:4874 [inline] __alloc_frozen_pages_noprof+0x7d5/0x3190 mm/page_alloc.c:5442 alloc_slab_page mm/slub.c:3384 [inline] allocate_slab mm/slub.c:3499 [inline] new_slab+0xb1/0x6d0 mm/slub.c:3550 ___slab_alloc+0x5d1/0x810 mm/slub.c:4605 slab_alloc_node mm/slub.c:5024 [inline] __kmalloc_cache_node_noprof+0x3a9/0x710 mm/slub.c:5695 _kmalloc_node_noprof include/linux/slab.h:1196 [inline] alloc_flush_pnodes kernel/workqueue.c:5275 [inline] __alloc_workqueue+0x7b9/0x1900 kernel/workqueue.c:6189 alloc_workqueue_va kernel/workqueue.c:6253 [inline] alloc_workqueue_noprof+0xc7/0x130 kernel/workqueue.c:6269 wg_newlink+0x207/0x7a0 drivers/net/wireguard/device.c:335 rtnl_newlink_create net/core/rtnetlink.c:4006 [inline] __rtnl_newlink net/core/rtnetlink.c:4135 [inline] rtnl_newlink+0x1697/0x2620 net/core/rtnetlink.c:4252 rtnetlink_rcv_msg+0x95e/0xe90 net/core/rtnetlink.c:7169 netlink_rcv_skb+0x159/0x420 net/netlink/af_netlink.c:2576 netlink_unicast_kernel net/netlink/af_netlink.c:1335 [inline] netlink_unicast+0x668/0x950 net/netlink/af_netlink.c:1361 netlink_sendmsg+0x9ac/0x10c0 net/netlink/af_netlink.c:1920 sock_sendmsg_nosec net/socket.c:800 [inline] __sock_sendmsg net/socket.c:818 [inline] ____sys_sendmsg+0xa99/0xc30 net/socket.c:2715 ___sys_sendmsg+0x190/0x1e0 net/socket.c:2769 page last free pid 23 tgid 23 ts 48132071475 stack trace: reset_page_owner include/linux/page_owner.h:26 [inline] __free_pages_prepare mm/page_alloc.c:1401 [inline] __free_frozen_pages+0x7b4/0x1110 mm/page_alloc.c:2952 __pagetable_free include/linux/mm.h:3793 [inline] pagetable_free include/linux/mm.h:3817 [inline] pagetable_dtor_free include/linux/mm.h:3916 [inline] __tlb_remove_table include/asm-generic/tlb.h:205 [inline] __tlb_remove_table_free mm/mmu_gather.c:226 [inline] tlb_remove_table_rcu+0x2cf/0x380 mm/mmu_gather.c:287 rcu_do_batch kernel/rcu/tree.c:2650 [inline] rcu_core+0x5f0/0x1220 kernel/rcu/tree.c:2919 handle_softirqs+0x216/0xa20 kernel/softirq.c:669 run_ksoftirqd kernel/softirq.c:1133 [inline] run_ksoftirqd+0x38/0x60 kernel/softirq.c:1125 smpboot_thread_fn+0x41f/0xb90 kernel/smpboot.c:162 kthread+0x373/0x450 kernel/kthread.c:436 ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 Memory state around the buggy address: ffff88802a1e6f80: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ffff88802a1e7000: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc >ffff88802a1e7080: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff88802a1e7100: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff88802a1e7180: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ================================================================== ---------------- Code disassembly (best guess): 0: d2 74 05 c1 shlb %cl,-0x3f(%rbp,%rax,1) 4: e8 0c 89 02 8b call 0x8b028915 9: 5d pop %rbp a: fc cld b: 31 c0 xor %eax,%eax d: c9 leave e: c3 ret f: 90 nop 10: 90 nop 11: 90 nop 12: 90 nop 13: 90 nop 14: 90 nop 15: 90 nop 16: 90 nop 17: 90 nop 18: 90 nop 19: 90 nop 1a: 90 nop 1b: 90 nop 1c: 90 nop 1d: 90 nop 1e: 0f 1f 00 nopl (%rax) 21: 51 push %rcx 22: 52 push %rdx 23: 55 push %rbp 24: 89 e5 mov %esp,%ebp 26: 0f 34 sysenter 28: cd 80 int $0x80 * 2a: 5d pop %rbp <-- trapping instruction 2b: 5a pop %rdx 2c: 59 pop %rcx 2d: c3 ret 2e: 90 nop 2f: 2e 8d b4 26 00 00 00 cs lea 0x0(%rsi,%riz,1),%esi 36: 00 37: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi 3e: 58 pop %rax 3f: b8 .byte 0xb8