================================================================== 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 ffff8881095e2460 by task syz.0.861/3872 CPU: 1 PID: 3872 Comm: syz.0.861 Tainted: G W 5.10.234-syzkaller-00023-g3f5f2283d684 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 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_open+0x241/0x480 fs/block_dev.c:1770 do_dentry_open+0x7c1/0x10d0 fs/open.c:819 vfs_open+0x73/0x80 fs/open.c:942 do_open fs/namei.c:3391 [inline] path_openat+0x2660/0x3000 fs/namei.c:3509 do_filp_open+0x21c/0x460 fs/namei.c:3536 do_sys_openat2+0x13f/0x710 fs/open.c:1217 do_sys_open fs/open.c:1233 [inline] __do_sys_creat fs/open.c:1309 [inline] __se_sys_creat fs/open.c:1303 [inline] __x64_sys_creat+0x11f/0x160 fs/open.c:1303 do_syscall_64+0x34/0x70 entry_SYSCALL_64_after_hwframe+0x61/0xcb RIP: 0033:0x7fe853e43169 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:00007fe85248c038 EFLAGS: 00000246 ORIG_RAX: 0000000000000055 RAX: ffffffffffffffda RBX: 00007fe85405c080 RCX: 00007fe853e43169 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00004000000000c0 RBP: 00007fe853ec42a0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fe85405c080 R15: 00007fffd20b0038 Allocated by task 3534: 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] kmem_cache_alloc_trace+0x18a/0x2e0 mm/slub.c:2974 kmalloc include/linux/slab.h:552 [inline] kzalloc include/linux/slab.h:664 [inline] do_check_common+0x188/0x1370 kernel/bpf/verifier.c:12004 do_check_main kernel/bpf/verifier.c:12110 [inline] bpf_check+0xb551/0xf230 kernel/bpf/verifier.c:12665 bpf_prog_load kernel/bpf/syscall.c:2239 [inline] __do_sys_bpf kernel/bpf/syscall.c:4440 [inline] __se_sys_bpf+0x107a2/0x11cb0 kernel/bpf/syscall.c:4396 __x64_sys_bpf+0x7b/0x90 kernel/bpf/syscall.c:4396 do_syscall_64+0x34/0x70 entry_SYSCALL_64_after_hwframe+0x61/0xcb Freed by task 3534: 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] kfree+0xc3/0x270 mm/slub.c:4191 free_func_state kernel/bpf/verifier.c:839 [inline] free_verifier_state+0xe3/0x220 kernel/bpf/verifier.c:855 do_check_common+0x983/0x1370 kernel/bpf/verifier.c:12053 do_check_main kernel/bpf/verifier.c:12110 [inline] bpf_check+0xb551/0xf230 kernel/bpf/verifier.c:12665 bpf_prog_load kernel/bpf/syscall.c:2239 [inline] __do_sys_bpf kernel/bpf/syscall.c:4440 [inline] __se_sys_bpf+0x107a2/0x11cb0 kernel/bpf/syscall.c:4396 __x64_sys_bpf+0x7b/0x90 kernel/bpf/syscall.c:4396 do_syscall_64+0x34/0x70 entry_SYSCALL_64_after_hwframe+0x61/0xcb The buggy address belongs to the object at ffff8881095e2000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1120 bytes inside of 2048-byte region [ffff8881095e2000, ffff8881095e2800) The buggy address belongs to the page: page:ffffea0004257800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1095e0 head:ffffea0004257800 order:3 compound_mapcount:0 compound_pincount:0 flags: 0x4000000000010200(slab|head) raw: 4000000000010200 0000000000000000 0000000100000001 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 1794292276, 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 loop_add+0x32d/0x750 drivers/block/loop.c:2158 loop_init+0x225/0x263 drivers/block/loop.c:2403 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: ffff8881095e2300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881095e2380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881095e2400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881095e2480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881095e2500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== general protection fault, probably for non-canonical address 0xdffffc000000000c: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000060-0x0000000000000067] CPU: 1 PID: 3872 Comm: syz.0.861 Tainted: G B W 5.10.234-syzkaller-00023-g3f5f2283d684 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 RIP: 0010:get_disk_and_module block/genhd.c:1789 [inline] RIP: 0010:exact_lock+0x4b/0xd0 block/genhd.c:677 Code: 00 48 89 d8 48 c1 e8 03 42 80 3c 30 00 74 08 48 89 df e8 38 21 60 ff 48 8b 1b 48 85 db 74 35 48 83 c3 68 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 16 21 60 ff 4c 8b 33 4d 85 f6 74 RSP: 0018:ffffc90000c175b0 EFLAGS: 00010207 RAX: 000000000000000c RBX: 0000000000000067 RCX: 0000000000080000 RDX: ffffc9000213e000 RSI: 0000000000000286 RDI: 0000000000080000 RBP: ffffc90000c175c8 R08: ffffffff813e2b8b R09: 0000000000000003 R10: fffffbfff0e11248 R11: dffffc0000000001 R12: ffffffff82483d10 R13: 0000000000700001 R14: dffffc0000000000 R15: ffff8881095e2000 FS: 00007fe85248c6c0(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fe85246bd58 CR3: 0000000123fee000 CR4: 00000000003506a0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: 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_open+0x241/0x480 fs/block_dev.c:1770 do_dentry_open+0x7c1/0x10d0 fs/open.c:819 vfs_open+0x73/0x80 fs/open.c:942 do_open fs/namei.c:3391 [inline] path_openat+0x2660/0x3000 fs/namei.c:3509 do_filp_open+0x21c/0x460 fs/namei.c:3536 do_sys_openat2+0x13f/0x710 fs/open.c:1217 do_sys_open fs/open.c:1233 [inline] __do_sys_creat fs/open.c:1309 [inline] __se_sys_creat fs/open.c:1303 [inline] __x64_sys_creat+0x11f/0x160 fs/open.c:1303 do_syscall_64+0x34/0x70 entry_SYSCALL_64_after_hwframe+0x61/0xcb RIP: 0033:0x7fe853e43169 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:00007fe85248c038 EFLAGS: 00000246 ORIG_RAX: 0000000000000055 RAX: ffffffffffffffda RBX: 00007fe85405c080 RCX: 00007fe853e43169 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00004000000000c0 RBP: 00007fe853ec42a0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fe85405c080 R15: 00007fffd20b0038 Modules linked in: ---[ end trace 527fe633959b4040 ]--- RIP: 0010:get_disk_and_module block/genhd.c:1789 [inline] RIP: 0010:exact_lock+0x4b/0xd0 block/genhd.c:677 Code: 00 48 89 d8 48 c1 e8 03 42 80 3c 30 00 74 08 48 89 df e8 38 21 60 ff 48 8b 1b 48 85 db 74 35 48 83 c3 68 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 16 21 60 ff 4c 8b 33 4d 85 f6 74 RSP: 0018:ffffc90000c175b0 EFLAGS: 00010207 RAX: 000000000000000c RBX: 0000000000000067 RCX: 0000000000080000 RDX: ffffc9000213e000 RSI: 0000000000000286 RDI: 0000000000080000 RBP: ffffc90000c175c8 R08: ffffffff813e2b8b R09: 0000000000000003 R10: fffffbfff0e11248 R11: dffffc0000000001 R12: ffffffff82483d10 R13: 0000000000700001 R14: dffffc0000000000 R15: ffff8881095e2000 FS: 00007fe85248c6c0(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000110c30abea CR3: 0000000123fee000 CR4: 00000000003506b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 ---------------- Code disassembly (best guess): 0: 00 48 89 add %cl,-0x77(%rax) 3: d8 48 c1 fmuls -0x3f(%rax) 6: e8 03 42 80 3c call 0x3c80420e b: 30 00 xor %al,(%rax) d: 74 08 je 0x17 f: 48 89 df mov %rbx,%rdi 12: e8 38 21 60 ff call 0xff60214f 17: 48 8b 1b mov (%rbx),%rbx 1a: 48 85 db test %rbx,%rbx 1d: 74 35 je 0x54 1f: 48 83 c3 68 add $0x68,%rbx 23: 48 89 d8 mov %rbx,%rax 26: 48 c1 e8 03 shr $0x3,%rax * 2a: 42 80 3c 30 00 cmpb $0x0,(%rax,%r14,1) <-- trapping instruction 2f: 74 08 je 0x39 31: 48 89 df mov %rbx,%rdi 34: e8 16 21 60 ff call 0xff60214f 39: 4c 8b 33 mov (%rbx),%r14 3c: 4d 85 f6 test %r14,%r14 3f: 74 .byte 0x74