KASAN: use-after-free Read in get_disk

22 views
Skip to first unread message

syzbot

unread,
Apr 12, 2019, 8:01:23 PM4/12/19
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 47350a9f ANDROID: x86_64_cuttlefish_defconfig: Enable lz4 ..
git tree: android-4.14
console output: https://syzkaller.appspot.com/x/log.txt?x=17b237bc400000
kernel config: https://syzkaller.appspot.com/x/.config?x=10d236078f3378a3
dashboard link: https://syzkaller.appspot.com/bug?extid=a43ba1cae2dd8edc178c
compiler: gcc (GCC) 8.0.1 20180413 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+a43ba1...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in get_disk+0xb7/0xd0 block/genhd.c:1433
Read of size 8 at addr ffff8801d94f3830 by task blkid/16522

CPU: 1 PID: 16522 Comm: blkid Not tainted 4.14.67+ #1
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0xb9/0x11b lib/dump_stack.c:53
print_address_description+0x60/0x22b mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report.cold.6+0x11b/0x2dd mm/kasan/report.c:409
get_disk+0xb7/0xd0 block/genhd.c:1433
get_gendisk+0xe4/0x230 block/genhd.c:793
__blkdev_get+0x345/0xe50 fs/block_dev.c:1446
blkdev_get+0x97/0x8c0 fs/block_dev.c:1604
blkdev_open+0x1bd/0x240 fs/block_dev.c:1762
do_dentry_open+0x426/0xda0 fs/open.c:764
vfs_open+0x11c/0x210 fs/open.c:878
do_last fs/namei.c:3408 [inline]
path_openat+0x4eb/0x23a0 fs/namei.c:3550
device syz_tun entered promiscuous mode
device syz_tun left promiscuous mode
do_filp_open+0x197/0x270 fs/namei.c:3584
do_sys_open+0x2ef/0x580 fs/open.c:1071
do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x7fa5072a9120
RSP: 002b:00007ffd88683088 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fa5072a9120
RDX: 00007ffd88683f1f RSI: 0000000000000000 RDI: 00007ffd88683f1f
RBP: 0000000000000000 R08: 0000000000000078 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000015ad030
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000005

Allocated by task 16461:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc.part.1+0x4f/0xd0 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x138/0x300 mm/slub.c:2750
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+0x5f/0x3b0 block/genhd.c:1387
loop_add+0x3e9/0x840 drivers/block/loop.c:1827
loop_control_ioctl+0x12e/0x310 drivers/block/loop.c:1959
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:500 [inline]
do_vfs_ioctl+0x1a0/0x1030 fs/ioctl.c:684
SYSC_ioctl fs/ioctl.c:701 [inline]
SyS_ioctl+0x7e/0xb0 fs/ioctl.c:692
do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 2038:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xac/0x190 mm/kasan/kasan.c:524
slab_free_hook mm/slub.c:1389 [inline]
slab_free_freelist_hook mm/slub.c:1410 [inline]
slab_free mm/slub.c:2966 [inline]
kfree+0xf5/0x310 mm/slub.c:3897
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+0x146/0x200 lib/kobject.c:692
put_disk+0x1f/0x30 block/genhd.c:1452
__blkdev_get+0x564/0xe50 fs/block_dev.c:1562
blkdev_get+0x97/0x8c0 fs/block_dev.c:1604
blkdev_open+0x1bd/0x240 fs/block_dev.c:1762
do_dentry_open+0x426/0xda0 fs/open.c:764
vfs_open+0x11c/0x210 fs/open.c:878
do_last fs/namei.c:3408 [inline]
path_openat+0x4eb/0x23a0 fs/namei.c:3550
do_filp_open+0x197/0x270 fs/namei.c:3584
do_sys_open+0x2ef/0x580 fs/open.c:1071
do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8801d94f3300
which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 1328 bytes inside of
2048-byte region [ffff8801d94f3300, ffff8801d94f3b00)
The buggy address belongs to the page:
page:ffffea0007653c00 count:1 mapcount:0 mapping: (null) index:0x0
compound_mapcount: 0
flags: 0x4000000000008100(slab|head)
raw: 4000000000008100 0000000000000000 0000000000000000 00000001000f000f
raw: 0000000000000000 0000000b00000001 ffff8801da802800 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801d94f3700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d94f3780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8801d94f3800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8801d94f3880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d94f3900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Apr 14, 2019, 5:30:12 AM4/14/19
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 132f097f ANDROID: sdcardfs: Set s_root to NULL after putting
git tree: android-4.9
console output: https://syzkaller.appspot.com/x/log.txt?x=17b8a847800000
kernel config: https://syzkaller.appspot.com/x/.config?x=a54f56879744de40
dashboard link: https://syzkaller.appspot.com/bug?extid=42498191c906088d4e71
compiler: gcc (GCC) 8.0.1 20180413 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+424981...@syzkaller.appspotmail.com

