[v6.1] KASAN: stack-out-of-bounds Write in copy_from_kernel_nofault

0 views
Skip to first unread message

syzbot

unread,
Apr 2, 2023, 12:05:47 PM4/2/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3b29299e5f60 Linux 6.1.22
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=11e4ecc9c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=4a782518325cb082
dashboard link: https://syzkaller.appspot.com/bug?extid=65da5dbeacebf1b0fb83
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1093d785c80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/46ca0111f0f2/disk-3b29299e.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/e685b23e427f/vmlinux-3b29299e.xz
kernel image: https://storage.googleapis.com/syzbot-assets/eb1a012e2c1f/bzImage-3b29299e.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+65da5d...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: stack-out-of-bounds in copy_from_kernel_nofault+0xa0/0x2c0 mm/maccess.c:35
Write of size 8 at addr ffffc90006a6fa88 by task syz-executor.4/17204

CPU: 0 PID: 17204 Comm: syz-executor.4 Not tainted 6.1.22-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x15f/0x4f0 mm/kasan/report.c:395
kasan_report+0x136/0x160 mm/kasan/report.c:495
copy_from_kernel_nofault+0xa0/0x2c0 mm/maccess.c:35
get_kernel_gp_address arch/x86/kernel/traps.c:590 [inline]
__exc_general_protection arch/x86/kernel/traps.c:768 [inline]
exc_general_protection+0x312/0x4f0 arch/x86/kernel/traps.c:728
asm_exc_general_protection+0x22/0x30 arch/x86/include/asm/idtentry.h:564
RIP: 0010:bpf_prog_test_run_xdp+0x7ff/0x1130 net/bpf/test_run.c:1398
Code: 89 df 48 8b 74 24 58 e8 0f 2b 00 00 31 ff 44 89 e6 e8 65 9b d0 f8 45 85 e4 74 0a e8 fb 97 d0 f8 e9 57 01 00 00 48 8b 44 24 48 <42> 80 3c 30 00 4c 8b 64 24 10 74 0d 48 8b bc 24 88 00 00 00 e8 f8
RSP: 0018:ffffc90006a6fb80 EFLAGS: 00010246
RAX: 1ffff92000d4df91 RBX: 0000000000000000 RCX: ffff888022179d40
RDX: ffff888022179d40 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc90006a6fd30 R08: ffffffff88b8f59b R09: ffffed100442f3a9
R10: 0000000000000000 R11: dffffc0000000001 R12: 0000000000000000
R13: ffffffff88b8d854 R14: 0000000000000000 R15: ffffc90006a6fc60
bpf_prog_test_run+0x32f/0x3a0 kernel/bpf/syscall.c:3628
__sys_bpf+0x3eb/0x6c0 kernel/bpf/syscall.c:4981
__do_sys_bpf kernel/bpf/syscall.c:5067 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5065 [inline]
__x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:5065
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fbe5be8c0f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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:00007fbe5cb63168 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007fbe5bfabf80 RCX: 00007fbe5be8c0f9
RDX: 0000000000000048 RSI: 0000000020000200 RDI: 000000000000000a
RBP: 00007fbe5bee7b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe82ee769f R14: 00007fbe5cb63300 R15: 0000000000022000
</TASK>

The buggy address belongs to stack of task syz-executor.4/17204
KASAN internal error: frame info validation failed; invalid marker: 0

The buggy address belongs to the virtual mapping at
[ffffc90006a68000, ffffc90006a71000) created by:
copy_process+0x637/0x4020 kernel/fork.c:2087

