syzbot


KASAN: use-after-free Read in get_disk

Status: auto-closed as invalid on 2019/12/06 15:46
Reported-by: syzbot+1128ee090b4b6823d0da@syzkaller.appspotmail.com
First crash: 1064d, last: 1064d
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-414 KASAN: use-after-free Read in get_disk C 48 960d 1181d 0/1 public: reported C repro on 2019/04/13 00:01
android-49 KASAN: use-after-free Read in get_disk 42 959d 1180d 0/3 auto-closed as invalid on 2020/03/20 03:33

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in get_disk+0xc9/0xe0 block/genhd.c:1433
Read of size 8 at addr ffff8880a0a411d0 by task blkid/11890

CPU: 0 PID: 11890 Comm: blkid Not tainted 4.14.137 #33
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+0x138/0x19c lib/dump_stack.c:53
 print_address_description.cold+0x7c/0x1dc 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+0xa9/0x2af mm/kasan/report.c:393
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430
 get_disk+0xc9/0xe0 block/genhd.c:1433
 get_gendisk block/genhd.c:793 [inline]
 get_gendisk+0xf5/0x240 block/genhd.c:778
 __blkdev_get+0x3af/0x1120 fs/block_dev.c:1451
 blkdev_get+0xa8/0x8e0 fs/block_dev.c:1612
 blkdev_open+0x1d1/0x260 fs/block_dev.c:1770
 do_dentry_open+0x73b/0xeb0 fs/open.c:777
 vfs_open+0x105/0x220 fs/open.c:891
 do_last fs/namei.c:3425 [inline]
 path_openat+0x8bd/0x3f70 fs/namei.c:3566
 do_filp_open+0x18e/0x250 fs/namei.c:3600
 do_sys_open+0x2c5/0x430 fs/open.c:1084
 SYSC_open fs/open.c:1102 [inline]
 SyS_open+0x2d/0x40 fs/open.c:1097
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x7f0bf02a1120
RSP: 002b:00007ffd706f8708 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0bf02a1120
RDX: 00007ffd706f9f18 RSI: 0000000000000000 RDI: 00007ffd706f9f18
RBP: 0000000000000000 R08: 0000000000000078 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000001eda030
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000005

Allocated by task 11866:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc mm/kasan/kasan.c:551 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
 kmem_cache_alloc_node_trace+0x153/0x770 mm/slab.c:3661
 kmalloc_node include/linux/slab.h:526 [inline]
 kzalloc_node include/linux/slab.h:672 [inline]
 alloc_disk_node+0x64/0x3e0 block/genhd.c:1387
 alloc_disk+0x1b/0x20 block/genhd.c:1371
 loop_add+0x3e7/0x850 drivers/block/loop.c:1858
 loop_control_ioctl+0x10c/0x2f0 drivers/block/loop.c:1990
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x7ae/0x1060 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 11888:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xcc/0x270 mm/slab.c:3815
 disk_release+0x24b/0x2d0 block/genhd.c:1230
 device_release+0xf6/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.cold+0x269/0x2f9 lib/kobject.c:692
 put_disk+0x23/0x30 block/genhd.c:1452
 __blkdev_get+0x6a6/0x1120 fs/block_dev.c:1570
 blkdev_get+0xa8/0x8e0 fs/block_dev.c:1612
 blkdev_open+0x1d1/0x260 fs/block_dev.c:1770
 do_dentry_open+0x73b/0xeb0 fs/open.c:777
 vfs_open+0x105/0x220 fs/open.c:891
 do_last fs/namei.c:3425 [inline]
 path_openat+0x8bd/0x3f70 fs/namei.c:3566
 do_filp_open+0x18e/0x250 fs/namei.c:3600
 do_sys_open+0x2c5/0x430 fs/open.c:1084
 SYSC_open fs/open.c:1102 [inline]
 SyS_open+0x2d/0x40 fs/open.c:1097
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8880a0a40c80
 which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 1360 bytes inside of
 2048-byte region [ffff8880a0a40c80, ffff8880a0a41480)
The buggy address belongs to the page:
page:ffffea0002829000 count:1 mapcount:0 mapping:ffff8880a0a40400 index:0x0 compound_mapcount: 0
flags: 0x1fffc0000008100(slab|head)
raw: 01fffc0000008100 ffff8880a0a40400 0000000000000000 0000000100000003
raw: ffffea00022a8ea0 ffffea00023837a0 ffff8880aa800c40 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a0a41080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a0a41100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a0a41180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff8880a0a41200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a0a41280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-14 2019/08/08 15:45 linux-4.14.y b19ffe6e7205 bcc419e9 .config log report