KASAN: use-after-free Write in ring_buffer_read_page
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: e7ae89a0c97c Linux 7.1-rc5 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=16f06e2e580000 kernel config: https://syzkaller.appspot.com/x/.config?x=58acee1ac5406016 dashboard link: https://syzkaller.appspot.com/bug?extid=2dd9d02f60775ce5c1fb compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
Unfortunately, I don't have any reproducer for this issue yet.
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/9b0c5b4e3645/disk-e7ae89a0.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ed163d3ad68b/vmlinux-e7ae89a0.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f2408b333334/bzImage-e7ae89a0.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
==================================================================
BUG: KASAN: use-after-free in ring_buffer_read_page+0xd51/0x15a0 kernel/trace/ring_buffer.c:7059
Write of size 16308 at addr ffff88805ceb404c by task syz.3.1872/14532
CPU: 0 UID: 0 PID: 14532 Comm: syz.3.1872 Tainted: G L syzkaller #0 PREEMPT(full)
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0x13d/0x4b0 mm/kasan/report.c:482
kasan_report+0xdf/0x1d0 mm/kasan/report.c:595
check_region_inline mm/kasan/generic.c:186 [inline]
kasan_check_range+0x10f/0x1e0 mm/kasan/generic.c:200
__asan_memset+0x23/0x50 mm/kasan/shadow.c:84
ring_buffer_read_page+0xd51/0x15a0 kernel/trace/ring_buffer.c:7059
tracing_buffers_read+0x2bf/0xaf0 kernel/trace/trace.c:7129
vfs_read+0x1e4/0xb30 fs/read_write.c:572
ksys_read+0x12a/0x250 fs/read_write.c:717
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x10b/0x830 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fb1aad9ce59
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fb1abca5028 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007fb1ab015fa0 RCX: 00007fb1aad9ce59
RDX: 0000000000001000 RSI: 00002000000002c0 RDI: 0000000000000008
RBP: 00007fb1aae32d6f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fb1ab016038 R14: 00007fb1ab015fa0 R15: 00007ffec139a1b8
</TASK>
The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5ceb4
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x44dc0(GFP_KERNEL|__GFP_ZERO|__GFP_RETRY_MAYFAIL|__GFP_COMP), pid 5959, tgid 5958 (syz.1.37), ts 95924498456, free_ts 95918916027
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1858
prep_new_page mm/page_alloc.c:1866 [inline]
get_page_from_freelist+0x11a6/0x33b0 mm/page_alloc.c:3946
__alloc_frozen_pages_noprof+0x27c/0x2bc0 mm/page_alloc.c:5226
__alloc_pages_noprof+0xb/0x110 mm/page_alloc.c:5260
__alloc_pages_node_noprof include/linux/gfp.h:289 [inline]
alloc_pages_node_noprof include/linux/gfp.h:316 [inline]
alloc_cpu_data+0x60/0x130 kernel/trace/ring_buffer.c:406
ring_buffer_alloc_read_page+0x430/0x560 kernel/trace/ring_buffer.c:6801
tracing_buffers_read+0x603/0xaf0 kernel/trace/trace.c:7110
vfs_read+0x1e4/0xb30 fs/read_write.c:572
ksys_read+0x12a/0x250 fs/read_write.c:717
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x10b/0x830 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 5946 tgid 5945 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1402 [inline]
__free_frozen_pages+0x747/0x1040 mm/page_alloc.c:2943
tlb_batch_list_free mm/mmu_gather.c:161 [inline]
tlb_finish_mmu+0x27d/0x810 mm/mmu_gather.c:552
exit_mmap+0x454/0xa10 mm/mmap.c:1313
__mmput+0x12a/0x410 kernel/fork.c:1178
mmput+0x67/0x80 kernel/fork.c:1201
exit_mm kernel/exit.c:582 [inline]
do_exit+0x8b2/0x2af0 kernel/exit.c:964
do_group_exit+0xd5/0x2a0 kernel/exit.c:1119
get_signal+0x20ff/0x2210 kernel/signal.c:3037
arch_do_signal_or_restart+0x91/0x7a0 arch/x86/kernel/signal.c:337
__exit_to_user_mode_loop kernel/entry/common.c:64 [inline]
exit_to_user_mode_loop+0x8b/0x4f0 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:230 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
do_syscall_64+0x6f2/0x830 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Memory state around the buggy address:
ffff88805ceb4f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88805ceb4f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88805ceb5000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88805ceb5080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88805ceb5100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
Steven Rostedt
maintainerQuoted 10 lines · On Tue, 02 Jun 2026 06:45:31 -0700 syzbot…
syzbot found the following issue on:
HEAD commit: e7ae89a0c97c Linux 7.1-rc5 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=16f06e2e580000 kernel config: https://syzkaller.appspot.com/x/.config?x=58acee1ac5406016 dashboard link: https://syzkaller.appspot.com/bug?extid=2dd9d02f60775ce5c1fb compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44Unfortunately, I don't have any reproducer for this issue yet.
Looks like the test was doing something really weird to trigger this. Without a reproducer, it's pretty much impossible to find out what happened. Maybe AI could do it?
-- Steve
Masami Hiramatsu (Google)
maintainerQuoted 12 lines · On Tue, 2 Jun 2026 12:28:29 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 9 lines · On Tue, 02 Jun 2026 06:45:31 -0700 syzbot…
syzbot found the following issue on:
HEAD commit: e7ae89a0c97c Linux 7.1-rc5 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=16f06e2e580000 kernel config: https://syzkaller.appspot.com/x/.config?x=58acee1ac5406016 dashboard link: https://syzkaller.appspot.com/bug?extid=2dd9d02f60775ce5c1fb compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
Quoted 6 lines
Quoted 1 line
Unfortunately, I don't have any reproducer for this issue yet.
Looks like the test was doing something really weird to trigger this. Without a reproducer, it's pretty much impossible to find out what happened. Maybe AI could do it?
Does the "I don't have any reproducer for this issue yet." means this is not reproducible even if it runs completely same sequence in the console output? If so, might this be a timing related issue? (e.g. read v.s. write-event)
Thanks,
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 23 lines · Masami Hiramatsu' via syzkaller-bugs
Quoted 12 lines · On Tue, 2 Jun 2026 12:28:29 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 9 lines · On Tue, 02 Jun 2026 06:45:31 -0700 syzbot…
syzbot found the following issue on:
HEAD commit: e7ae89a0c97c Linux 7.1-rc5 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=16f06e2e580000 kernel config: https://syzkaller.appspot.com/x/.config?x=58acee1ac5406016 dashboard link: https://syzkaller.appspot.com/bug?extid=2dd9d02f60775ce5c1fb compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44Quoted 6 lines
Quoted 1 line
Unfortunately, I don't have any reproducer for this issue yet.
Looks like the test was doing something really weird to trigger this. Without a reproducer, it's pretty much impossible to find out what happened. Maybe AI could do it?
Quoted 4 lines
Does the "I don't have any reproducer for this issue yet." means this is not reproducible even if it runs completely same sequence in the console output? If so, might this be a timing related issue? (e.g. read v.s. write-event)
Yes, syzbot normally re-plays the sequence of last programs executed on the crashed VM to find a reproducer, and, in many cases, they no longer crash the kernel..
In the meanwhile, syzbot's AI bug reproduction functionality has found a C reproducer for a KASAN crash in the kernel/trace's ring buffer, although with a slightly different stack trace:
https://syzkaller.appspot.com/ai_job?id=b2620161-1632-4d4e-9314-114a8a5e79ef
Cc Alexander Potapenko
Quoted 6 lines
Thanks,
--
Masami Hiramatsu (Google) <[email protected]>
Quoted 35 lines · Aleksandr Nogikh
Quoted 23 lines · Masami Hiramatsu' via syzkaller-bugs
Quoted 12 lines · On Tue, 2 Jun 2026 12:28:29 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 9 lines · On Tue, 02 Jun 2026 06:45:31 -0700 syzbot…
syzbot found the following issue on:
HEAD commit: e7ae89a0c97c Linux 7.1-rc5 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=16f06e2e580000 kernel config: https://syzkaller.appspot.com/x/.config?x=58acee1ac5406016 dashboard link: https://syzkaller.appspot.com/bug?extid=2dd9d02f60775ce5c1fb compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44Quoted 6 lines
Quoted 1 line
Unfortunately, I don't have any reproducer for this issue yet.
Looks like the test was doing something really weird to trigger this. Without a reproducer, it's pretty much impossible to find out what happened. Maybe AI could do it?
Quoted 4 lines
Does the "I don't have any reproducer for this issue yet." means this is not reproducible even if it runs completely same sequence in the console output? If so, might this be a timing related issue? (e.g. read v.s. write-event)
Yes, syzbot normally re-plays the sequence of last programs executed on the crashed VM to find a reproducer, and, in many cases, they no longer crash the kernel..
Quoted 6 lines
In the meanwhile, syzbot's AI bug reproduction functionality has found a C reproducer for a KASAN crash in the kernel/trace's ring buffer, although with a slightly different stack trace:
https://syzkaller.appspot.com/ai_job?id=b2620161-1632-4d4e-9314-114a8a5e79efCc Alexander Potapenko
Yes, the bug that the AI reproduced manifests with a different stack:
BUG: KASAN: slab-use-after-free in instrument_copy_to_user include/linux/instrumented.h:129 [inline] BUG: KASAN: slab-use-after-free in _inline_copy_to_user include/linux/uaccess.h:205 [inline] BUG: KASAN: slab-use-after-free in _copy_to_user+0x79/0xb0 lib/usercopy.c:26 Read of size 12288 at addr ffff888180423000 by task syz-executor144/5941 CPU: 1 UID: 0 PID: 5941 Comm: syz-executor144 Not tainted syzkaller #1 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 print_address_description+0x55/0x1e0 mm/kasan/report.c:378 print_report+0x58/0x70 mm/kasan/report.c:482 kasan_report+0x117/0x150 mm/kasan/report.c:595 check_region_inline mm/kasan/generic.c:-1 [inline] kasan_check_range+0x264/0x2c0 mm/kasan/generic.c:200 instrument_copy_to_user include/linux/instrumented.h:129 [inline] _inline_copy_to_user include/linux/uaccess.h:205 [inline] _copy_to_user+0x79/0xb0 lib/usercopy.c:26 copy_to_user include/linux/uaccess.h:236 [inline] tracing_buffers_read+0x4cd/0xd60 kernel/trace/trace.c:7158 vfs_read+0x20c/0xa70 fs/read_write.c:572 ksys_read+0x150/0x270 fs/read_write.c:717 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x15f/0x560 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f9facd00cde Code: 08 0f 85 f5 e2 ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89
c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> 90 41 57 41 56 4d 89 c6 41 55 4d 89 cd 41 54 55 53 48 83 ec 08
RSP: 002b:00007f9fabc9e198 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007f9fabca26c0 RCX: 00007f9facd00cde
RDX: 0000000000004000 RSI: 00007f9fabc9e200 RDI: 0000000000000006
RBP: 00007f9fabc9e200 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f9facd7ab20
R13: 0000000000000000 R14: 00007ffd6ed73110 R15: 00007ffd6ed731f8
</TASK>
Quoting the AI itself:
"""
The reproducer successfully triggered a KASAN use-after-free crash in the tracing subsystem. Although the exact crash signature differs slightly (a read in _copy_to_user called from tracing_buffers_read vs a write in ring_buffer_read_page called from tracing_buffers_read), both crashes are use-after-free bugs on ring buffer pages accessed during tracing_buffers_read. The reproduced crash shows the page being freed by ring_buffer_subbuf_order_set (via buffer_subbuf_size_write) while being concurrently accessed by tracing_buffers_read. This confirms the underlying race condition between reading the trace buffers and modifying the buffer size/order has been successfully reproduced.
"""
I took a glance at the reports, and the above makes sense: we just happen to access filp->private_data->spare at different times after it has been freed.
PS. Please bear with repro-c, it's making its baby steps.
The reproducer contains some dead code, and the results are hard to navigate. At some point we'll probably be able to link AI-generated repros from the original bugs.
From syzbot initial report, I noticed that ring_buffer_read_page() checks data_page->order against buffer->subbuf_order , whereas in while ring_buffer_subbuf_order_set() updates subbuf_size before replacing the old pages. I think this allows reader to use older spare page while observing a newer sub-buffer size.
That could explain the report (KASAN UAF, memset of 16308 bytes order 2 into an order 0 spare), while the AI reproducer may hit a related race later in via copy_to_user() tracing_buffers_read().
Before spending more time on a fix, does this sound correct, or i am missing something in between?
Sincerely,
Yash Suthar