KASAN: use-after-free Read in blkcg_print_stat

4 views
Skip to first unread message

syzbot

unread,
Nov 18, 2019, 6:06:09 AM11/18/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: c555efaf Linux 4.19.84
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16f26426e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=9140f2df4ddc6016
dashboard link: https://syzkaller.appspot.com/bug?extid=b456d536d14f592c8b28
compiler: gcc (GCC) 9.0.0 20181231 (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+b456d5...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in dev_name include/linux/device.h:1056 [inline]
BUG: KASAN: use-after-free in blkg_dev_name block/blk-cgroup.c:477 [inline]
BUG: KASAN: use-after-free in blkcg_print_stat+0xc44/0xd20
block/blk-cgroup.c:963
Read of size 8 at addr ffff8880527d22d0 by task syz-executor.3/26084

CPU: 0 PID: 26084 Comm: syz-executor.3 Not tainted 4.19.84 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x197/0x210 lib/dump_stack.c:118
print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
kasan_report_error mm/kasan/report.c:354 [inline]
kasan_report mm/kasan/report.c:412 [inline]
kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
dev_name include/linux/device.h:1056 [inline]
blkg_dev_name block/blk-cgroup.c:477 [inline]
blkcg_print_stat+0xc44/0xd20 block/blk-cgroup.c:963
cgroup_seqfile_show+0x1a8/0x300 kernel/cgroup/cgroup.c:3516
kernfs_seq_show+0x14f/0x1b0 fs/kernfs/file.c:168
seq_read+0x4ca/0x1110 fs/seq_file.c:229
kernfs_fop_read+0xed/0x560 fs/kernfs/file.c:252
do_loop_readv_writev fs/read_write.c:701 [inline]
do_loop_readv_writev fs/read_write.c:688 [inline]
do_iter_read+0x490/0x640 fs/read_write.c:925
vfs_readv+0xf0/0x160 fs/read_write.c:987
do_readv+0x15e/0x370 fs/read_write.c:1020
__do_sys_readv fs/read_write.c:1107 [inline]
__se_sys_readv fs/read_write.c:1104 [inline]
__x64_sys_readv+0x75/0xb0 fs/read_write.c:1104
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45a639
Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
ff 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f7897911c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000013
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045a639
RDX: 00000000000003a9 RSI: 00000000200002c0 RDI: 0000000000000006
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f78979126d4
R13: 00000000004c7ecd R14: 00000000004de160 R15: 00000000ffffffff

Allocated by task 7560:
save_stack+0x45/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
kasan_kmalloc mm/kasan/kasan.c:553 [inline]
kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
kmem_cache_alloc_trace+0x152/0x760 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
kzalloc include/linux/slab.h:709 [inline]
device_create_groups_vargs+0x8e/0x270 drivers/base/core.c:2585
device_create_vargs+0x45/0x60 drivers/base/core.c:2643
bdi_register_va.part.0+0x38/0x740 mm/backing-dev.c:882
bdi_register_va mm/backing-dev.c:910 [inline]
bdi_register+0x12a/0x140 mm/backing-dev.c:907
bdi_register_owner+0x61/0x100 mm/backing-dev.c:917
__device_add_disk+0xcd8/0x10c0 block/genhd.c:707
device_add_disk+0x23/0x30 block/genhd.c:729
add_disk include/linux/genhd.h:408 [inline]
loop_add+0x650/0x8d0 drivers/block/loop.c:2015
loop_probe+0x161/0x1a0 drivers/block/loop.c:2087
kobj_lookup+0x260/0x460 drivers/base/map.c:124
get_gendisk+0x4d/0x380 block/genhd.c:844
bdev_get_gendisk fs/block_dev.c:1080 [inline]
__blkdev_get+0x457/0x1660 fs/block_dev.c:1466
blkdev_get+0xc4/0x990 fs/block_dev.c:1625
blkdev_open+0x205/0x290 fs/block_dev.c:1783
do_dentry_open+0x4c3/0x1210 fs/open.c:796
vfs_open+0xa0/0xd0 fs/open.c:905
do_last fs/namei.c:3418 [inline]
path_openat+0x10d7/0x45e0 fs/namei.c:3534
do_filp_open+0x1a1/0x280 fs/namei.c:3564
do_sys_open+0x3fe/0x550 fs/open.c:1088
__do_sys_open fs/open.c:1106 [inline]
__se_sys_open fs/open.c:1101 [inline]
__x64_sys_open+0x7e/0xc0 fs/open.c:1101
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 26104:
save_stack+0x45/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
__kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
__cache_free mm/slab.c:3503 [inline]
kfree+0xcf/0x220 mm/slab.c:3822
device_create_release+0x16/0x20 drivers/base/cpu.c:409
device_release+0x7b/0x210 drivers/base/core.c:892
kobject_cleanup lib/kobject.c:662 [inline]
kobject_release lib/kobject.c:691 [inline]
kref_put include/linux/kref.h:70 [inline]
kobject_put.cold+0x289/0x2e6 lib/kobject.c:708
put_device drivers/base/core.c:2082 [inline]
device_unregister+0x28/0x30 drivers/base/core.c:2194
bdi_unregister+0x46e/0x650 mm/backing-dev.c:949
del_gendisk+0x84d/0xaf0 block/genhd.c:776
loop_remove+0x3c/0xd0 drivers/block/loop.c:2033
loop_control_ioctl drivers/block/loop.c:2132 [inline]
loop_control_ioctl+0x320/0x360 drivers/block/loop.c:2098
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0xd5f/0x1380 fs/ioctl.c:688
ksys_ioctl+0xab/0xd0 fs/ioctl.c:705
__do_sys_ioctl fs/ioctl.c:712 [inline]
__se_sys_ioctl fs/ioctl.c:710 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:710
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880527d2280
which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 80 bytes inside of
2048-byte region [ffff8880527d2280, ffff8880527d2a80)
The buggy address belongs to the page:
page:ffffea000149f480 count:1 mapcount:0 mapping:ffff88812c3f0c40
index:0xffff8880527d3380 compound_mapcount: 0
flags: 0x1fffc0000008100(slab|head)
raw: 01fffc0000008100 ffffea00021b1108 ffffea000146b808 ffff88812c3f0c40
raw: ffff8880527d3380 ffff8880527d2280 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880527d2180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880527d2200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8880527d2280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880527d2300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880527d2380: 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,
Mar 17, 2020, 6:06:11 AM3/17/20
to syzkaller...@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