================================================================== BUG: KASAN: use-after-free in disk_unblock_events+0x4b/0x50 block/genhd.c:1644 Read of size 8 at addr ffff88819a971668 by task blkid/8961 CPU: 0 PID: 8961 Comm: blkid Not tainted 4.14.141+ #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:0x7f033bdaf120 RSP: 002b:00007fff033da8f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000002 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f033bdaf120 RDX: 00007fff033dcf41 RSI: 0000000000000000 RDI: 00007fff033dcf41 RBP: 0000000000000000 R08: 0000000000000078 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000021be030 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000005 Allocated by task 8796: 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_control_ioctl+0x130/0x310 drivers/block/loop.c:1990 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:500 [inline] do_vfs_ioctl+0xabe/0x1040 fs/ioctl.c:684 SYSC_ioctl fs/ioctl.c:701 [inline] SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692 do_syscall_64+0x19b/0x520 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x42/0xb7 0xffffffffffffffff Freed by task 8961: 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 ffff88819a971100 which belongs to the cache kmalloc-2048 of size 2048 The buggy address is located 1384 bytes inside of 2048-byte region [ffff88819a971100, ffff88819a971900) The buggy address belongs to the page: page:ffffea00066a5c00 count:1 mapcount:0 mapping: (null) index:0x0 compound_mapcount: 0 flags: 0x4000000000010200(slab|head) raw: 4000000000010200 0000000000000000 ffff88819a976600 00000001800f000e raw: ffffea0007107c00 0000000200000002 ffff8881d6402800 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88819a971500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88819a971580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88819a971600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88819a971680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88819a971700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================