syzbot


KASAN: use-after-free Read in loop_queue_work

Status: auto-closed as invalid on 2021/09/23 06:11
Reported-by: syzbot+604b89acbfbcefd63729@syzkaller.appspotmail.com
First crash: 1065d, last: 1065d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in lo_write_simple drivers/block/loop.c:295 [inline]
BUG: KASAN: use-after-free in do_req_filebacked drivers/block/loop.c:619 [inline]
BUG: KASAN: use-after-free in loop_handle_cmd drivers/block/loop.c:1926 [inline]
BUG: KASAN: use-after-free in loop_queue_work+0x204f/0x20c0 drivers/block/loop.c:1940
Read of size 4 at addr ffff8880001100b0 by task loop2/7344

CPU: 0 PID: 7344 Comm: loop2 Not tainted 4.19.191-syzkaller #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+0x1fc/0x2ef lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_load4_noabort+0x88/0x90 mm/kasan/report.c:432
 lo_write_simple drivers/block/loop.c:295 [inline]
 do_req_filebacked drivers/block/loop.c:619 [inline]
 loop_handle_cmd drivers/block/loop.c:1926 [inline]
 loop_queue_work+0x204f/0x20c0 drivers/block/loop.c:1940
 kthread_worker_fn+0x292/0x730 kernel/kthread.c:700
 kthread+0x33f/0x460 kernel/kthread.c:259
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

Allocated by task 8126:
 kmem_cache_alloc+0x122/0x370 mm/slab.c:3559
 mempool_alloc+0x146/0x350 mm/mempool.c:385
 bio_alloc_bioset+0x389/0x5e0 block/bio.c:489
 bio_alloc include/linux/bio.h:437 [inline]
 blkdev_issue_flush+0xcc/0x2f0 block/blk-flush.c:559
 ext4_sync_fs+0x51a/0x8d0 fs/ext4/super.c:5157
 __sync_filesystem fs/sync.c:39 [inline]
 sync_filesystem+0x1b5/0x250 fs/sync.c:67
 generic_shutdown_super+0x70/0x370 fs/super.c:442
 kill_block_super+0x97/0xf0 fs/super.c:1185
 deactivate_locked_super+0x94/0x160 fs/super.c:329
 deactivate_super+0x174/0x1a0 fs/super.c:360
 cleanup_mnt+0x1a8/0x290 fs/namespace.c:1098
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:193 [inline]
 exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
 do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 7344:
 __cache_free mm/slab.c:3503 [inline]
 kmem_cache_free+0x7f/0x260 mm/slab.c:3765
 mempool_free+0xe3/0x370 mm/mempool.c:494
 bio_free+0xee/0x140 block/bio.c:267
 bio_put+0x55/0x80 block/bio.c:561
 bio_endio+0x488/0x830 block/bio.c:1780
 req_bio_endio block/blk-core.c:278 [inline]
 blk_update_request+0x30f/0xaf0 block/blk-core.c:3112
 blk_mq_end_request+0x4a/0x340 block/blk-mq.c:544
 lo_complete_rq+0x201/0x2d0 drivers/block/loop.c:487
 __blk_mq_complete_request block/blk-mq.c:583 [inline]
 blk_mq_complete_request+0x472/0x660 block/blk-mq.c:620
 loop_handle_cmd drivers/block/loop.c:1931 [inline]
 loop_queue_work+0x274/0x20c0 drivers/block/loop.c:1940
 kthread_worker_fn+0x292/0x730 kernel/kthread.c:700
 kthread+0x33f/0x460 kernel/kthread.c:259
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

The buggy address belongs to the object at ffff888000110080
 which belongs to the cache bio-0 of size 216
The buggy address is located 48 bytes inside of
 216-byte region [ffff888000110080, ffff888000110158)
The buggy address belongs to the page:
page:ffffea0000004400 count:1 mapcount:0 mapping:ffff8880b2dd8480 index:0x0
flags: 0x7ff00000000100(slab)
raw: 007ff00000000100 ffffea0000dbfc08 ffffea0000f15408 ffff8880b2dd8480
raw: 0000000000000000 ffff888000110080 000000010000000c 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88800010ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888000110000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888000110080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                     ^
 ffff888000110100: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc
 ffff888000110180: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/05/26 06:10 linux-4.19.y 1e986fe9ad15 93d3a9f6 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in loop_queue_work
* Struck through repros no longer work on HEAD.