================================================================== BUG: KASAN: use-after-free in get_disk_and_module block/genhd.c:1787 [inline] BUG: KASAN: use-after-free in exact_lock+0x38/0xc0 block/genhd.c:677 Read of size 8 at addr ffff8881095d9460 by task syz.1.3689/15334 CPU: 1 PID: 15334 Comm: syz.1.3689 Tainted: G W 5.10.236-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 Call Trace: __dump_stack+0x21/0x24 lib/dump_stack.c:77 dump_stack_lvl+0x169/0x1d8 lib/dump_stack.c:118 print_address_description+0x7f/0x2c0 mm/kasan/report.c:248 __kasan_report mm/kasan/report.c:435 [inline] kasan_report+0xe2/0x130 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/0xc0 block/genhd.c:677 kobj_lookup+0x298/0x430 drivers/base/map.c:119 get_gendisk+0xe9/0x340 block/genhd.c:1001 bdev_get_gendisk fs/block_dev.c:1110 [inline] __blkdev_get+0x1b0/0x12f0 fs/block_dev.c:1474 blkdev_get fs/block_dev.c:1653 [inline] blkdev_open+0x208/0x430 fs/block_dev.c:1770 do_dentry_open+0x793/0x1090 fs/open.c:819 vfs_open+0x73/0x80 fs/open.c:942 do_open fs/namei.c:3391 [inline] path_openat+0x27ad/0x3160 fs/namei.c:3509 do_filp_open+0x1b3/0x3e0 fs/namei.c:3536 do_sys_openat2+0x14c/0x6d0 fs/open.c:1217 do_sys_open fs/open.c:1233 [inline] __do_sys_open fs/open.c:1241 [inline] __se_sys_open fs/open.c:1237 [inline] __x64_sys_open+0x11c/0x140 fs/open.c:1237 do_syscall_64+0x31/0x40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x61/0xcb RIP: 0033:0x7f18dd26b969 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:00007f18db8d4038 EFLAGS: 00000246 ORIG_RAX: 0000000000000002 RAX: ffffffffffffffda RBX: 00007f18dd492fa0 RCX: 00007f18dd26b969 RDX: 000000000000014a RSI: 0000000000085481 RDI: 0000200000000040 RBP: 00007f18dd2edab1 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f18dd492fa0 R15: 00007ffd67900808 Allocated by task 8149: 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 mm/kasan/common.c:509 [inline] __kasan_kmalloc+0xda/0x110 mm/kasan/common.c:518 kasan_kmalloc include/linux/kasan.h:254 [inline] kmem_cache_alloc_trace+0x184/0x2e0 mm/slub.c:2974 kmalloc include/linux/slab.h:552 [inline] kmalloc_array include/linux/slab.h:591 [inline] kcalloc include/linux/slab.h:603 [inline] input_alloc_absinfo drivers/input/input.c:502 [inline] input_set_abs_params+0x94/0x260 drivers/input/input.c:520 aiptek_probe+0x9e8/0x19e0 drivers/input/tablet/aiptek.c:1797 usb_probe_interface+0x5ff/0xae0 drivers/usb/core/driver.c:397 really_probe+0x3d8/0xa90 drivers/base/dd.c:562 driver_probe_device+0xe7/0x190 drivers/base/dd.c:752 __device_attach_driver+0x282/0x3f0 drivers/base/dd.c:863 bus_for_each_drv+0x175/0x200 drivers/base/bus.c:433 __device_attach+0x29a/0x400 drivers/base/dd.c:932 device_initial_probe+0x1a/0x20 drivers/base/dd.c:981 bus_probe_device+0xc0/0x1e0 drivers/base/bus.c:493 device_add+0x8b4/0xbf0 drivers/base/core.c:3273 usb_set_configuration+0x1a47/0x1f80 drivers/usb/core/message.c:2160 usb_generic_driver_probe+0x91/0x150 drivers/usb/core/generic.c:238 usb_probe_device+0x148/0x260 drivers/usb/core/driver.c:294 really_probe+0x3d8/0xa90 drivers/base/dd.c:562 driver_probe_device+0xe7/0x190 drivers/base/dd.c:752 __device_attach_driver+0x282/0x3f0 drivers/base/dd.c:863 bus_for_each_drv+0x175/0x200 drivers/base/bus.c:433 __device_attach+0x29a/0x400 drivers/base/dd.c:932 device_initial_probe+0x1a/0x20 drivers/base/dd.c:981 bus_probe_device+0xc0/0x1e0 drivers/base/bus.c:493 device_add+0x8b4/0xbf0 drivers/base/core.c:3273 usb_new_device+0xcd1/0x1450 drivers/usb/core/hub.c:2626 hub_port_connect drivers/usb/core/hub.c:5469 [inline] hub_port_connect_change drivers/usb/core/hub.c:5609 [inline] port_event drivers/usb/core/hub.c:5759 [inline] hub_event+0x2679/0x4120 drivers/usb/core/hub.c:5841 process_one_work+0x6e1/0xba0 kernel/workqueue.c:2301 worker_thread+0xa6a/0x13b0 kernel/workqueue.c:2447 kthread+0x346/0x3d0 kernel/kthread.c:313 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 Freed by task 8149: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4a/0x70 mm/kasan/common.c:45 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370 ____kasan_slab_free+0x125/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+0xc5/0x190 mm/slub.c:1621 slab_free mm/slub.c:3203 [inline] kfree+0xc0/0x270 mm/slub.c:4191 input_dev_release+0x7e/0xc0 drivers/input/input.c:1612 device_release+0x96/0x1c0 drivers/base/core.c:-1 kobject_cleanup lib/kobject.c:713 [inline] kobject_release lib/kobject.c:744 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x18a/0x270 lib/kobject.c:761 put_device+0x1f/0x30 drivers/base/core.c:3372 input_put_device include/linux/input.h:373 [inline] input_unregister_device+0xb4/0xf0 drivers/input/input.c:2368 aiptek_disconnect+0x96/0x150 drivers/input/tablet/aiptek.c:1903 usb_unbind_interface+0x212/0x8c0 drivers/usb/core/driver.c:459 __device_release_driver drivers/base/dd.c:-1 [inline] device_release_driver_internal+0x4bc/0x750 drivers/base/dd.c:1221 device_release_driver+0x19/0x20 drivers/base/dd.c:1244 bus_remove_device+0x2dd/0x340 drivers/base/bus.c:535 device_del+0x696/0xed0 drivers/base/core.c:3452 usb_disable_device+0x3a8/0x750 drivers/usb/core/message.c:1411 usb_disconnect+0x31e/0x850 drivers/usb/core/hub.c:2282 hub_port_connect drivers/usb/core/hub.c:5308 [inline] hub_port_connect_change drivers/usb/core/hub.c:5609 [inline] port_event drivers/usb/core/hub.c:5759 [inline] hub_event+0x1912/0x4120 drivers/usb/core/hub.c:5841 process_one_work+0x6e1/0xba0 kernel/workqueue.c:2301 process_scheduled_works kernel/workqueue.c:2363 [inline] worker_thread+0xd56/0x13b0 kernel/workqueue.c:2449 kthread+0x346/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 ffff8881095d9000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1120 bytes inside of 2048-byte region [ffff8881095d9000, ffff8881095d9800) The buggy address belongs to the page: page:ffffea0004257600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1095d8 head:ffffea0004257600 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 2083307114, 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+0x179/0x180 mm/page_alloc.c:2462 get_page_from_freelist+0x2235/0x23d0 mm/page_alloc.c:4254 __alloc_pages_nodemask+0x268/0x5f0 mm/page_alloc.c:5349 alloc_slab_page mm/slub.c:-1 [inline] allocate_slab mm/slub.c:1808 [inline] new_slab+0x84/0x3f0 mm/slub.c:1869 new_slab_objects mm/slub.c:2627 [inline] ___slab_alloc+0x2a6/0x450 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+0x1b3/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+0x79/0x580 block/genhd.c:1727 loop_add+0x33f/0x7b0 drivers/block/loop.c:2158 loop_init+0x1bf/0x1ff drivers/block/loop.c:2403 do_one_initcall+0x187/0x510 init/main.c:1197 do_initcall_level+0x16f/0x2cf init/main.c:1270 do_initcalls+0x50/0x92 init/main.c:1286 do_basic_setup+0x88/0x8f init/main.c:1306 kernel_init_freeable+0x287/0x3be init/main.c:1510 kernel_init+0x11/0x1a0 init/main.c:1397 page_owner free stack trace missing Memory state around the buggy address: ffff8881095d9300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881095d9380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881095d9400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881095d9480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881095d9500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================