================================================================== 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 ffff8881f06184d0 by task syz-executor/12230 CPU: 0 PID: 12230 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:0x7fb7ab519251 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:00007ffce87fc200 EFLAGS: 00000202 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fb7ab519251 RDX: 0000000000000002 RSI: 00007ffce87fc310 RDI: 00000000ffffff9c RBP: 00007ffce87fc310 R08: 000000000000000a R09: 00007ffce87fbfc7 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000150 R13: 00000000000927c0 R14: 00000000000c6bf6 R15: 00007ffce87fc310 Allocated by task 1: 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 kmem_cache_alloc_trace+0x112/0x290 mm/slub.c:2856 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 kernel_init+0x11/0x1a0 init/main.c:1375 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:354 Freed by task 18922: 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 disk_release+0x251/0x2b0 block/genhd.c:1335 device_release+0x70/0x1a0 drivers/base/core.c:1776 kobject_cleanup lib/kobject.c:716 [inline] kobject_release lib/kobject.c:747 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1fe/0x2c0 lib/kobject.c:764 put_disk+0x23/0x30 block/genhd.c:1542 loop_remove+0x93/0xb0 drivers/block/loop.c:2197 loop_control_ioctl+0x487/0x550 drivers/block/loop.c:2293 do_vfs_ioctl+0x753/0x13f0 fs/ioctl.c:47 ksys_ioctl fs/ioctl.c:742 [inline] __do_sys_ioctl fs/ioctl.c:749 [inline] __se_sys_ioctl fs/ioctl.c:747 [inline] __x64_sys_ioctl+0xe1/0x120 fs/ioctl.c:747 do_syscall_64+0xcf/0x170 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x5c/0xc1 The buggy address belongs to the object at ffff8881f0618000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1232 bytes inside of 2048-byte region [ffff8881f0618000, ffff8881f0618800) The buggy address belongs to the page: page:ffffea0007c18600 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: ffff8881f0618380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881f0618400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881f0618480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881f0618500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881f0618580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================