syzbot


KASAN: use-after-free Read in ring_buffer_map

Status: upstream: reported C repro on 2024/12/16 08:23
Subsystems: trace
[Documentation on labels]
Reported-by: syzbot+345e4443a21200874b18@syzkaller.appspotmail.com
Fix commit: ring-buffer: Fix overflow in __rb_map_vma
Patched on: [ci-qemu-gce-upstream-auto ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-snapshot-upstream-root ci-upstream-gce-leak ci-upstream-kasan-badwrites-root 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-386-root ci-upstream-kmsan-gce-root ci-upstream-linux-next-kasan-gce-root ci2-upstream-fs ci2-upstream-kcsan-gce], missing on: [ci-qemu-native-arm64-kvm ci-qemu2-arm32 ci-qemu2-riscv64 ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-arm64 ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-usb]
First crash: 9d06h, last: 18h51m
Discussions (3)
Title Replies (including bot) Last reply
[for-linus][PATCH 1/2] ring-buffer: Fix overflow in __rb_map_vma 1 (1) 2024/12/19 01:23
[PATCH] ring-buffer: Fix a oob in __rb_map_vma 13 (13) 2024/12/18 14:33
[syzbot] [trace?] KASAN: use-after-free Read in ring_buffer_map 2 (4) 2024/12/16 14:06
Last patch testing requests (1)
Created Duration User Patch Repo Result
2024/12/16 13:44 20m eadavis@qq.com https://github.com/ea1davis/linux kt/syz OK log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __rb_map_vma+0x9ab/0xae0 kernel/trace/ring_buffer.c:7058
Read of size 8 at addr ffff8880819f9ef8 by task syz-executor386/5869

CPU: 1 UID: 0 PID: 5869 Comm: syz-executor386 Not tainted 6.13.0-rc3-syzkaller-00073-geabcdba3ad40 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/25/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xc3/0x620 mm/kasan/report.c:489
 kasan_report+0xd9/0x110 mm/kasan/report.c:602
 __rb_map_vma+0x9ab/0xae0 kernel/trace/ring_buffer.c:7058
 ring_buffer_map+0x56e/0x9b0 kernel/trace/ring_buffer.c:7138
 tracing_buffers_mmap+0xa6/0x120 kernel/trace/trace.c:8335
 call_mmap include/linux/fs.h:2183 [inline]
 mmap_file mm/internal.h:124 [inline]
 __mmap_new_file_vma mm/vma.c:2291 [inline]
 __mmap_new_vma mm/vma.c:2355 [inline]
 __mmap_region+0x1786/0x2670 mm/vma.c:2456
 mmap_region+0x127/0x320 mm/mmap.c:1348
 do_mmap+0xc00/0xfc0 mm/mmap.c:496
 vm_mmap_pgoff+0x1ba/0x360 mm/util.c:580
 ksys_mmap_pgoff+0x32c/0x5c0 mm/mmap.c:542
 __do_sys_mmap arch/x86/kernel/sys_x86_64.c:89 [inline]
 __se_sys_mmap arch/x86/kernel/sys_x86_64.c:82 [inline]
 __x64_sys_mmap+0x125/0x190 arch/x86/kernel/sys_x86_64.c:82
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fa43e138f99
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 1f 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd7b5fee38 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fa43e138f99
RDX: 0000000001000000 RSI: 0000000000004000 RDI: 0000000020ff8000
RBP: 0000000000000000 R08: 0000000000000003 R09: 0000000800000000
R10: 000000000008e051 R11: 0000000000000246 R12: 0000000000000003
R13: 00007ffd7b5fee90 R14: 00007ffd7b5feed0 R15: 0000000000000000
 </TASK>

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x819f9
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea0002067e48 ffffea0002067e48 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner info is not present (never set?)

Memory state around the buggy address:
 ffff8880819f9d80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff8880819f9e00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff8880819f9e80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                                                ^
 ffff8880819f9f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff8880819f9f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (15):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/19 21:31 upstream eabcdba3ad40 1d58202c .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: use-after-free Read in ring_buffer_map
2024/12/13 15:06 upstream f932fb9b4074 b1b5e51a .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in ring_buffer_map
2024/12/18 00:55 upstream 59dbb9d81adf a0626d3a .config console log report syz / log [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: use-after-free Read in ring_buffer_map
2024/12/20 14:56 upstream 8faabc041a00 49cfeac8 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: use-after-free Read in ring_buffer_map
2024/12/12 08:13 upstream f92f4749861b 6f1b0fa8 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: use-after-free Read in ring_buffer_map
2024/12/20 19:49 upstream 8faabc041a00 49cfeac8 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-use-after-free Read in ring_buffer_map
2024/12/20 15:39 upstream 8faabc041a00 49cfeac8 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in ring_buffer_map
2024/12/18 00:35 upstream 59dbb9d81adf a0626d3a .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in ring_buffer_map
2024/12/17 02:06 upstream f44d154d6e3d f93b2b55 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in ring_buffer_map
2024/12/16 14:10 upstream 78d4f34e2115 eec85da6 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in ring_buffer_map
2024/12/16 14:01 upstream 78d4f34e2115 eec85da6 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in ring_buffer_map
2024/12/16 13:55 upstream 78d4f34e2115 eec85da6 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in ring_buffer_map
2024/12/14 17:48 upstream a446e965a188 7cbfbb3a .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in ring_buffer_map
2024/12/13 15:02 upstream f932fb9b4074 b1b5e51a .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in ring_buffer_map
2024/12/13 14:39 upstream f932fb9b4074 b1b5e51a .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in ring_buffer_map
* Struck through repros no longer work on HEAD.