loop0: p1
==================================================================
BUG: KASAN: use-after-free in get_disk+0xc2/0xd0 block/genhd.c:1339
Read of size 8 at addr ffff8801d6e39ea8 by task blkid/14175

CPU: 0 PID: 14175 Comm: blkid Not tainted 4.9.96-g132f097 #9
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
ffff88019a0b7698 ffffffff81eb0b69 ffffea00075b8e00 ffff8801d6e39ea8
0000000000000000 ffff8801d6e39ea8 0000000000000000 ffff88019a0b76d0
ffffffff8156540b ffff8801d6e39ea8 0000000000000008 0000000000000000
Call Trace:
[<ffffffff81eb0b69>] __dump_stack lib/dump_stack.c:15 [inline]
[<ffffffff81eb0b69>] dump_stack+0xc1/0x128 lib/dump_stack.c:51
[<ffffffff8156540b>] print_address_description+0x6c/0x234
mm/kasan/report.c:256
[<ffffffff81565815>] kasan_report_error mm/kasan/report.c:355 [inline]
[<ffffffff81565815>] kasan_report.cold.6+0x242/0x2fe mm/kasan/report.c:412
[<ffffffff81539494>] __asan_report_load8_noabort+0x14/0x20
mm/kasan/report.c:433
[<ffffffff81e57832>] get_disk+0xc2/0xd0 block/genhd.c:1339
[<ffffffff81e57b4a>] get_gendisk+0x16a/0x2d0 block/genhd.c:724
[<ffffffff8162ec81>] __blkdev_get+0x351/0xd60 fs/block_dev.c:1262
[<ffffffff81631f2a>] blkdev_get+0x2da/0x920 fs/block_dev.c:1416
[<ffffffff81632785>] blkdev_open+0x1a5/0x250 fs/block_dev.c:1571
[<ffffffff81567583>] do_dentry_open+0x703/0xc80 fs/open.c:766
[<ffffffff8156ad6c>] vfs_open+0x11c/0x210 fs/open.c:879
[<ffffffff815a1ea8>] do_last fs/namei.c:3410 [inline]
[<ffffffff815a1ea8>] path_openat+0x758/0x3590 fs/namei.c:3534
[<ffffffff815a8fa7>] do_filp_open+0x197/0x270 fs/namei.c:3568
[<ffffffff8156b77d>] do_sys_open+0x30d/0x5c0 fs/open.c:1072
[<ffffffff8156ba5d>] SYSC_open fs/open.c:1090 [inline]
[<ffffffff8156ba5d>] SyS_open+0x2d/0x40 fs/open.c:1085
[<ffffffff81006316>] do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
[<ffffffff839f3313>] entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Allocated by task 10220:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
save_stack+0x43/0xd0 mm/kasan/kasan.c:505
set_track mm/kasan/kasan.c:517 [inline]
kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:609
kmem_cache_alloc_trace+0xfd/0x2b0 mm/slub.c:2742
kmem_cache_alloc_node_trace include/linux/slab.h:381 [inline]
kmalloc_node include/linux/slab.h:528 [inline]
kzalloc_node include/linux/slab.h:647 [inline]
alloc_disk_node+0x54/0x3a0 block/genhd.c:1294
alloc_disk+0x18/0x20 block/genhd.c:1286
loop_add+0x33b/0x770 drivers/block/loop.c:1782
loop_probe+0x14f/0x180 drivers/block/loop.c:1889
kobj_lookup+0x223/0x410 drivers/base/map.c:124
get_gendisk+0x39/0x2d0 block/genhd.c:716
__blkdev_get+0x351/0xd60 fs/block_dev.c:1262
blkdev_get+0x2da/0x920 fs/block_dev.c:1416
blkdev_open+0x1a5/0x250 fs/block_dev.c:1571
do_dentry_open+0x703/0xc80 fs/open.c:766
vfs_open+0x11c/0x210 fs/open.c:879
do_last fs/namei.c:3410 [inline]
path_openat+0x758/0x3590 fs/namei.c:3534
do_filp_open+0x197/0x270 fs/namei.c:3568
do_sys_open+0x30d/0x5c0 fs/open.c:1072
SYSC_open fs/open.c:1090 [inline]
SyS_open+0x2d/0x40 fs/open.c:1085
do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Freed by task 10220:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
save_stack+0x43/0xd0 mm/kasan/kasan.c:505
set_track mm/kasan/kasan.c:517 [inline]
kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:582
slab_free_hook mm/slub.c:1355 [inline]
slab_free_freelist_hook mm/slub.c:1377 [inline]
slab_free mm/slub.c:2958 [inline]
kfree+0xfb/0x310 mm/slub.c:3878
disk_release+0x259/0x330 block/genhd.c:1147
device_release+0x7e/0x220 drivers/base/core.c:247
kobject_cleanup lib/kobject.c:645 [inline]
kobject_release+0x103/0x1b0 lib/kobject.c:674
kref_sub include/linux/kref.h:73 [inline]
kref_put include/linux/kref.h:98 [inline]
kobject_put+0x6d/0xd0 lib/kobject.c:691
put_disk+0x23/0x30 block/genhd.c:1358
__blkdev_get+0x57d/0xd60 fs/block_dev.c:1374
blkdev_get+0x2da/0x920 fs/block_dev.c:1416
blkdev_open+0x1a5/0x250 fs/block_dev.c:1571
do_dentry_open+0x703/0xc80 fs/open.c:766
vfs_open+0x11c/0x210 fs/open.c:879
do_last fs/namei.c:3410 [inline]
path_openat+0x758/0x3590 fs/namei.c:3534
do_filp_open+0x197/0x270 fs/namei.c:3568
do_sys_open+0x30d/0x5c0 fs/open.c:1072
SYSC_open fs/open.c:1090 [inline]
SyS_open+0x2d/0x40 fs/open.c:1085
do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
entry_SYSCALL_64_after_swapgs+0x5d/0xdb

