lkml.org 
[lkml]   [2022]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectKASAN: use-after-free Read in io_iopoll_getevents
Hi,

We would like to report the following bug which has been found by our
modified version of syzkaller.

======================================================
description: KASAN: use-after-free Read in io_iopoll_getevents
affected file: fs/io_uring.c
kernel version: 5.7
kernel commit: 3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162
git tree: upstream
kernel config: attached
crash reproducer: none
======================================================
Crash log:

BUG: KASAN: use-after-free in io_do_iopoll fs/io_uring.c:1755 [inline]
BUG: KASAN: use-after-free in io_iopoll_getevents+0xa02/0xad0 fs/io_uring.c:1806
Read of size 8 at addr ffff8880922b7498 by task syz-executor.0/10124

CPU: 1 PID: 10124 Comm: syz-executor.0 Tainted: G OE 5.7.0+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.13.0-1ubuntu1.1 04/01/2014
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1a4/0x21d lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xd3/0x413 mm/kasan/report.c:382
__kasan_report.cold+0x20/0x38 mm/kasan/report.c:511
kasan_report+0x3c/0x50 mm/kasan/common.c:637
io_do_iopoll fs/io_uring.c:1755 [inline]
io_iopoll_getevents+0xa02/0xad0 fs/io_uring.c:1806
io_iopoll_reap_events.part.0+0xce/0x150 fs/io_uring.c:1829
io_iopoll_reap_events fs/io_uring.c:1822 [inline]
io_ring_ctx_wait_and_kill+0x381/0x5f0 fs/io_uring.c:7331
io_uring_release+0x42/0x50 fs/io_uring.c:7345
__fput+0x33c/0x880 fs/file_table.c:280
task_work_run+0xf8/0x1b0 kernel/task_work.c:123
exit_task_work include/linux/task_work.h:22 [inline]
do_exit+0xb9f/0x3020 kernel/exit.c:798
do_group_exit+0x129/0x320 kernel/exit.c:896
get_signal+0x47f/0x2740 kernel/signal.c:2739
do_signal+0x86/0x2110 arch/x86/kernel/signal.c:784
exit_to_usermode_loop+0x26c/0x380 arch/x86/entry/common.c:161
prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline]
syscall_return_slowpath arch/x86/entry/common.c:279 [inline]
do_syscall_64+0x6f9/0x830 arch/x86/entry/common.c:305
entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x7f5f1ee634ed
Code: Bad RIP value.
RSP: 002b:00007f5f1ce13c98 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00007f5f1ef81f68 RCX: 00007f5f1ee634ed
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007f5f1ef81f68
RBP: 00007f5f1ef81f60 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5f1ef81f6c
R13: 00007ffdc6440acf R14: 00007ffdc6440c70 R15: 00007f5f1ce13d80

Allocated by task 10124:
save_stack+0x1b/0x40 mm/kasan/common.c:50
set_track mm/kasan/common.c:58 [inline]
__kasan_kmalloc.constprop.0+0xd0/0xe0 mm/kasan/common.c:507
slab_post_alloc_hook mm/slab.h:586 [inline]
slab_alloc mm/slab.c:3320 [inline]
kmem_cache_alloc+0x120/0x4d0 mm/slab.c:3484
io_alloc_req fs/io_uring.c:1306 [inline]
io_submit_sqes+0x1826/0x2950 fs/io_uring.c:5884
__do_sys_io_uring_enter fs/io_uring.c:7533 [inline]
__se_sys_io_uring_enter fs/io_uring.c:7491 [inline]
__x64_sys_io_uring_enter+0x80c/0xbd0 fs/io_uring.c:7491
do_syscall_64+0xfa/0x830 arch/x86/entry/common.c:295
entry_SYSCALL_64_after_hwframe+0x49/0xb3

Freed by task 10141:
save_stack+0x1b/0x40 mm/kasan/common.c:50
set_track mm/kasan/common.c:58 [inline]
kasan_set_free_info mm/kasan/common.c:318 [inline]
__kasan_slab_free+0x103/0x150 mm/kasan/common.c:462
__cache_free mm/slab.c:3426 [inline]
kmem_cache_free+0x83/0x390 mm/slab.c:3694
__io_free_req+0x22f/0x600 fs/io_uring.c:1378
io_free_req+0x77/0xd0 fs/io_uring.c:1551
io_put_req+0x72/0xa0 fs/io_uring.c:1597
io_worker_handle_work+0xcbe/0x1710 fs/io-wq.c:540
io_wqe_worker+0xcf3/0x12c0 fs/io-wq.c:576
kthread+0x390/0x470 kernel/kthread.c:268
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:351

The buggy address belongs to the object at ffff8880922b7440
which belongs to the cache io_kiocb of size 240
The buggy address is located 88 bytes inside of
240-byte region [ffff8880922b7440, ffff8880922b7530)
The buggy address belongs to the page:
page:ffffea000248adc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffff8881114ea550 ffffea00026a9848 ffff88811166ac40
raw: 0000000000000000 ffff8880922b7080 000000010000000c 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880922b7380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc
ffff8880922b7400: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff8880922b7480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880922b7500: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc
ffff8880922b7580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

--
Thanks & Regards,

Dipanjan
[unhandled content-type:application/octet-stream]
\
 
 \ /
  Last update: 2022-07-18 00:57    [W:0.051 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site