BUG: unable to handle kernel paging request in write_comp_data
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: a2cf4ef33184 Merge tag 'devicetree-fixes-for-7.2' of git:/.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=16c0cc9e580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f221a1b5d497ed15 dashboard link: https://syzkaller.appspot.com/bug?extid=237f670105a254a230d4 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/6eb03d1a0722/disk-a2cf4ef3.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/4e0d90b14d28/vmlinux-a2cf4ef3.xz
kernel image: https://storage.googleapis.com/syzbot-assets/9b81b6ecaa65/bzImage-a2cf4ef3.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
BUG: unable to handle page fault for address: ffffc90013ccbfe8 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 13fe60067 P4D 13fe60067 PUD 1cafa067 PMD 61350067 PTE 0 Oops: Oops: 0002 [#1] SMP KASAN PTI CPU: 0 UID: 0 PID: 19114 Comm: syz.3.1830 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026 RIP: 0010:write_comp_data+0x75/0x90 kernel/kcov.c:267 Code: 00 8b bf fc 16 00 00 48 8b 30 48 c1 e7 03 4c 8d 1c b5 00 00 00 00 4a 8d 14 dd 28 00 00 00 48 39 d7 72 bd 48 83 c6 01 48 89 30 <4c> 89 44 10 e0 4c 89 4c 10 e8 4c 89 54 10 f0 4a 89 4c d8 20 c3 cc RSP: 0018:ffffc90005a57e78 EFLAGS: 00050257 RAX: ffffc90013ccc000 RBX: 0000000000000000 RCX: ffffffff824589a5 RDX: 0000000000000008 RSI: 0000000000000000 RDI: 0000000000400000 RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000002 R10: 0000000000000001 R11: fffffffffffffffc R12: 0000000000000020 R13: 0000000000000000 R14: 00007ffffffff000 R15: 0000000000000001 FS: 00007fa950b4b6c0(0000) GS:ffff888123de1000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffc90013ccbfe8 CR3: 000000005848c000 CR4: 00000000003526f0 Call Trace: <TASK> rseq_register+0x115/0x350 kernel/rseq.c:460 __do_sys_rseq kernel/rseq.c:561 [inline] __se_sys_rseq kernel/rseq.c:547 [inline] __x64_sys_rseq+0x1b8/0x2e0 kernel/rseq.c:547 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x115/0x840 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fa95359e019 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:00007fa950b4b028 EFLAGS: 00000246 ORIG_RAX: 000000000000014e RAX: ffffffffffffffda RBX: 00007fa953826450 RCX: 00007fa95359e019 RDX: 0000000000000000 RSI: 0000000000000020 RDI: 0000000000000000 RBP: 00007fa95363500c R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000000e R11: 0000000000000246 R12: 0000000000000000 R13: 00007fa9538264e8 R14: 00007fa953826450 R15: 00007fff4d0e3998 </TASK> Modules linked in: CR2: ffffc90013ccbfe8 ---[ end trace 0000000000000000 ]--- RIP: 0010:write_comp_data+0x75/0x90 kernel/kcov.c:267 Code: 00 8b bf fc 16 00 00 48 8b 30 48 c1 e7 03 4c 8d 1c b5 00 00 00 00 4a 8d 14 dd 28 00 00 00 48 39 d7 72 bd 48 83 c6 01 48 89 30 <4c> 89 44 10 e0 4c 89 4c 10 e8 4c 89 54 10 f0 4a 89 4c d8 20 c3 cc RSP: 0018:ffffc90005a57e78 EFLAGS: 00050257 RAX: ffffc90013ccc000 RBX: 0000000000000000 RCX: ffffffff824589a5 RDX: 0000000000000008 RSI: 0000000000000000 RDI: 0000000000400000 RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000002 R10: 0000000000000001 R11: fffffffffffffffc R12: 0000000000000020 R13: 0000000000000000 R14: 00007ffffffff000 R15: 0000000000000001 FS: 00007fa950b4b6c0(0000) GS:ffff888123de1000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffc90013ccbfe8 CR3: 000000005848c000 CR4: 00000000003526f0 ---------------- Code disassembly (best guess): 0: 00 8b bf fc 16 00 add %cl,0x16fcbf(%rbx) 6: 00 48 8b add %cl,-0x75(%rax) 9: 30 48 c1 xor %cl,-0x3f(%rax) c: e7 03 out %eax,$0x3 e: 4c 8d 1c b5 00 00 00 lea 0x0(,%rsi,4),%r11 15: 00 16: 4a 8d 14 dd 28 00 00 lea 0x28(,%r11,8),%rdx 1d: 00 1e: 48 39 d7 cmp %rdx,%rdi 21: 72 bd jb 0xffffffe0 23: 48 83 c6 01 add $0x1,%rsi 27: 48 89 30 mov %rsi,(%rax) * 2a: 4c 89 44 10 e0 mov %r8,-0x20(%rax,%rdx,1) <-- trapping instruction 2f: 4c 89 4c 10 e8 mov %r9,-0x18(%rax,%rdx,1) 34: 4c 89 54 10 f0 mov %r10,-0x10(%rax,%rdx,1) 39: 4a 89 4c d8 20 mov %rcx,0x20(%rax,%r11,8) 3e: c3 ret 3f: cc int3
---
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
syzbot
syzbotsyzbot has found a reproducer for the following issue on:
syzbot has found a reproducer for the following issue on:
HEAD commit: 704340f1cd0d Merge tag 'x86_urgent_for_7.3-rc4' of git://g.. git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git console output: https://syzkaller.appspot.com/x/log.txt?x=13351925580000 kernel config: https://syzkaller.appspot.com/x/.config?x=8c5c3949d762a91f dashboard link: https://syzkaller.appspot.com/bug?extid=237f670105a254a230d4 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11b875f9580000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
BUG: unable to handle page fault for address: ffffc90003792fe8 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 1c000067 P4D 1c000067 PUD 1d695067 PMD 25aa1067 PTE 0 Oops: Oops: 0002 [#1] SMP KASAN NOPTI CPU: 2 UID: 0 PID: 6034 Comm: syz-executor404 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:write_comp_data+0x7c/0xa0 kernel/kcov.c:263 Code: 00 8b bf 14 17 00 00 48 8b 30 48 c1 e7 03 4c 8d 1c b5 00 00 00 00 4a 8d 14 dd 28 00 00 00 48 39 d7 72 1b 48 83 c6 01 48 89 30 <4c> 89 44 10 e0 4c 89 4c 10 e8 4c 89 54 10 f0 4a 89 4c d8 20 e9 9b RSP: 0018:ffffc900016cfec0 EFLAGS: 00010257 RAX: ffffc90003793000 RBX: 0000000000000000 RCX: ffffffff824af562 RDX: 0000000000000008 RSI: 0000000000000000 RDI: 0000000000002000 RBP: 0000000000000000 R08: 0000000000000005 R09: 0000000000000000 R10: 0000000000000000 R11: fffffffffffffffc R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 FS: 000055556039d400(0000) GS:ffff8880d5d59000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffc90003792fe8 CR3: 0000000033822000 CR4: 0000000000352ef0 Call Trace: <TASK> __do_sys_rseq kernel/rseq.c:549 [inline] __se_sys_rseq kernel/rseq.c:547 [inline] __x64_sys_rseq+0xc2/0x2e0 kernel/rseq.c:547 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f4f6e875649 Code: c0 79 93 eb d5 48 8d 7c 1d 00 eb 99 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 d8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fffe975f1b8 EFLAGS: 00000246 ORIG_RAX: 000000000000014e RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f4f6e875649 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 00007f4f6e846000 R08: 0000000000000000 R09: 00000000000a8ca8 R10: 0000000000000000 R11: 0000000000000246 R12: 00007fffe975f2e8 R13: 0000000000000002 R14: 00007f4f6e8f8cc0 R15: 0000000000000002 </TASK> Modules linked in: CR2: ffffc90003792fe8 ---[ end trace 0000000000000000 ]--- RIP: 0010:write_comp_data+0x7c/0xa0 kernel/kcov.c:263 Code: 00 8b bf 14 17 00 00 48 8b 30 48 c1 e7 03 4c 8d 1c b5 00 00 00 00 4a 8d 14 dd 28 00 00 00 48 39 d7 72 1b 48 83 c6 01 48 89 30 <4c> 89 44 10 e0 4c 89 4c 10 e8 4c 89 54 10 f0 4a 89 4c d8 20 e9 9b RSP: 0018:ffffc900016cfec0 EFLAGS: 00010257 RAX: ffffc90003793000 RBX: 0000000000000000 RCX: ffffffff824af562 RDX: 0000000000000008 RSI: 0000000000000000 RDI: 0000000000002000 RBP: 0000000000000000 R08: 0000000000000005 R09: 0000000000000000 R10: 0000000000000000 R11: fffffffffffffffc R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 FS: 000055556039d400(0000) GS:ffff8880d5d59000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffc90003792fe8 CR3: 0000000033822000 CR4: 0000000000352ef0 ---------------- Code disassembly (best guess): 0: 00 8b bf 14 17 00 add %cl,0x1714bf(%rbx) 6: 00 48 8b add %cl,-0x75(%rax) 9: 30 48 c1 xor %cl,-0x3f(%rax) c: e7 03 out %eax,$0x3 e: 4c 8d 1c b5 00 00 00 lea 0x0(,%rsi,4),%r11 15: 00 16: 4a 8d 14 dd 28 00 00 lea 0x28(,%r11,8),%rdx 1d: 00 1e: 48 39 d7 cmp %rdx,%rdi 21: 72 1b jb 0x3e 23: 48 83 c6 01 add $0x1,%rsi 27: 48 89 30 mov %rsi,(%rax) * 2a: 4c 89 44 10 e0 mov %r8,-0x20(%rax,%rdx,1) <-- trapping instruction 2f: 4c 89 4c 10 e8 mov %r9,-0x18(%rax,%rdx,1) 34: 4c 89 54 10 f0 mov %r10,-0x10(%rax,%rdx,1) 39: 4a 89 4c d8 20 mov %rcx,0x20(%rax,%r11,8) 3e: e9 .byte 0xe9 3f: 9b fwait
---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
From: Edward Aadm Davis <[email protected]>
#syz test: upstream 704340f1cd0d
kernel/kcov.c +4 -2
@@ -236,7 +236,7 @@ static void notrace write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip) {struct task_struct *t;u64 *area; -u64 count, start_index, end_pos, max_pos; +u64 count, start_index, end_pos, max_pos, tmp; t = current;if (!check_kcov_mode (KCOV_MODE_TRACE_CMP , t))
@@ -254,7 +254,9 @@ static void notrace write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip) count =READ_ONCE (area[0 ]);/* Every record is KCOV_WORDS_PER_CMP 64-bit words. */ - start_index =1 + count *KCOV_WORDS_PER_CMP ; +if (check_mul_overflow (count,KCOV_WORDS_PER_CMP , &tmp)) +return ; + start_index =1 + tmp; end_pos = (start_index +KCOV_WORDS_PER_CMP ) *sizeof (u64);if (likely (end_pos <= max_pos)) {/* See comment in __sanitizer_cov_trace_pc(). */
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Tested on:
commit: 704340f1 Merge tag 'x86_urgent_for_7.3-rc4' of git://g.. git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git console output: https://syzkaller.appspot.com/x/log.txt?x=113a48c9580000 kernel config: https://syzkaller.appspot.com/x/.config?x=8c5c3949d762a91f dashboard link: https://syzkaller.appspot.com/bug?extid=237f670105a254a230d4 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 patch: https://syzkaller.appspot.com/x/patch.diff?x=13587df9580000
Note: testing is done by a robot and is best-effort only.
PATCH 1/1 kcov: add a missing bound check in write_comp_data()
In reply to syzbotA missing bounds check in write_comp_data() can lead to an out-of-bounds read or write in the adjacent memory area, since the start_index is not validated before accessing area[] in the function later, potentially hitting:
BUG: unable to handle page fault for address: ffffc90003792fe8 RIP: 0010:write_comp_data+0x7c/0xa0 kernel/kcov.c:263 Call Trace: __do_sys_rseq kernel/rseq.c:549 [inline] __se_sys_rseq kernel/rseq.c:547 [inline] __x64_sys_rseq+0xc2/0x2e0 kernel/rseq.c:547
--- kernel/kcov.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/kcov.c +4 -2
@@ -236,7 +236,7 @@ static void notrace write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip) {struct task_struct *t;u64 *area; -u64 count, start_index, end_pos, max_pos; +u64 count, start_index, end_pos, max_pos, tmp; t = current;if (!check_kcov_mode (KCOV_MODE_TRACE_CMP , t))
@@ -254,7 +254,9 @@ static void notrace write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip) count =READ_ONCE (area[0 ]);/* Every record is KCOV_WORDS_PER_CMP 64-bit words. */ - start_index =1 + count *KCOV_WORDS_PER_CMP ; +if (check_mul_overflow (count,KCOV_WORDS_PER_CMP , &tmp)) +return ; + start_index =1 + tmp; end_pos = (start_index +KCOV_WORDS_PER_CMP ) *sizeof (u64);if (likely (end_pos <= max_pos)) {/* See comment in __sanitizer_cov_trace_pc(). */
Signature · 1 line
2.43.0