================================================================== BUG: KASAN: use-after-free in get_disk_and_module block/genhd.c:1524 [inline] BUG: KASAN: use-after-free in exact_lock+0x38/0xc0 block/genhd.c:594 Read of size 8 at addr ffff8881f06a84d0 by task syz-executor/14885 CPU: 0 PID: 14885 Comm: syz-executor Tainted: G W 5.4.292-syzkaller-00021-gcd8e74fa0fa3 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 Call Trace: __dump_stack+0x1e/0x20 lib/dump_stack.c:77 dump_stack+0x15b/0x1b8 lib/dump_stack.c:118 print_address_description+0x8d/0x4c0 mm/kasan/report.c:384 __kasan_report+0xef/0x120 mm/kasan/report.c:516 kasan_report+0x30/0x60 mm/kasan/common.c:653 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132 get_disk_and_module block/genhd.c:1524 [inline] exact_lock+0x38/0xc0 block/genhd.c:594 kobj_lookup+0x298/0x430 drivers/base/map.c:119 get_gendisk+0xe9/0x340 block/genhd.c:879 bdev_get_gendisk fs/block_dev.c:1105 [inline] __blkdev_get+0x125/0x1560 fs/block_dev.c:1560 blkdev_get+0x68/0x380 fs/block_dev.c:1714 blkdev_open+0x1cb/0x2b0 fs/block_dev.c:1856 do_dentry_open+0x8b5/0x1030 fs/open.c:806 vfs_open+0x73/0x80 fs/open.c:920 do_last fs/namei.c:3565 [inline] path_openat+0x2a5e/0x35c0 fs/namei.c:3683 do_filp_open+0x1ae/0x3f0 fs/namei.c:3713 do_sys_open+0x2bb/0x5d0 fs/open.c:1123 __do_sys_openat fs/open.c:1150 [inline] __se_sys_openat fs/open.c:1144 [inline] __x64_sys_openat+0xa2/0xb0 fs/open.c:1144 do_syscall_64+0xcf/0x170 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x5c/0xc1 RIP: 0033:0x7f457fb60251 Code: 75 57 89 f0 25 00 00 41 00 3d 00 00 41 00 74 49 80 3d fa 72 1f 00 00 74 6d 89 da 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 93 00 00 00 48 8b 54 24 28 64 48 2b 14 25 RSP: 002b:00007ffc0196d5f0 EFLAGS: 00000202 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007f457fb60251 RDX: 0000000000000002 RSI: 00007ffc0196d700 RDI: 00000000ffffff9c RBP: 00007ffc0196d700 R08: 000000000000000a R09: 00007ffc0196d3b7 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000 R13: 00007f457fd50260 R14: 0000000000000003 R15: 00007ffc0196d700 Allocated by task 14770: save_stack mm/kasan/common.c:70 [inline] set_track mm/kasan/common.c:78 [inline] __kasan_kmalloc+0x162/0x200 mm/kasan/common.c:529 kasan_kmalloc+0xd/0x20 mm/kasan/common.c:543 __kmalloc+0x12a/0x2f0 mm/slub.c:3913 kmalloc include/linux/slab.h:561 [inline] kzalloc include/linux/slab.h:690 [inline] __register_sysctl_table+0xeb/0x1130 fs/proc/proc_sysctl.c:1332 register_net_sysctl+0x2c/0x40 net/sysctl_net.c:121 __addrconf_sysctl_register+0x26e/0x3d0 net/ipv6/addrconf.c:6977 addrconf_init_net+0x256/0x470 net/ipv6/addrconf.c:7072 ops_init+0x1ba/0x4a0 net/core/net_namespace.c:141 setup_net+0x20c/0x9b0 net/core/net_namespace.c:348 copy_net_ns+0x314/0x520 net/core/net_namespace.c:489 create_new_namespaces+0x49c/0x590 kernel/nsproxy.c:103 unshare_nsproxy_namespaces+0x120/0x170 kernel/nsproxy.c:202 ksys_unshare+0x4a4/0x7d0 kernel/fork.c:2908 __do_sys_unshare kernel/fork.c:2976 [inline] __se_sys_unshare kernel/fork.c:2974 [inline] __x64_sys_unshare+0x38/0x40 kernel/fork.c:2974 do_syscall_64+0xcf/0x170 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x5c/0xc1 Freed by task 17: save_stack mm/kasan/common.c:70 [inline] set_track mm/kasan/common.c:78 [inline] kasan_set_free_info mm/kasan/common.c:345 [inline] __kasan_slab_free+0x1c3/0x280 mm/kasan/common.c:487 kasan_slab_free+0xe/0x10 mm/kasan/common.c:496 slab_free_hook mm/slub.c:1455 [inline] slab_free_freelist_hook+0xb7/0x180 mm/slub.c:1494 slab_free mm/slub.c:3080 [inline] kfree+0xbe/0x260 mm/slub.c:4071 __rcu_reclaim kernel/rcu/rcu.h:215 [inline] rcu_do_batch+0x416/0x980 kernel/rcu/tree.c:2167 rcu_core+0x4bd/0xbd0 kernel/rcu/tree.c:2387 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2396 __do_softirq+0x236/0x660 kernel/softirq.c:292 The buggy address belongs to the object at ffff8881f06a8000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1232 bytes inside of 2048-byte region [ffff8881f06a8000, ffff8881f06a8800) The buggy address belongs to the page: page:ffffea0007c1aa00 refcount:1 mapcount:0 mapping:ffff8881f5c0c000 index:0x0 compound_mapcount: 0 flags: 0x8000000000010200(slab|head) raw: 8000000000010200 0000000000000000 0000000100000001 ffff8881f5c0c000 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) set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook mm/page_alloc.c:2165 [inline] prep_new_page+0x35e/0x370 mm/page_alloc.c:2171 get_page_from_freelist+0x1296/0x1310 mm/page_alloc.c:3794 __alloc_pages_nodemask+0x202/0x4b0 mm/page_alloc.c:4894 alloc_slab_page+0x3c/0x3b0 mm/slub.c:343 allocate_slab mm/slub.c:1683 [inline] new_slab+0x93/0x420 mm/slub.c:1749 new_slab_objects mm/slub.c:2505 [inline] ___slab_alloc+0x29e/0x420 mm/slub.c:2667 __slab_alloc+0x63/0xa0 mm/slub.c:2707 slab_alloc_node mm/slub.c:2792 [inline] slab_alloc mm/slub.c:2837 [inline] kmem_cache_alloc_trace+0x130/0x290 mm/slub.c:2854 kmem_cache_alloc_node_trace include/linux/slab.h:444 [inline] kmalloc_node include/linux/slab.h:594 [inline] kzalloc_node include/linux/slab.h:701 [inline] __alloc_disk_node+0x79/0x5c0 block/genhd.c:1477 loop_add+0x32b/0x780 drivers/block/loop.c:2142 loop_init+0x1bf/0x1ff drivers/block/loop.c:2387 do_one_initcall+0x196/0x5c0 init/main.c:1192 do_initcall_level+0x21b/0x408 init/main.c:1259 do_initcalls+0x50/0x92 init/main.c:1275 do_basic_setup+0x88/0x8f init/main.c:1295 kernel_init_freeable+0x282/0x42f init/main.c:1458 page_owner free stack trace missing Memory state around the buggy address: ffff8881f06a8380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881f06a8400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881f06a8480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881f06a8500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881f06a8580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault: 0000 [#1] PREEMPT SMP KASAN CPU: 1 PID: 14885 Comm: syz-executor Tainted: G B W 5.4.292-syzkaller-00021-gcd8e74fa0fa3 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 RIP: 0010:module_is_live include/linux/module.h:542 [inline] RIP: 0010:try_module_get+0x80/0x2d0 kernel/module.c:1139 Code: f1 f1 f1 f1 04 f3 f3 f3 4b 89 44 3d 00 48 85 ff 0f 84 d5 00 00 00 48 89 fb bf 01 00 00 00 e8 17 cb eb ff 48 89 d8 48 c1 e8 03 <42> 0f b6 04 38 84 c0 0f 85 f5 00 00 00 83 3b 02 0f 84 e2 00 00 00 RSP: 0018:ffff8881b261f480 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffffffff86542900 RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffffffff8155a7a9 RBP: ffff8881b261f540 R08: 0000000000000004 R09: 0000000000000003 R10: fffffbfff0ca7a5c R11: 1ffffffff0ca7a5c R12: ffff8881f06a8000 R13: 1ffff110364c3e94 R14: 0000000000000001 R15: dffffc0000000000 FS: 000055557d697500(0000) GS:ffff8881f6f00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000555574ab24a8 CR3: 00000001d494e000 CR4: 00000000003426a0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: get_disk_and_module block/genhd.c:1527 [inline] exact_lock+0x6a/0xc0 block/genhd.c:594 kobj_lookup+0x298/0x430 drivers/base/map.c:119 get_gendisk+0xe9/0x340 block/genhd.c:879 bdev_get_gendisk fs/block_dev.c:1105 [inline] __blkdev_get+0x125/0x1560 fs/block_dev.c:1560 blkdev_get+0x68/0x380 fs/block_dev.c:1714 blkdev_open+0x1cb/0x2b0 fs/block_dev.c:1856 do_dentry_open+0x8b5/0x1030 fs/open.c:806 vfs_open+0x73/0x80 fs/open.c:920 do_last fs/namei.c:3565 [inline] path_openat+0x2a5e/0x35c0 fs/namei.c:3683 do_filp_open+0x1ae/0x3f0 fs/namei.c:3713 do_sys_open+0x2bb/0x5d0 fs/open.c:1123 __do_sys_openat fs/open.c:1150 [inline] __se_sys_openat fs/open.c:1144 [inline] __x64_sys_openat+0xa2/0xb0 fs/open.c:1144 do_syscall_64+0xcf/0x170 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x5c/0xc1 RIP: 0033:0x7f457fb60251 Code: 75 57 89 f0 25 00 00 41 00 3d 00 00 41 00 74 49 80 3d fa 72 1f 00 00 74 6d 89 da 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 93 00 00 00 48 8b 54 24 28 64 48 2b 14 25 RSP: 002b:00007ffc0196d5f0 EFLAGS: 00000202 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007f457fb60251 RDX: 0000000000000002 RSI: 00007ffc0196d700 RDI: 00000000ffffff9c RBP: 00007ffc0196d700 R08: 000000000000000a R09: 00007ffc0196d3b7 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000 R13: 00007f457fd50260 R14: 0000000000000003 R15: 00007ffc0196d700 Modules linked in: ---[ end trace d4e25a54f35ce727 ]--- RIP: 0010:module_is_live include/linux/module.h:542 [inline] RIP: 0010:try_module_get+0x80/0x2d0 kernel/module.c:1139 Code: f1 f1 f1 f1 04 f3 f3 f3 4b 89 44 3d 00 48 85 ff 0f 84 d5 00 00 00 48 89 fb bf 01 00 00 00 e8 17 cb eb ff 48 89 d8 48 c1 e8 03 <42> 0f b6 04 38 84 c0 0f 85 f5 00 00 00 83 3b 02 0f 84 e2 00 00 00 RSP: 0018:ffff8881b261f480 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffffffff86542900 RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffffffff8155a7a9 RBP: ffff8881b261f540 R08: 0000000000000004 R09: 0000000000000003 R10: fffffbfff0ca7a5c R11: 1ffffffff0ca7a5c R12: ffff8881f06a8000 R13: 1ffff110364c3e94 R14: 0000000000000001 R15: dffffc0000000000 FS: 000055557d697500(0000) GS:ffff8881f6f00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000555574ab24a8 CR3: 00000001d494e000 CR4: 00000000003426a0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 ---------------- Code disassembly (best guess): 0: f1 int1 1: f1 int1 2: f1 int1 3: f1 int1 4: 04 f3 add $0xf3,%al 6: f3 f3 4b 89 44 3d 00 repz xrelease mov %rax,0x0(%r13,%r15,1) d: 48 85 ff test %rdi,%rdi 10: 0f 84 d5 00 00 00 je 0xeb 16: 48 89 fb mov %rdi,%rbx 19: bf 01 00 00 00 mov $0x1,%edi 1e: e8 17 cb eb ff call 0xffebcb3a 23: 48 89 d8 mov %rbx,%rax 26: 48 c1 e8 03 shr $0x3,%rax * 2a: 42 0f b6 04 38 movzbl (%rax,%r15,1),%eax <-- trapping instruction 2f: 84 c0 test %al,%al 31: 0f 85 f5 00 00 00 jne 0x12c 37: 83 3b 02 cmpl $0x2,(%rbx) 3a: 0f 84 e2 00 00 00 je 0x122