================================================================== BUG: KASAN: use-after-free in disk_unblock_events+0x4b/0x50 block/genhd.c:1644 Read of size 8 at addr ffff88819d3c9668 by task blkid/23437 CPU: 0 PID: 23437 Comm: blkid Not tainted 4.14.143+ #0 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0xca/0x134 lib/dump_stack.c:53 print_address_description+0x60/0x226 mm/kasan/report.c:187 __kasan_report.cold+0x1a/0x41 mm/kasan/report.c:316 disk_unblock_events+0x4b/0x50 block/genhd.c:1644 __blkdev_get+0x68f/0xf90 fs/block_dev.c:1556 blkdev_get+0x97/0x8b0 fs/block_dev.c:1612 blkdev_open+0x1cc/0x250 fs/block_dev.c:1770 do_dentry_open+0x44e/0xe20 fs/open.c:789 vfs_open+0x105/0x230 fs/open.c:903 do_last fs/namei.c:3539 [inline] path_openat+0xb6c/0x2be0 fs/namei.c:3681 do_filp_open+0x1a1/0x280 fs/namei.c:3715 do_sys_open+0x2ca/0x590 fs/open.c:1096 do_syscall_64+0x19b/0x520 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x7f610a03c120 RSP: 002b:00007fffc04c1278 EFLAGS: 00000246 ORIG_RAX: 0000000000000002 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f610a03c120 RDX: 00007fffc04c1f34 RSI: 0000000000000000 RDI: 00007fffc04c1f34 RBP: 0000000000000000 R08: 0000000000000078 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000023fb030 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000005 Allocated by task 23437: save_stack mm/kasan/common.c:76 [inline] set_track mm/kasan/common.c:85 [inline] __kasan_kmalloc.part.0+0x53/0xc0 mm/kasan/common.c:495 kmem_cache_alloc_node_trace include/linux/slab.h:378 [inline] kmalloc_node include/linux/slab.h:526 [inline] kzalloc_node include/linux/slab.h:672 [inline] alloc_disk_node+0x5b/0x3d0 block/genhd.c:1387 loop_add+0x3ee/0x870 drivers/block/loop.c:1858 loop_probe+0x153/0x180 drivers/block/loop.c:1965 kobj_lookup+0x226/0x410 drivers/base/map.c:124 get_gendisk+0x36/0x240 block/genhd.c:785 __blkdev_get+0x345/0xf90 fs/block_dev.c:1451 blkdev_get+0x97/0x8b0 fs/block_dev.c:1612 blkdev_open+0x1cc/0x250 fs/block_dev.c:1770 do_dentry_open+0x44e/0xe20 fs/open.c:789 vfs_open+0x105/0x230 fs/open.c:903 do_last fs/namei.c:3539 [inline] path_openat+0xb6c/0x2be0 fs/namei.c:3681 do_filp_open+0x1a1/0x280 fs/namei.c:3715 do_sys_open+0x2ca/0x590 fs/open.c:1096 do_syscall_64+0x19b/0x520 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x42/0xb7 0xffffffffffffffff Freed by task 23437: save_stack mm/kasan/common.c:76 [inline] set_track mm/kasan/common.c:85 [inline] __kasan_slab_free+0x164/0x210 mm/kasan/common.c:457 slab_free_hook mm/slub.c:1407 [inline] slab_free_freelist_hook mm/slub.c:1458 [inline] slab_free mm/slub.c:3039 [inline] kfree+0x108/0x3a0 mm/slub.c:3976 device_release+0xf4/0x1a0 drivers/base/core.c:822 kobject_cleanup lib/kobject.c:646 [inline] kobject_release lib/kobject.c:675 [inline] kref_put include/linux/kref.h:70 [inline] kobject_put+0x142/0x200 lib/kobject.c:692 put_disk+0x1f/0x30 block/genhd.c:1452 __blkdev_get+0x5fa/0xf90 fs/block_dev.c:1549 blkdev_get+0x97/0x8b0 fs/block_dev.c:1612 blkdev_open+0x1cc/0x250 fs/block_dev.c:1770 do_dentry_open+0x44e/0xe20 fs/open.c:789 vfs_open+0x105/0x230 fs/open.c:903 do_last fs/namei.c:3539 [inline] path_openat+0xb6c/0x2be0 fs/namei.c:3681 do_filp_open+0x1a1/0x280 fs/namei.c:3715 do_sys_open+0x2ca/0x590 fs/open.c:1096 do_syscall_64+0x19b/0x520 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x42/0xb7 0xffffffffffffffff The buggy address belongs to the object at ffff88819d3c9100 which belongs to the cache kmalloc-2048 of size 2048 The buggy address is located 1384 bytes inside of 2048-byte region [ffff88819d3c9100, ffff88819d3c9900) The buggy address belongs to the page: page:ffffea000674f200 count:1 mapcount:0 mapping: (null) index:0x0 compound_mapcount: 0 flags: 0x4000000000010200(slab|head) raw: 4000000000010200 0000000000000000 0000000000000000 00000001000f000f raw: ffffea000764d400 0000000500000005 ffff8881da802800 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88819d3c9500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88819d3c9580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88819d3c9600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88819d3c9680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88819d3c9700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================