syzbot


KASAN: slab-out-of-bounds Read in io_uring_show_fdinfo

Status: upstream: reported C repro on 2022/10/10 07:15
Reported-by: syzbot+e5198737e8a2d23d958c@syzkaller.appspotmail.com
Fix commit: 00927931cb63 io_uring: fix fdinfo sqe offsets calculation
Patched on: [ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm32 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-arm64 ci-upstream-gce-leak ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-kmsan-gce ci-upstream-kmsan-gce-386 ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-fs ci2-upstream-kcsan-gce ci2-upstream-usb], missing on: [ci-qemu2-riscv64]
First crash: 120d, last: 113d

Cause bisection: introduced by (bisect log) :
commit 3b8fdd1dc35e395d19efbc8391a809a5b954ecf4
Author: Jens Axboe <axboe@kernel.dk>
Date: Sun Sep 11 12:40:37 2022 +0000

  io_uring/fdinfo: fix sqe dumping for IORING_SETUP_SQE128

Crash: KASAN: use-after-free Read in io_uring_show_fdinfo (log)
Repro: C syz .config
Last patch testing requests:
Created Duration User Patch Repo Result
2022/10/10 11:54 17m asml.silence@gmail.com https://github.com/isilence/linux.git io_uring/fdinfo_fix OK log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __io_uring_show_fdinfo io_uring/fdinfo.c:98 [inline]
BUG: KASAN: use-after-free in io_uring_show_fdinfo+0x625/0x1947 io_uring/fdinfo.c:206
Read of size 8 at addr ffff888070efff20 by task syz-executor137/3614

CPU: 1 PID: 3614 Comm: syz-executor137 Not tainted 6.0.0-syzkaller-09039-ga6afa4199d3d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:317 [inline]
 print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
 kasan_report+0xb1/0x1e0 mm/kasan/report.c:495
 __io_uring_show_fdinfo io_uring/fdinfo.c:98 [inline]
 io_uring_show_fdinfo+0x625/0x1947 io_uring/fdinfo.c:206
 seq_show+0x587/0x800 fs/proc/fd.c:68
 seq_read_iter+0x4f5/0x1280 fs/seq_file.c:230
 seq_read+0x16d/0x210 fs/seq_file.c:162
 vfs_read+0x257/0x930 fs/read_write.c:468
 ksys_pread64 fs/read_write.c:665 [inline]
 __do_sys_pread64 fs/read_write.c:675 [inline]
 __se_sys_pread64 fs/read_write.c:672 [inline]
 __x64_sys_pread64+0x1f7/0x250 fs/read_write.c:672
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f5d9eb604e9
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 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 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff67d324d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000011
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f5d9eb604e9
RDX: 0000000000000011 RSI: 0000000020002140 RDI: 0000000000000005
RBP: 00007fff67d324e0 R08: 00007fff67d32370 R09: 68742f636f72702f
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5d9eb243d0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0001c3bfc0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x70eff
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 dead000000000100 dead000000000122 0000000000000000
raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 0, migratetype Movable, gfp_mask 0x8(__GFP_MOVABLE), pid 1, tgid 1 (swapper/0), ts 10956630395, free_ts 11652600851
 split_map_pages+0x1ef/0x520 mm/compaction.c:99
 isolate_freepages_range+0x30f/0x350 mm/compaction.c:737
 alloc_contig_range+0x2f6/0x490 mm/page_alloc.c:9331
 __alloc_contig_pages mm/page_alloc.c:9354 [inline]
 alloc_contig_pages+0x35a/0x4c0 mm/page_alloc.c:9431
 debug_vm_pgtable_alloc_huge_page mm/debug_vm_pgtable.c:1098 [inline]
 init_args mm/debug_vm_pgtable.c:1221 [inline]
 debug_vm_pgtable+0x88f/0x29d6 mm/debug_vm_pgtable.c:1259
 do_one_initcall+0xfe/0x650 init/main.c:1296
 do_initcall_level init/main.c:1369 [inline]
 do_initcalls init/main.c:1385 [inline]
 do_basic_setup init/main.c:1404 [inline]
 kernel_init_freeable+0x6b1/0x73a init/main.c:1623
 kernel_init+0x1a/0x1d0 init/main.c:1512
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1449 [inline]
 free_pcp_prepare+0x5e4/0xd20 mm/page_alloc.c:1499
 free_unref_page_prepare mm/page_alloc.c:3380 [inline]
 free_unref_page+0x19/0x4d0 mm/page_alloc.c:3476
 free_contig_range+0xb1/0x180 mm/page_alloc.c:9453
 destroy_args+0xa8/0x646 mm/debug_vm_pgtable.c:1031
 debug_vm_pgtable+0x2945/0x29d6 mm/debug_vm_pgtable.c:1354
 do_one_initcall+0xfe/0x650 init/main.c:1296
 do_initcall_level init/main.c:1369 [inline]
 do_initcalls init/main.c:1385 [inline]
 do_basic_setup init/main.c:1404 [inline]
 kernel_init_freeable+0x6b1/0x73a init/main.c:1623
 kernel_init+0x1a/0x1d0 init/main.c:1512
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

Memory state around the buggy address:
 ffff888070effe00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888070effe80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888070efff00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                               ^
 ffff888070efff80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888070f00000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (5):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci-upstream-kasan-gce 2022/10/09 16:46 upstream a6afa4199d3d aea5da89 .config strace log report syz C [disk image] [vmlinux] KASAN: use-after-free Read in io_uring_show_fdinfo
ci-upstream-kasan-gce-root 2022/10/09 12:20 upstream a6afa4199d3d aea5da89 .config strace log report syz C [disk image] [vmlinux] KASAN: use-after-free Read in io_uring_show_fdinfo
ci-upstream-kasan-gce 2022/10/15 23:54 upstream 55be6084c8e0 67cb024c .config console log report info [disk image] [vmlinux] KASAN: slab-out-of-bounds Read in io_uring_show_fdinfo
ci-upstream-kasan-gce-root 2022/10/09 12:01 upstream a6afa4199d3d aea5da89 .config console log report info [disk image] [vmlinux] KASAN: slab-out-of-bounds Read in io_uring_show_fdinfo
ci-upstream-kasan-gce-root 2022/10/15 06:25 upstream 55be6084c8e0 67cb024c .config console log report info [disk image] [vmlinux] KASAN: use-after-free Read in io_uring_show_fdinfo
* Struck through repros no longer work on HEAD.