syzbot


KASAN: stack-out-of-bounds Read in proc_pid_stack

Status: fixed on 2023/06/08 14:41
Subsystems: riscv
[Documentation on labels]
Reported-by: syzbot+01e9a564dc6b3289cea3@syzkaller.appspotmail.com
Fix commit: 76950340cf03 riscv: Use READ_ONCE_NOCHECK in imprecise unwinding stack mode
First crash: 361d, last: 326d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [fs?] KASAN: stack-out-of-bounds Read in proc_pid_stack 7 (8) 2023/05/02 13:13

Sample crash report:
EXT4-fs (loop0): mounted filesystem 00000000-0000-0000-0000-000000000000 without journal. Quota mode: none.
==================================================================
BUG: KASAN: stack-out-of-bounds in walk_stackframe+0x128/0x2fe arch/riscv/kernel/stacktrace.c:58
Read of size 8 at addr ff200000039279b0 by task syz-executor.0/5903

CPU: 0 PID: 5903 Comm: syz-executor.0 Tainted: G        W          6.2.0-rc1-syzkaller #0
Hardware name: riscv-virtio,qemu (DT)
Call Trace:
[<ffffffff8000b9ea>] dump_backtrace+0x2e/0x3c arch/riscv/kernel/stacktrace.c:121
[<ffffffff83402b96>] show_stack+0x34/0x40 arch/riscv/kernel/stacktrace.c:127
[<ffffffff83442726>] __dump_stack lib/dump_stack.c:88 [inline]
[<ffffffff83442726>] dump_stack_lvl+0xe0/0x14c lib/dump_stack.c:106
[<ffffffff83409674>] print_address_description mm/kasan/report.c:306 [inline]
[<ffffffff83409674>] print_report+0x1e4/0x4c0 mm/kasan/report.c:417
[<ffffffff804ead14>] kasan_report+0xb8/0xe6 mm/kasan/report.c:517
[<ffffffff804ebea4>] check_region_inline mm/kasan/generic.c:183 [inline]
[<ffffffff804ebea4>] __asan_load8+0x7e/0xa6 mm/kasan/generic.c:256
[<ffffffff8000b782>] walk_stackframe+0x128/0x2fe arch/riscv/kernel/stacktrace.c:58
[<ffffffff8000bc66>] arch_stack_walk+0x2c/0x3c arch/riscv/kernel/stacktrace.c:154
[<ffffffff80190822>] stack_trace_save_tsk+0x14a/0x1bc kernel/stacktrace.c:150
[<ffffffff80697822>] proc_pid_stack+0x146/0x1ee fs/proc/base.c:456
[<ffffffff80698bb0>] proc_single_show+0x9c/0x148 fs/proc/base.c:777
[<ffffffff805afada>] seq_read_iter+0x304/0x934 fs/seq_file.c:230
[<ffffffff805b0224>] seq_read+0x11a/0x16e fs/seq_file.c:162
[<ffffffff80547c70>] vfs_read+0x1f8/0x55c fs/read_write.c:468
[<ffffffff80548cfa>] ksys_read+0x10a/0x224 fs/read_write.c:613
[<ffffffff80548e3c>] __do_sys_read fs/read_write.c:623 [inline]
[<ffffffff80548e3c>] sys_read+0x28/0x36 fs/read_write.c:621
[<ffffffff80005ff6>] ret_from_syscall+0x0/0x2

The buggy address belongs to the virtual mapping at
 [ff20000003920000, ff20000003929000) created by:
 kernel_clone+0xee/0x914 kernel/fork.c:2681

The buggy address belongs to the physical page:
page:ff1c0000024ea180 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x93a86
memcg:ff60000011ede002
flags: 0xffe000000000000(node=0|zone=0|lastcpupid=0x7ff)
raw: 0ffe000000000000 0000000000000000 0000000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000001ffffffff ff60000011ede002
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 5901, tgid 5901 (syz-executor.0), ts 3370200604200, free_ts 3369054889400
 __set_page_owner+0x32/0x182 mm/page_owner.c:190
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0xf8/0x11a mm/page_alloc.c:2524
 prep_new_page mm/page_alloc.c:2531 [inline]
 get_page_from_freelist+0xc0e/0x1118 mm/page_alloc.c:4283
 __alloc_pages+0x1b0/0x165a mm/page_alloc.c:5549
 alloc_pages+0x132/0x25e mm/mempolicy.c:2286
 vm_area_alloc_pages mm/vmalloc.c:2989 [inline]
 __vmalloc_area_node mm/vmalloc.c:3057 [inline]
 __vmalloc_node_range+0x81c/0xdb4 mm/vmalloc.c:3227
 alloc_thread_stack_node kernel/fork.c:311 [inline]
 dup_task_struct kernel/fork.c:987 [inline]
 copy_process+0x210e/0x4068 kernel/fork.c:2097
 kernel_clone+0xee/0x914 kernel/fork.c:2681
 __do_sys_clone+0xec/0x120 kernel/fork.c:2822
 sys_clone+0x32/0x44 kernel/fork.c:2790
 ret_from_syscall+0x0/0x2
page last free stack trace:
 __reset_page_owner+0x4a/0xf8 mm/page_owner.c:148
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1446 [inline]
 free_pcp_prepare+0x254/0x48e mm/page_alloc.c:1496
 free_unref_page_prepare mm/page_alloc.c:3369 [inline]
 free_unref_page_list+0x11e/0x736 mm/page_alloc.c:3510
 release_pages+0x85a/0xbb2 mm/swap.c:1076
 free_pages_and_swap_cache+0x76/0x88 mm/swap_state.c:311
 tlb_batch_pages_flush+0x86/0x10c mm/mmu_gather.c:97
 tlb_flush_mmu_free mm/mmu_gather.c:292 [inline]
 tlb_flush_mmu mm/mmu_gather.c:299 [inline]
 tlb_finish_mmu+0xcc/0x280 mm/mmu_gather.c:391
 exit_mmap+0x190/0x686 mm/mmap.c:3096
 __mmput+0x98/0x290 kernel/fork.c:1207
 mmput+0x74/0x88 kernel/fork.c:1229
 exit_mm kernel/exit.c:563 [inline]
 do_exit+0x602/0x17be kernel/exit.c:854
 do_group_exit+0x8e/0x15e kernel/exit.c:1012
 __do_sys_exit_group kernel/exit.c:1023 [inline]
 __wake_up_parent+0x0/0x4a kernel/exit.c:1021
 ret_from_syscall+0x0/0x2

Memory state around the buggy address:
 ff20000003927880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ff20000003927900: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 00 f2 f2
>ff20000003927980: 00 00 00 f3 f3 f3 f3 f3 00 00 00 00 00 00 00 00
                                     ^
 ff20000003927a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ff20000003927a80: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/06/05 20:33 git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git fixes 950b879b7f02 a4ae4f42 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-riscv64 KASAN: stack-out-of-bounds Read in proc_pid_stack
2023/05/05 13:59 git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git fixes 950b879b7f02 acf730dc .config console log report info ci-qemu2-riscv64 KASAN: stack-out-of-bounds Read in proc_pid_stack
2023/05/02 05:39 git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git fixes 950b879b7f02 62df2017 .config console log report info ci-qemu2-riscv64 KASAN: stack-out-of-bounds Read in proc_pid_stack
* Struck through repros no longer work on HEAD.