bisecting fixing commit since 2d2791fce891fc20709232d49a6bae075b9a77f8 building syzkaller on a57db36fe48aa500618c2eac3b38c27afe6d290f testing commit 2d2791fce891fc20709232d49a6bae075b9a77f8 with gcc (GCC) 8.4.1 20210217 kernel signature: 88f724f6163c88a895dbada7b293e8933f734832f903b8d5df99e03319075388 all runs: crashed: KASAN: use-after-free Read in disk_unblock_events testing current HEAD 670d6552eda8ff0c5f396d3d6f0174237917c66c testing commit 670d6552eda8ff0c5f396d3d6f0174237917c66c with gcc (GCC) 8.4.1 20210217 kernel signature: 62acf1bbe52b4dd00d992899b37c6a09101cca30fe3e7862efd2799ca48ae0bd all runs: crashed: KASAN: use-after-free Read in disk_unblock_events revisions tested: 2, total time: 21m22.825416169s (build: 14m45.435605813s, test: 6m14.09848398s) the crash still happens on HEAD commit msg: Linux 4.14.227 crash: KASAN: use-after-free Read in disk_unblock_events md: md1 stopped. md: md1 stopped. md: md1 stopped. md: md1 stopped. ================================================================== BUG: KASAN: use-after-free in disk_unblock_events+0x42/0x50 block/genhd.c:1647 Read of size 8 at addr ffff8880b05c0f08 by task syz-executor.0/10067 CPU: 0 PID: 10067 Comm: syz-executor.0 Not tainted 4.14.227-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x14b/0x1e7 lib/dump_stack.c:58 print_address_description.cold.6+0x9/0x1ca mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 [inline] kasan_report mm/kasan/report.c:409 [inline] kasan_report.cold.7+0x11a/0x2d3 mm/kasan/report.c:393 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430 disk_unblock_events+0x42/0x50 block/genhd.c:1647 __blkdev_get+0x6ef/0xff0 fs/block_dev.c:1556 blkdev_get+0x265/0x890 fs/block_dev.c:1611 md: md1 stopped. blkdev_open+0x19f/0x200 fs/block_dev.c:1772 do_dentry_open+0x3e4/0xde0 fs/open.c:777 vfs_open+0xfc/0x240 fs/open.c:888 do_last fs/namei.c:3428 [inline] path_openat+0xb6f/0x2760 fs/namei.c:3569 do_filp_open+0x16b/0x220 fs/namei.c:3603 do_sys_open+0x1d0/0x350 fs/open.c:1081 SYSC_openat fs/open.c:1108 [inline] SyS_openat+0xf/0x20 fs/open.c:1102 do_syscall_64+0x1c7/0x5b0 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x46/0xbb RIP: 0033:0x465b09 RSP: 002b:00007fc5b8042188 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 000000000056c008 RCX: 0000000000465b09 RDX: 0000000000000000 RSI: 00000000200020c0 RDI: ffffffffffffff9c RBP: 00000000004b069f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056c008 R13: 00007ffc87d8518f R14: 00007fc5b8042300 R15: 0000000000022000 Allocated by task 10054: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 save_stack mm/kasan/kasan.c:447 [inline] set_track mm/kasan/kasan.c:459 [inline] kasan_kmalloc.part.1+0x62/0xf0 mm/kasan/kasan.c:551 kasan_kmalloc+0xaf/0xc0 mm/kasan/kasan.c:536 kmem_cache_alloc_node_trace+0x151/0x3f0 mm/slab.c:3661 kmalloc_node include/linux/slab.h:526 [inline] kzalloc_node include/linux/slab.h:672 [inline] alloc_disk_node+0x5e/0x380 block/genhd.c:1390 alloc_disk+0xe/0x10 block/genhd.c:1374 md_alloc+0x1e0/0x7a0 drivers/md/md.c:5332 md_probe+0x17/0x20 drivers/md/md.c:5389 kobj_lookup+0x20a/0x410 drivers/base/map.c:124 get_gendisk+0x2f/0x1d0 block/genhd.c:788 __blkdev_get+0x3d4/0xff0 fs/block_dev.c:1449 blkdev_get+0x265/0x890 fs/block_dev.c:1611 blkdev_open+0x19f/0x200 fs/block_dev.c:1772 do_dentry_open+0x3e4/0xde0 fs/open.c:777 vfs_open+0xfc/0x240 fs/open.c:888 do_last fs/namei.c:3428 [inline] path_openat+0xb6f/0x2760 fs/namei.c:3569 do_filp_open+0x16b/0x220 fs/namei.c:3603 do_sys_open+0x1d0/0x350 fs/open.c:1081 SYSC_openat fs/open.c:1108 [inline] SyS_openat+0xf/0x20 fs/open.c:1102 do_syscall_64+0x1c7/0x5b0 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x46/0xbb Freed by task 10067: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 save_stack mm/kasan/kasan.c:447 [inline] set_track mm/kasan/kasan.c:459 [inline] kasan_slab_free+0xab/0x190 mm/kasan/kasan.c:524 __cache_free mm/slab.c:3496 [inline] kfree+0xcc/0x270 mm/slab.c:3815 disk_release+0x215/0x290 block/genhd.c:1233 device_release+0xd7/0x170 drivers/base/core.c:846 kobject_cleanup lib/kobject.c:646 [inline] kobject_release lib/kobject.c:675 [inline] kref_put include/linux/kref.h:70 [inline] kobject_put lib/kobject.c:692 [inline] kobject_put+0x14f/0x3d0 lib/kobject.c:685 put_disk+0x15/0x20 block/genhd.c:1455 __blkdev_get+0x65c/0xff0 fs/block_dev.c:1549 blkdev_get+0x265/0x890 fs/block_dev.c:1611 blkdev_open+0x19f/0x200 fs/block_dev.c:1772 do_dentry_open+0x3e4/0xde0 fs/open.c:777 vfs_open+0xfc/0x240 fs/open.c:888 do_last fs/namei.c:3428 [inline] path_openat+0xb6f/0x2760 fs/namei.c:3569 do_filp_open+0x16b/0x220 fs/namei.c:3603 do_sys_open+0x1d0/0x350 fs/open.c:1081 SYSC_openat fs/open.c:1108 [inline] SyS_openat+0xf/0x20 fs/open.c:1102 do_syscall_64+0x1c7/0x5b0 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x46/0xbb The buggy address belongs to the object at ffff8880b05c0980 which belongs to the cache kmalloc-2048 of size 2048 The buggy address is located 1416 bytes inside of 2048-byte region [ffff8880b05c0980, ffff8880b05c1180) The buggy address belongs to the page: page:ffffea0002c17000 count:1 mapcount:0 mapping:ffff8880b05c0100 index:0x0 compound_mapcount: 0 flags: 0xfff00000008100(slab|head) raw: 00fff00000008100 ffff8880b05c0100 0000000000000000 0000000100000003 raw: ffffea0002c199a0 ffffea0002536ca0 ffff88813fe64c40 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880b05c0e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880b05c0e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8880b05c0f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880b05c0f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880b05c1000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== md: md1 stopped.