syzbot


KASAN: invalid-free in io_req_caches_free

Status: fixed on 2021/04/09 19:46
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+30b4936dcdb3aafa4fb4@syzkaller.appspotmail.com
Fix commit: 8e5c66c485a8 io_uring: clear request count when freeing caches
First crash: 1331d, last: 1328d
Discussions (3)
Title Replies (including bot) Last reply
Re: KASAN: invalid-free in io_req_caches_free 1 (1) 2021/02/23 02:35
[PATCH] io_uring: double freeing req caches 2 (2) 2021/02/22 13:32
KASAN: invalid-free in io_req_caches_free 0 (1) 2021/02/22 09:44

Sample crash report:
==================================================================
BUG: KASAN: double-free or invalid-free in io_req_caches_free.constprop.0+0x3ce/0x530 fs/io_uring.c:8709

CPU: 1 PID: 9898 Comm: kworker/u4:6 Not tainted 5.11.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events_unbound io_ring_exit_work
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0xfa/0x151 lib/dump_stack.c:120
 print_address_description.constprop.0.cold+0x5b/0x2c6 mm/kasan/report.c:230
 kasan_report_invalid_free+0x51/0x80 mm/kasan/report.c:355
 ____kasan_slab_free+0xcc/0xe0 mm/kasan/common.c:341
 kasan_slab_free include/linux/kasan.h:192 [inline]
 __cache_free mm/slab.c:3424 [inline]
 kmem_cache_free_bulk+0x4b/0x1b0 mm/slab.c:3744
 io_req_caches_free.constprop.0+0x3ce/0x530 fs/io_uring.c:8709
 io_ring_ctx_free fs/io_uring.c:8764 [inline]
 io_ring_exit_work+0x518/0x6b0 fs/io_uring.c:8846
 process_one_work+0x98d/0x1600 kernel/workqueue.c:2275
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
 kthread+0x3b1/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

Allocated by task 17115:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:401 [inline]
 ____kasan_kmalloc.constprop.0+0x7f/0xa0 mm/kasan/common.c:429
 kasan_slab_alloc include/linux/kasan.h:209 [inline]
 slab_post_alloc_hook mm/slab.h:512 [inline]
 kmem_cache_alloc_bulk+0x2c2/0x460 mm/slab.c:3534
 io_alloc_req fs/io_uring.c:2014 [inline]
 io_submit_sqes+0x18e8/0x2b60 fs/io_uring.c:6915
 __do_sys_io_uring_enter+0x1154/0x1f50 fs/io_uring.c:9454
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 17115:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:356
 ____kasan_slab_free+0xb0/0xe0 mm/kasan/common.c:362
 kasan_slab_free include/linux/kasan.h:192 [inline]
 __cache_free mm/slab.c:3424 [inline]
 kmem_cache_free_bulk+0x4b/0x1b0 mm/slab.c:3744
 io_req_caches_free.constprop.0+0x3ce/0x530 fs/io_uring.c:8709
 io_uring_flush+0x483/0x6e0 fs/io_uring.c:9237
 filp_close+0xb4/0x170 fs/open.c:1295
 close_files fs/file.c:403 [inline]
 put_files_struct fs/file.c:418 [inline]
 put_files_struct+0x1d0/0x350 fs/file.c:415
 exit_files+0x7e/0xa0 fs/file.c:435
 do_exit+0xc27/0x2ae0 kernel/exit.c:820
 do_group_exit+0x125/0x310 kernel/exit.c:922
 get_signal+0x42c/0x2100 kernel/signal.c:2773
 arch_do_signal_or_restart+0x2a8/0x1eb0 arch/x86/kernel/signal.c:811
 handle_signal_work kernel/entry/common.c:147 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
 exit_to_user_mode_prepare+0x148/0x250 kernel/entry/common.c:208
 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
 syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff888075506480
 which belongs to the cache io_kiocb of size 208
The buggy address is located 0 bytes inside of
 208-byte region [ffff888075506480, ffff888075506550)
The buggy address belongs to the page:
page:00000000af6ecafb refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x75506
flags: 0xfff00000000200(slab)
raw: 00fff00000000200 ffffea00004a4f08 ffffea000070a188 ffff88801899da00
raw: 0000000000000000 ffff8880755060c0 000000010000000c 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888075506380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888075506400: fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888075506480: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff888075506500: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc
 ffff888075506580: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/02/25 05:16 upstream 719bbd4a509f fcc6d71b .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: invalid-free in io_req_caches_free
2021/02/24 08:46 upstream c03c21ba6f4e fcc6d71b .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: invalid-free in io_req_caches_free
2021/02/22 22:42 upstream a99163e9e708 c26fb06b .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: invalid-free in io_req_caches_free
2021/02/22 15:52 upstream 31caf8b2a847 a659b3f1 .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: invalid-free in io_req_caches_free
2021/02/22 09:15 upstream 31caf8b2a847 a659b3f1 .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: invalid-free in io_req_caches_free
* Struck through repros no longer work on HEAD.