The buggy address belongs to the physical page:
page:ffffea000071bec0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1c6fb
memcg:ffff888145d01f02
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000001ffffffff ffff888145d01f02
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x102dc2(GFP_HIGHUSER|__GFP_NOWARN|__GFP_ZERO), pid 17201, tgid 17201 (syz-executor.4), ts 903650785456, free_ts 888834892014
prep_new_page mm/page_alloc.c:2540 [inline]
get_page_from_freelist+0x32ed/0x3480 mm/page_alloc.c:4292
__alloc_pages+0x28d/0x770 mm/page_alloc.c:5559
vm_area_alloc_pages mm/vmalloc.c:2975 [inline]
__vmalloc_area_node mm/vmalloc.c:3043 [inline]
__vmalloc_node_range+0x962/0x1360 mm/vmalloc.c:3213
alloc_thread_stack_node kernel/fork.c:311 [inline]
dup_task_struct+0x3e5/0x6d0 kernel/fork.c:977
copy_process+0x637/0x4020 kernel/fork.c:2087
kernel_clone+0x222/0x920 kernel/fork.c:2676
__do_sys_clone kernel/fork.c:2817 [inline]
__se_sys_clone kernel/fork.c:2801 [inline]
__x64_sys_clone+0x231/0x280 kernel/fork.c:2801
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1460 [inline]
free_pcp_prepare mm/page_alloc.c:1510 [inline]
free_unref_page_prepare+0xf5e/0x1110 mm/page_alloc.c:3388
free_unref_page_list+0x107/0x810 mm/page_alloc.c:3530
release_pages+0x2836/0x2b40 mm/swap.c:1055
tlb_batch_pages_flush mm/mmu_gather.c:59 [inline]
tlb_flush_mmu_free mm/mmu_gather.c:254 [inline]
tlb_flush_mmu+0xfc/0x210 mm/mmu_gather.c:261
tlb_finish_mmu+0xce/0x1f0 mm/mmu_gather.c:361
exit_mmap+0x2c2/0x8b0 mm/mmap.c:3100
__mmput+0x115/0x3c0 kernel/fork.c:1188
exit_mm+0x226/0x300 kernel/exit.c:563
do_exit+0x67e/0x2300 kernel/exit.c:856
do_group_exit+0x202/0x2b0 kernel/exit.c:1019
get_signal+0x16f7/0x17d0 kernel/signal.c:2858
arch_do_signal_or_restart+0xb0/0x1a10 arch/x86/kernel/signal.c:869
exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:168
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:297
do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86

Memory state around the buggy address:
ffffc90006a6f980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffc90006a6fa00: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 00 00 f2
>ffffc90006a6fa80: f2 f2 f2 f2 00 00 f2 f2 00 00 00 f2 f2 f2 f2 f2
^
ffffc90006a6fb00: 04 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
ffffc90006a6fb80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
----------------
Code disassembly (best guess):
0: 89 df mov %ebx,%edi
2: 48 8b 74 24 58 mov 0x58(%rsp),%rsi
7: e8 0f 2b 00 00 callq 0x2b1b
c: 31 ff xor %edi,%edi
e: 44 89 e6 mov %r12d,%esi
11: e8 65 9b d0 f8 callq 0xf8d09b7b
16: 45 85 e4 test %r12d,%r12d
19: 74 0a je 0x25
1b: e8 fb 97 d0 f8 callq 0xf8d0981b
20: e9 57 01 00 00 jmpq 0x17c
25: 48 8b 44 24 48 mov 0x48(%rsp),%rax
* 2a: 42 80 3c 30 00 cmpb $0x0,(%rax,%r14,1) <-- trapping instruction
2f: 4c 8b 64 24 10 mov 0x10(%rsp),%r12
34: 74 0d je 0x43
36: 48 8b bc 24 88 00 00 mov 0x88(%rsp),%rdi
3d: 00
3e: e8 .byte 0xe8
3f: f8 clc


---
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 syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Nov 15, 2023, 12:44:27 PM11/15/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: fb2635ac69ab Linux 6.1.62
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1239553f680000
kernel config: https://syzkaller.appspot.com/x/.config?x=d1540e3da5e5623f
dashboard link: https://syzkaller.appspot.com/bug?extid=65da5dbeacebf1b0fb83
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12d5bf88e80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=106c2184e80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c564654b9f0a/disk-fb2635ac.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/7967ffa53eb1/vmlinux-fb2635ac.xz
kernel image: https://storage.googleapis.com/syzbot-assets/2ddd941684d4/bzImage-fb2635ac.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+65da5d...@syzkaller.appspotmail.com