The buggy address belongs to the object at ffff8801d6e39980
which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 1320 bytes inside of
2048-byte region [ffff8801d6e39980, ffff8801d6e3a180)
The buggy address belongs to the page:
page:ffffea00075b8e00 count:1 mapcount:0 mapping: (null) index:0x0
compound_mapcount: 0
flags: 0x8000000000004080(slab|head)
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801d6e39d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d6e39e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8801d6e39e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8801d6e39f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d6e39f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

syzbot

unread,
Apr 16, 2019, 4:14:06 PM4/16/19
to syzkaller-a...@googlegroups.com
syzbot has found a reproducer for the following crash on:

HEAD commit: efe83653 Revert "CHROMIUM: dm: boot time specification of ..
git tree: android-4.14
console output: https://syzkaller.appspot.com/x/log.txt?x=1389995b200000
kernel config: https://syzkaller.appspot.com/x/.config?x=19963a41b6ae10e6
dashboard link: https://syzkaller.appspot.com/bug?extid=a43ba1cae2dd8edc178c
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10dc598f200000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11f0b5bf200000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+a43ba1...@syzkaller.appspotmail.com

random: sshd: uninitialized urandom read (32 bytes read)
audit: type=1400 audit(1555445329.679:7): avc: denied { map } for
pid=1800 comm="syz-executor908" path="/root/syz-executor908997611"
dev="sda1" ino=16481 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
==================================================================
BUG: KASAN: use-after-free in get_disk+0xc0/0xd0 block/genhd.c:1433
Read of size 8 at addr ffff8881cf4d1eb0 by task blkid/1806

CPU: 1 PID: 1806 Comm: blkid Not tainted 4.14.111+ #54
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0xb9/0x10e lib/dump_stack.c:53
print_address_description+0x60/0x226 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+0x88/0x2a5 mm/kasan/report.c:393

Allocated by task 1801:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc.part.0+0x4f/0xd0 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x126/0x310 mm/slub.c:2750
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

Freed by task 1803:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xb0/0x190 mm/kasan/kasan.c:524
slab_free_hook mm/slub.c:1389 [inline]
slab_free_freelist_hook mm/slub.c:1410 [inline]
slab_free mm/slub.c:2966 [inline]
kfree+0xf5/0x310 mm/slub.c:3897
device_release+0xf4/0x1a0 drivers/base/core.c:822

The buggy address belongs to the object at ffff8881cf4d1980
which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 1328 bytes inside of
2048-byte region [ffff8881cf4d1980, ffff8881cf4d2180)
The buggy address belongs to the page:
page:ffffea00073d3400 count:1 mapcount:0 mapping: (null) index:0x0
compound_mapcount: 0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 0000000000000000 0000000000000000 00000001800f000f
raw: dead000000000100 dead000000000200 ffff8881da802800 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8881cf4d1d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881cf4d1e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8881cf4d1e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881cf4d1f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881cf4d1f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

syzbot

unread,
Mar 19, 2020, 11:33:09 PM3/19/20
to syzkaller-a...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages