syzbot


KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof

Status: upstream: reported C repro on 2024/11/25 02:50
Subsystems: bpf
[Documentation on labels]
Reported-by: syzbot+7d9959e6503e8ffc8558@syzkaller.appspotmail.com
Fix commit: d699440f58ce mm: fix vrealloc()'s KASAN poisoning logic
Patched on: [ci-qemu-gce-upstream-auto ci-qemu-native-arm64-kvm ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-qemu2-riscv64 ci-snapshot-upstream-root ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-arm64 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 ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-fs ci2-upstream-kcsan-gce ci2-upstream-usb], missing on: [ci-qemu2-arm32]
First crash: 30d, last: 20h19m
Cause bisection: introduced by (bisect log) :
commit 96a30e469ca1d2b8cc7811b40911f8614b558241
Author: Andrii Nakryiko <andrii@kernel.org>
Date: Fri Nov 15 00:13:03 2024 +0000

  bpf: use common instruction history across all states

Crash: KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof (log)
Repro: C syz .config
  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [bpf?] KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof 2 (3) 2024/11/26 00:54

Sample crash report:
==================================================================
BUG: KASAN: vmalloc-out-of-bounds in vrealloc_noprof+0x340/0x3a0 mm/vmalloc.c:4095
Write of size 2097120 at addr ffffc9000c600020 by task syz-executor382/5856

CPU: 1 UID: 0 PID: 5856 Comm: syz-executor382 Not tainted 6.12.0-next-20241120-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:489
 kasan_report+0x143/0x180 mm/kasan/report.c:602
 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189
 __asan_memset+0x23/0x50 mm/kasan/shadow.c:84
 vrealloc_noprof+0x340/0x3a0 mm/vmalloc.c:4095
 push_insn_history+0x16c/0x6a0 kernel/bpf/verifier.c:3571
 check_mem_access+0xf30/0x2240 kernel/bpf/verifier.c:7267
 do_check+0x7d97/0xfcd0 kernel/bpf/verifier.c:18703
 do_check_common+0x1564/0x2010 kernel/bpf/verifier.c:21848
 do_check_main kernel/bpf/verifier.c:21939 [inline]
 bpf_check+0x19380/0x1f1b0 kernel/bpf/verifier.c:22656
 bpf_prog_load+0x1667/0x20f0 kernel/bpf/syscall.c:2947
 __sys_bpf+0x4ee/0x810 kernel/bpf/syscall.c:5790
 __do_sys_bpf kernel/bpf/syscall.c:5897 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5895 [inline]
 __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5895
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f82b1a0e2f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 17 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:00007fffa78fc1f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f82b1a0e2f9
RDX: 0000000000000090 RSI: 0000000020000840 RDI: 0000000000000005
RBP: 000000000003551f R08: 0000000000000000 R09: 00007fffa78fc21c
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fffa78fc21c
R13: 431bde82d7b634db R14: 00007fffa78fc230 R15: 0000000000000001
 </TASK>

The buggy address belongs to the virtual mapping at
 [ffffc9000c200000, ffffc9000c801000) created by:
 kvrealloc_noprof+0xc7/0x120 mm/util.c:747

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x6da00
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 0x102cc2(GFP_HIGHUSER|__GFP_NOWARN), pid 5856, tgid 5856 (syz-executor382), ts 245334294068, free_ts 15243076114
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1556
 prep_new_page mm/page_alloc.c:1564 [inline]
 get_page_from_freelist+0x3725/0x3870 mm/page_alloc.c:3510
 __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4787
 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
 vm_area_alloc_pages mm/vmalloc.c:3589 [inline]
 __vmalloc_area_node mm/vmalloc.c:3667 [inline]
 __vmalloc_node_range_noprof+0x9c9/0x1380 mm/vmalloc.c:3844
 __kvmalloc_node_noprof+0x142/0x190 mm/util.c:672
 kvrealloc_noprof+0xc7/0x120 mm/util.c:747
 push_insn_history+0x16c/0x6a0 kernel/bpf/verifier.c:3571
 check_mem_access+0xf30/0x2240 kernel/bpf/verifier.c:7267
 do_check+0x7d97/0xfcd0 kernel/bpf/verifier.c:18703
 do_check_common+0x1564/0x2010 kernel/bpf/verifier.c:21848
 do_check_main kernel/bpf/verifier.c:21939 [inline]
 bpf_check+0x19380/0x1f1b0 kernel/bpf/verifier.c:22656
 bpf_prog_load+0x1667/0x20f0 kernel/bpf/syscall.c:2947
 __sys_bpf+0x4ee/0x810 kernel/bpf/syscall.c:5790
 __do_sys_bpf kernel/bpf/syscall.c:5897 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5895 [inline]
 __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5895
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
page last free pid 1 tgid 1 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1127 [inline]
 free_unref_page+0xdf9/0x1140 mm/page_alloc.c:2693
 free_contig_range+0x152/0x550 mm/page_alloc.c:6666
 destroy_args+0x92/0x910 mm/debug_vm_pgtable.c:1017
 debug_vm_pgtable+0x4be/0x550 mm/debug_vm_pgtable.c:1397
 do_one_initcall+0x248/0x880 init/main.c:1266
 do_initcall_level+0x157/0x210 init/main.c:1328
 do_initcalls+0x3f/0x80 init/main.c:1344
 kernel_init_freeable+0x435/0x5d0 init/main.c:1577
 kernel_init+0x1d/0x2b0 init/main.c:1466
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Memory state around the buggy address:
 ffffc9000c5fff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffffc9000c5fff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffffc9000c600000: 00 00 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
                               ^
 ffffc9000c600080: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
 ffffc9000c600100: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================

Crashes (46):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/22 03:43 linux-next ac24e26aa08f 4b25d554 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/22 00:18 linux-next ac24e26aa08f 4b25d554 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/21 20:20 linux-next ac24e26aa08f 4b25d554 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/21 11:50 linux-next ac24e26aa08f 4b25d554 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/01 01:51 upstream 0e287d31b62b 68914665 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/20 18:17 upstream 8faabc041a00 49cfeac8 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/20 15:37 upstream 8faabc041a00 49cfeac8 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/18 12:23 upstream 59dbb9d81adf a0626d3a .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/18 10:36 upstream 59dbb9d81adf a0626d3a .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/17 19:26 upstream 59dbb9d81adf bc1a1b50 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/17 05:34 upstream f44d154d6e3d f93b2b55 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/16 02:45 upstream dccbe2047a5b 7cbfbb3a .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/16 01:55 upstream dccbe2047a5b 7cbfbb3a .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/15 13:15 upstream 2d8308bf5b67 7cbfbb3a .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/14 23:03 upstream a446e965a188 7cbfbb3a .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/14 12:03 upstream 4800575d8c0b 7cbfbb3a .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/10 04:19 upstream 7cb1b4663150 deb72877 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/09 13:27 upstream fac04efc5c79 9ac0fdc6 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/08 13:41 upstream 7503345ac5f5 9ac0fdc6 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/07 08:16 upstream b5f217084ab3 9ac0fdc6 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/04 19:56 upstream feffde684ac2 b50eb251 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/04 05:39 upstream ceb8bf2ceaa7 b50eb251 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/04 00:29 upstream ceb8bf2ceaa7 b50eb251 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/03 00:20 upstream cdd30ebb1b9f bb326ffb .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/02 01:56 upstream f788b5ef1ca9 68914665 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/01 00:00 upstream d8b78066f4c9 68914665 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/30 10:49 upstream 2ba9f676d0a2 68914665 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/30 08:54 upstream 2ba9f676d0a2 68914665 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/29 23:02 upstream 7af08b57bcb9 b5d2be89 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/29 20:13 upstream 7af08b57bcb9 b5d2be89 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/28 12:06 upstream b86545e02e8c 5df23865 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/27 23:37 upstream aaf20f870da0 5df23865 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/27 09:31 upstream 445d9f05fa14 52b38cc1 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/26 07:00 upstream 2c22dc1ee3a1 11dbc254 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/25 06:04 upstream 9f16d5e6f220 68da6d95 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/25 02:13 upstream 9f16d5e6f220 68da6d95 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/24 05:08 upstream 9f16d5e6f220 68da6d95 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/24 04:51 upstream 9f16d5e6f220 68da6d95 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/24 01:32 upstream 228a1157fb9f 68da6d95 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/24 00:02 upstream 228a1157fb9f 68da6d95 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/22 08:39 upstream 28eb75e178d3 4b25d554 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/05 15:27 bpf e2cf913314b9 6e50d07b .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-kasan-gce KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/02 05:39 bpf 537a2525eaf7 68914665 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-kasan-gce KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/12/13 10:34 bpf-next f4f25b689b0d 3547e30f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-next-kasan-gce KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
2024/11/21 02:43 linux-next ac24e26aa08f 4fca1650 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: vmalloc-out-of-bounds Write in vrealloc_noprof
* Struck through repros no longer work on HEAD.