BUG: unable to handle page fault for address: ffffffffff600000
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD ce91067 P4D ce91067 PUD ce93067 PMD ceb6067 PTE 0
Oops: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 26 Comm: kworker/1:1 Not tainted 6.1.62-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
Workqueue: events free_work
RIP: 0010:copy_from_kernel_nofault+0x7d/0x2c0 mm/maccess.c:36
Code: 01 84 c0 0f 85 e1 01 00 00 41 ff 06 bf 07 00 00 00 4c 89 ee e8 14 d1 d0 ff 49 83 fd 07 76 58 4c 89 fb 49 83 c7 08 49 83 c5 f8 <49> 8b 2c 24 48 89 d8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df 80
RSP: 0018:ffffc90000a1fa20 EFLAGS: 00010257
RAX: 0000000000000000 RBX: ffffc90000a1fa88 RCX: ffff88801341bb80
RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000007
RBP: ffffc90000a1fa90 R08: ffffffff81b9c13c R09: fffffbfff2091845
R10: 0000000000000000 R11: dffffc0000000001 R12: ffffffffff600000
R13: 0000000000000000 R14: ffff88801341d2f0 R15: ffffc90000a1fa90
FS: 0000000000000000(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffff600000 CR3: 000000000ce8e000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
bpf_probe_read_kernel_common kernel/trace/bpf_trace.c:230 [inline]
____bpf_probe_read_kernel kernel/trace/bpf_trace.c:239 [inline]
bpf_probe_read_kernel+0x26/0x70 kernel/trace/bpf_trace.c:236
bpf_prog_bd8b22826c103b08+0x3a/0x3c
bpf_dispatcher_nop_func include/linux/bpf.h:970 [inline]
__bpf_prog_run include/linux/filter.h:600 [inline]
bpf_prog_run include/linux/filter.h:607 [inline]
__bpf_trace_run kernel/trace/bpf_trace.c:2275 [inline]
bpf_trace_run2+0x1fd/0x410 kernel/trace/bpf_trace.c:2314
__bpf_trace_kfree+0x6e/0x90 include/trace/events/kmem.h:94
trace_kfree include/trace/events/kmem.h:94 [inline]
kfree+0xf6/0x190 mm/slab_common.c:994
__vunmap+0x8d9/0x9a0 mm/vmalloc.c:2722
free_work+0x57/0x80 mm/vmalloc.c:97
process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
kthread+0x28d/0x320 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
</TASK>
Modules linked in:
CR2: ffffffffff600000
---[ end trace 0000000000000000 ]---
RIP: 0010:copy_from_kernel_nofault+0x7d/0x2c0 mm/maccess.c:36
Code: 01 84 c0 0f 85 e1 01 00 00 41 ff 06 bf 07 00 00 00 4c 89 ee e8 14 d1 d0 ff 49 83 fd 07 76 58 4c 89 fb 49 83 c7 08 49 83 c5 f8 <49> 8b 2c 24 48 89 d8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df 80
RSP: 0018:ffffc90000a1fa20 EFLAGS: 00010257
RAX: 0000000000000000 RBX: ffffc90000a1fa88 RCX: ffff88801341bb80
RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000007
RBP: ffffc90000a1fa90 R08: ffffffff81b9c13c R09: fffffbfff2091845
R10: 0000000000000000 R11: dffffc0000000001 R12: ffffffffff600000
R13: 0000000000000000 R14: ffff88801341d2f0 R15: ffffc90000a1fa90
FS: 0000000000000000(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffff600000 CR3: 000000000ce8e000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 01 84 c0 0f 85 e1 01 add %eax,0x1e1850f(%rax,%rax,8)
7: 00 00 add %al,(%rax)
9: 41 ff 06 incl (%r14)
c: bf 07 00 00 00 mov $0x7,%edi
11: 4c 89 ee mov %r13,%rsi
14: e8 14 d1 d0 ff call 0xffd0d12d
19: 49 83 fd 07 cmp $0x7,%r13
1d: 76 58 jbe 0x77
1f: 4c 89 fb mov %r15,%rbx
22: 49 83 c7 08 add $0x8,%r15
26: 49 83 c5 f8 add $0xfffffffffffffff8,%r13
* 2a: 49 8b 2c 24 mov (%r12),%rbp <-- trapping instruction
2e: 48 89 d8 mov %rbx,%rax
31: 48 c1 e8 03 shr $0x3,%rax
35: 48 b9 00 00 00 00 00 movabs $0xdffffc0000000000,%rcx
3c: fc ff df
3f: 80 .byte 0x80


---
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.
Reply all
Reply to author
Forward
0 new messages