================================================================== BUG: KASAN: use-after-free in get_disk_and_module block/genhd.c:1787 [inline] BUG: KASAN: use-after-free in exact_lock+0x38/0xd0 block/genhd.c:677 Read of size 8 at addr ffff8881009b5460 by task syz.0.5967/24080 CPU: 1 PID: 24080 Comm: syz.0.5967 Tainted: G W 5.10.234-syzkaller-00023-g3f5f2283d684 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118 print_address_description+0x81/0x3b0 mm/kasan/report.c:248 __kasan_report mm/kasan/report.c:435 [inline] kasan_report+0x179/0x1c0 mm/kasan/report.c:452 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309 get_disk_and_module block/genhd.c:1787 [inline] exact_lock+0x38/0xd0 block/genhd.c:677 kobj_lookup+0x294/0x430 drivers/base/map.c:119 get_gendisk+0xf7/0x3d0 block/genhd.c:1001 bdev_get_gendisk fs/block_dev.c:1110 [inline] __blkdev_get+0x18c/0x12f0 fs/block_dev.c:1474 blkdev_get fs/block_dev.c:1653 [inline] blkdev_get_by_path+0x25a/0x480 fs/block_dev.c:1690 mount_bdev+0x51/0x370 fs/super.c:1400 f2fs_mount+0x34/0x40 fs/f2fs/super.c:4548 legacy_get_tree+0xf1/0x190 fs/fs_context.c:593 vfs_get_tree+0x88/0x290 fs/super.c:1572 do_new_mount+0x2ba/0xb30 fs/namespace.c:2917 path_mount+0x56f/0xcb0 fs/namespace.c:3247 do_mount fs/namespace.c:3260 [inline] __do_sys_mount fs/namespace.c:3468 [inline] __se_sys_mount+0x2c4/0x3b0 fs/namespace.c:3445 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3445 do_syscall_64+0x34/0x70 entry_SYSCALL_64_after_hwframe+0x61/0xcb RIP: 0033:0x7f594245b169 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f5940ac5038 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f5942673fa0 RCX: 00007f594245b169 RDX: 0000400000000140 RSI: 0000400000000040 RDI: 0000400000000240 RBP: 00007f59424dc2a0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f5942673fa0 R15: 00007ffc1372d178 Allocated by task 23908: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:430 [inline] ____kasan_kmalloc+0xdb/0x110 mm/kasan/common.c:509 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:518 kasan_kmalloc include/linux/kasan.h:254 [inline] __kmalloc+0x1aa/0x330 mm/slub.c:4033 kmalloc include/linux/slab.h:557 [inline] kzalloc include/linux/slab.h:664 [inline] __register_sysctl_table+0xea/0x1240 fs/proc/proc_sysctl.c:1319 register_net_sysctl+0x2c/0x40 net/sysctl_net.c:121 __devinet_sysctl_register+0x1d3/0x2a0 net/ipv4/devinet.c:2598 devinet_sysctl_register+0x16a/0x1e0 net/ipv4/devinet.c:2638 inetdev_init+0x266/0x470 net/ipv4/devinet.c:277 inetdev_event+0x205/0x1040 net/ipv4/devinet.c:1544 notifier_call_chain kernel/notifier.c:83 [inline] raw_notifier_call_chain+0x8c/0xf0 kernel/notifier.c:410 call_netdevice_notifiers_info net/core/dev.c:2054 [inline] call_netdevice_notifiers_extack net/core/dev.c:2066 [inline] call_netdevice_notifiers+0x145/0x1b0 net/core/dev.c:2080 register_netdevice+0x1066/0x13f0 net/core/dev.c:10086 __ip_tunnel_create+0x2b0/0x370 net/ipv4/ip_tunnel.c:267 ip_tunnel_init_net+0x28d/0x750 net/ipv4/ip_tunnel.c:1083 erspan_init_net+0x29/0x30 net/ipv4/ip_gre.c:1718 ops_init+0x1cd/0x4a0 net/core/net_namespace.c:144 setup_net+0x367/0xbf0 net/core/net_namespace.c:345 copy_net_ns+0x32f/0x520 net/core/net_namespace.c:486 create_new_namespaces+0x410/0x660 kernel/nsproxy.c:110 copy_namespaces+0x1d1/0x220 kernel/nsproxy.c:179 copy_process+0x11a0/0x3340 kernel/fork.c:2186 kernel_clone+0x21e/0x9e0 kernel/fork.c:2574 __do_sys_clone kernel/fork.c:2700 [inline] __se_sys_clone kernel/fork.c:2684 [inline] __x64_sys_clone+0x23f/0x290 kernel/fork.c:2684 do_syscall_64+0x34/0x70 entry_SYSCALL_64_after_hwframe+0x61/0xcb Freed by task 1874: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:45 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370 ____kasan_slab_free+0x121/0x160 mm/kasan/common.c:362 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:370 kasan_slab_free include/linux/kasan.h:220 [inline] slab_free_hook mm/slub.c:1595 [inline] slab_free_freelist_hook+0xc0/0x190 mm/slub.c:1621 slab_free mm/slub.c:3203 [inline] kmem_cache_free_bulk+0x29f/0x590 mm/slub.c:3336 kfree_bulk include/linux/slab.h:409 [inline] kfree_rcu_work+0x2a4/0x680 kernel/rcu/tree.c:3238 process_one_work+0x6dc/0xbd0 kernel/workqueue.c:2301 worker_thread+0xaea/0x1510 kernel/workqueue.c:2447 kthread+0x34b/0x3d0 kernel/kthread.c:313 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 Last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38 __kasan_record_aux_stack+0xd3/0x100 mm/kasan/generic.c:348 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358 kvfree_call_rcu+0x136/0x650 kernel/rcu/tree.c:3535 drop_sysctl_table+0x311/0x450 fs/proc/proc_sysctl.c:1680 unregister_sysctl_table+0x76/0x120 fs/proc/proc_sysctl.c:1718 unregister_net_sysctl_table+0x15/0x20 net/sysctl_net.c:127 __devinet_sysctl_unregister net/ipv4/devinet.c:2621 [inline] devinet_sysctl_unregister net/ipv4/devinet.c:2649 [inline] inetdev_destroy net/ipv4/devinet.c:326 [inline] inetdev_event+0x76f/0x1040 net/ipv4/devinet.c:1612 notifier_call_chain kernel/notifier.c:83 [inline] raw_notifier_call_chain+0x8c/0xf0 kernel/notifier.c:410 call_netdevice_notifiers_info net/core/dev.c:2054 [inline] call_netdevice_notifiers_extack net/core/dev.c:2066 [inline] call_netdevice_notifiers net/core/dev.c:2080 [inline] unregister_netdevice_many+0xde7/0x17d0 net/core/dev.c:10766 ip_tunnel_delete_nets+0x33b/0x380 net/ipv4/ip_tunnel.c:1136 erspan_exit_batch_net+0x22/0x30 net/ipv4/ip_gre.c:1724 ops_exit_list net/core/net_namespace.c:190 [inline] cleanup_net+0x6e9/0xcb0 net/core/net_namespace.c:609 process_one_work+0x6dc/0xbd0 kernel/workqueue.c:2301 worker_thread+0xaea/0x1510 kernel/workqueue.c:2447 kthread+0x34b/0x3d0 kernel/kthread.c:313 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 Second to last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38 __kasan_record_aux_stack+0xd3/0x100 mm/kasan/generic.c:348 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358 kvfree_call_rcu+0x136/0x650 kernel/rcu/tree.c:3535 drop_sysctl_table+0x311/0x450 fs/proc/proc_sysctl.c:1680 unregister_sysctl_table+0x76/0x120 fs/proc/proc_sysctl.c:1718 unregister_net_sysctl_table+0x15/0x20 net/sysctl_net.c:127 __devinet_sysctl_unregister net/ipv4/devinet.c:2621 [inline] devinet_sysctl_unregister net/ipv4/devinet.c:2649 [inline] inetdev_destroy net/ipv4/devinet.c:326 [inline] inetdev_event+0x76f/0x1040 net/ipv4/devinet.c:1612 notifier_call_chain kernel/notifier.c:83 [inline] raw_notifier_call_chain+0x8c/0xf0 kernel/notifier.c:410 call_netdevice_notifiers_info net/core/dev.c:2054 [inline] call_netdevice_notifiers_extack net/core/dev.c:2066 [inline] call_netdevice_notifiers net/core/dev.c:2080 [inline] unregister_netdevice_many+0xde7/0x17d0 net/core/dev.c:10766 ip_tunnel_delete_nets+0x33b/0x380 net/ipv4/ip_tunnel.c:1136 ipgre_exit_batch_net+0x22/0x30 net/ipv4/ip_gre.c:1034 ops_exit_list net/core/net_namespace.c:190 [inline] cleanup_net+0x6e9/0xcb0 net/core/net_namespace.c:609 process_one_work+0x6dc/0xbd0 kernel/workqueue.c:2301 worker_thread+0xaea/0x1510 kernel/workqueue.c:2447 kthread+0x34b/0x3d0 kernel/kthread.c:313 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 The buggy address belongs to the object at ffff8881009b5000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1120 bytes inside of 2048-byte region [ffff8881009b5000, ffff8881009b5800) The buggy address belongs to the page: page:ffffea0004026c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1009b0 head:ffffea0004026c00 order:3 compound_mapcount:0 compound_pincount:0 flags: 0x4000000000010200(slab|head) raw: 4000000000010200 dead000000000100 dead000000000122 ffff888100042d80 raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, ts 1660642800, free_ts 0 set_page_owner include/linux/page_owner.h:35 [inline] post_alloc_hook mm/page_alloc.c:2456 [inline] prep_new_page+0x166/0x180 mm/page_alloc.c:2462 get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4254 __alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5348 allocate_slab mm/slub.c:1808 [inline] new_slab+0x80/0x400 mm/slub.c:1869 new_slab_objects mm/slub.c:2627 [inline] ___slab_alloc+0x302/0x4b0 mm/slub.c:2791 __slab_alloc+0x63/0xa0 mm/slub.c:2831 slab_alloc_node mm/slub.c:2913 [inline] slab_alloc mm/slub.c:2955 [inline] kmem_cache_alloc_trace+0x1bd/0x2e0 mm/slub.c:2972 kmem_cache_alloc_node_trace include/linux/slab.h:440 [inline] kmalloc_node include/linux/slab.h:570 [inline] kzalloc_node include/linux/slab.h:675 [inline] __alloc_disk_node+0x76/0x570 block/genhd.c:1727 brd_alloc+0x146/0x400 drivers/block/brd.c:394 brd_init+0x125/0x474 drivers/block/brd.c:517 do_one_initcall+0x189/0x620 init/main.c:1197 do_initcall_level+0x186/0x304 init/main.c:1270 do_initcalls+0x4e/0x8e init/main.c:1286 do_basic_setup+0x88/0x91 init/main.c:1306 kernel_init_freeable+0x2be/0x3f5 init/main.c:1510 kernel_init+0x11/0x280 init/main.c:1397 page_owner free stack trace missing Memory state around the buggy address: ffff8881009b5300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881009b5380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881009b5400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881009b5480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881009b5500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================