bisecting cause commit starting from c6dd78fcb8eefa15dd861889e0f59d301cb5230c building syzkaller on 1656845f45f284c574eb4f8bfe85dd7916a47a3a testing commit c6dd78fcb8eefa15dd861889e0f59d301cb5230c with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit testing release v5.2 testing commit 0ecfebd2b52404ae0c54a878c872bb93363ada36 with gcc (GCC) 8.1.0 all runs: OK # git bisect start c6dd78fcb8eefa15dd861889e0f59d301cb5230c v5.2 Bisecting: 6613 revisions left to test after this (roughly 13 steps) [e786741ff1b52769b044b7f4407f39cd13ee5d2d] Merge tag 'staging-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging testing commit e786741ff1b52769b044b7f4407f39cd13ee5d2d with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad e786741ff1b52769b044b7f4407f39cd13ee5d2d Bisecting: 3396 revisions left to test after this (roughly 12 steps) [8f6ccf6159aed1f04c6d179f61f6fb2691261e84] Merge tag 'clone3-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux testing commit 8f6ccf6159aed1f04c6d179f61f6fb2691261e84 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 8f6ccf6159aed1f04c6d179f61f6fb2691261e84 Bisecting: 1693 revisions left to test after this (roughly 11 steps) [c4cde5804d512a2f8934017dbf7df642dfbdf2ad] Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next testing commit c4cde5804d512a2f8934017dbf7df642dfbdf2ad with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad c4cde5804d512a2f8934017dbf7df642dfbdf2ad Bisecting: 851 revisions left to test after this (roughly 10 steps) [fefa9cfddf29a7c76ab052d13c2ef7170d9d6511] i40e: Check if the BAR size is large enough before writing to registers testing commit fefa9cfddf29a7c76ab052d13c2ef7170d9d6511 with gcc (GCC) 8.1.0 all runs: OK # git bisect good fefa9cfddf29a7c76ab052d13c2ef7170d9d6511 Bisecting: 456 revisions left to test after this (roughly 9 steps) [fae6cad17ce39b4c03e5c9f2315d2e511a1c8cb4] i40e/i40e_virtchnl_pf: Use struct_size() in kzalloc() testing commit fae6cad17ce39b4c03e5c9f2315d2e511a1c8cb4 with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad fae6cad17ce39b4c03e5c9f2315d2e511a1c8cb4 Bisecting: 197 revisions left to test after this (roughly 8 steps) [9558a83aee62be7c3ce9eddd6484a5da16aad4cf] net: flow_offload: implement support for meta key testing commit 9558a83aee62be7c3ce9eddd6484a5da16aad4cf with gcc (GCC) 8.1.0 all runs: OK # git bisect good 9558a83aee62be7c3ce9eddd6484a5da16aad4cf Bisecting: 98 revisions left to test after this (roughly 7 steps) [08003d0b63a63bebaccca90e2f1d628dfd66cd4d] inet: fix compilation warnings in fqdir_pre_exit() testing commit 08003d0b63a63bebaccca90e2f1d628dfd66cd4d with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad 08003d0b63a63bebaccca90e2f1d628dfd66cd4d Bisecting: 49 revisions left to test after this (roughly 6 steps) [0d3679e99ae4b7868da22e3b8540fd597df501f5] selftests/bpf: add basic verifier tests for loops testing commit 0d3679e99ae4b7868da22e3b8540fd597df501f5 with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad 0d3679e99ae4b7868da22e3b8540fd597df501f5 Bisecting: 24 revisions left to test after this (roughly 5 steps) [fb85c4a730af221339c1dde1a434b73da0dfc3ed] bpf: export bpf_sock for BPF_PROG_TYPE_CGROUP_SOCK_ADDR prog type testing commit fb85c4a730af221339c1dde1a434b73da0dfc3ed with gcc (GCC) 8.1.0 all runs: OK # git bisect good fb85c4a730af221339c1dde1a434b73da0dfc3ed Bisecting: 12 revisions left to test after this (roughly 4 steps) [9e3d709c47ca3d10df461635b350edef94f3cf11] selftests/bpf: add test for BTF-defined maps testing commit 9e3d709c47ca3d10df461635b350edef94f3cf11 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 9e3d709c47ca3d10df461635b350edef94f3cf11 Bisecting: 6 revisions left to test after this (roughly 3 steps) [a324aae32fa9bfdd03e89078e20ebcbd7737fda5] libbpf: constify getter APIs testing commit a324aae32fa9bfdd03e89078e20ebcbd7737fda5 with gcc (GCC) 8.1.0 all runs: OK # git bisect good a324aae32fa9bfdd03e89078e20ebcbd7737fda5 Bisecting: 3 revisions left to test after this (roughly 2 steps) [fb8d251ee2a6bf4d7f4af5548e9c8f4fb5f90402] bpf: extend is_branch_taken to registers testing commit fb8d251ee2a6bf4d7f4af5548e9c8f4fb5f90402 with gcc (GCC) 8.1.0 all runs: OK # git bisect good fb8d251ee2a6bf4d7f4af5548e9c8f4fb5f90402 Bisecting: 1 revision left to test after this (roughly 1 step) [eea1c227b9e9bad295e8ef984004a9acf12bb68c] bpf: fix callees pruning callers testing commit eea1c227b9e9bad295e8ef984004a9acf12bb68c with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad eea1c227b9e9bad295e8ef984004a9acf12bb68c Bisecting: 0 revisions left to test after this (roughly 0 steps) [2589726d12a1b12eaaa93c7f1ea64287e383c7a5] bpf: introduce bounded loops testing commit 2589726d12a1b12eaaa93c7f1ea64287e383c7a5 with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad 2589726d12a1b12eaaa93c7f1ea64287e383c7a5 2589726d12a1b12eaaa93c7f1ea64287e383c7a5 is the first bad commit commit 2589726d12a1b12eaaa93c7f1ea64287e383c7a5 Author: Alexei Starovoitov Date: Sat Jun 15 12:12:20 2019 -0700 bpf: introduce bounded loops Allow the verifier to validate the loops by simulating their execution. Exisiting programs have used '#pragma unroll' to unroll the loops by the compiler. Instead let the verifier simulate all iterations of the loop. In order to do that introduce parentage chain of bpf_verifier_state and 'branches' counter for the number of branches left to explore. See more detailed algorithm description in bpf_verifier.h This algorithm borrows the key idea from Edward Cree approach: https://patchwork.ozlabs.org/patch/877222/ Additional state pruning heuristics make such brute force loop walk practical even for large loops. Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko Signed-off-by: Daniel Borkmann :040000 040000 7cf697097cf69d283447c39c838d19a50729a9de b6bdcad41c7f3f96714618b20aa412e61d714146 M include :040000 040000 5e442a4f6ebc8d02a776ca0ab286a9f0ba02d069 855b680081fd096523b374e648491043abb28d35 M kernel revisions tested: 16, total time: 3h29m2.907080561s (build: 1h30m58.625577113s, test: 1h53m13.290782515s) first bad commit: 2589726d12a1b12eaaa93c7f1ea64287e383c7a5 bpf: introduce bounded loops cc: ["andriin@fb.com" "ast@kernel.org" "bpf@vger.kernel.org" "daniel@iogearbox.net" "kafai@fb.com" "linux-kernel@vger.kernel.org" "netdev@vger.kernel.org" "songliubraving@fb.com" "yhs@fb.com"] crash: KASAN: slab-out-of-bounds Read in do_jit ================================================================== BUG: KASAN: slab-out-of-bounds in do_jit.isra.2+0x44c6/0x5770 /arch/x86/net/bpf_jit_comp.c:997 Read of size 4 at addr ffff888089a42cfc by task syz-executor.2/7570 CPU: 1 PID: 7570 Comm: syz-executor.2 Not tainted 5.2.0-rc2+ #1 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack /lib/dump_stack.c:77 [inline] dump_stack+0x115/0x167 /lib/dump_stack.c:113 print_address_description.cold.5+0x9/0x1ff /mm/kasan/report.c:188 __kasan_report.cold.6+0x1b/0x39 /mm/kasan/report.c:317 kasan_report+0x12/0x20 /mm/kasan/common.c:614 __asan_report_load4_noabort+0x14/0x20 /mm/kasan/generic_report.c:131 do_jit.isra.2+0x44c6/0x5770 /arch/x86/net/bpf_jit_comp.c:997 bpf_int_jit_compile+0x302/0xb21 /arch/x86/net/bpf_jit_comp.c:1168 bpf_prog_select_runtime+0x43e/0x850 /kernel/bpf/core.c:1730 bpf_prog_load+0xaeb/0x1200 /kernel/bpf/syscall.c:1700 __do_sys_bpf+0x90a/0x3330 /kernel/bpf/syscall.c:2830 __se_sys_bpf /kernel/bpf/syscall.c:2789 [inline] __x64_sys_bpf+0x6e/0xb0 /kernel/bpf/syscall.c:2789 do_syscall_64+0xd0/0x530 /arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x459819 Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 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 0f 83 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007fb097662c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000459819 RDX: 0000000000000046 RSI: 0000000020000180 RDI: 0000000000000005 RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007fb0976636d4 R13: 00000000004bfc7c R14: 00000000004d16d8 R15: 00000000ffffffff Allocated by task 7294: save_stack+0x21/0x90 /mm/kasan/common.c:71 set_track /mm/kasan/common.c:79 [inline] __kasan_kmalloc.constprop.8+0xc7/0xd0 /mm/kasan/common.c:489 kasan_kmalloc+0x9/0x10 /mm/kasan/common.c:503 __do_kmalloc /mm/slab.c:3660 [inline] __kmalloc+0x15d/0x740 /mm/slab.c:3669 kmalloc /./include/linux/slab.h:552 [inline] kzalloc /./include/linux/slab.h:742 [inline] tomoyo_encode2.part.2+0x97/0x360 /security/tomoyo/realpath.c:44 tomoyo_encode2 /security/tomoyo/realpath.c:30 [inline] tomoyo_encode+0x1c/0x30 /security/tomoyo/realpath.c:79 tomoyo_realpath_from_path+0x168/0x790 /security/tomoyo/realpath.c:316 tomoyo_get_realpath /security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x203/0x380 /security/tomoyo/file.c:822 tomoyo_inode_getattr+0x13/0x20 /security/tomoyo/tomoyo.c:129 security_inode_getattr+0xb0/0x100 /security/security.c:1183 vfs_getattr+0x1c/0x40 /fs/stat.c:115 vfs_statx+0xd8/0x150 /fs/stat.c:191 vfs_fstatat /./include/linux/fs.h:3204 [inline] __do_sys_newfstatat+0x7d/0xd0 /fs/stat.c:368 __se_sys_newfstatat /fs/stat.c:362 [inline] __x64_sys_newfstatat+0x92/0xf0 /fs/stat.c:362 do_syscall_64+0xd0/0x530 /arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 7294: save_stack+0x21/0x90 /mm/kasan/common.c:71 set_track /mm/kasan/common.c:79 [inline] __kasan_slab_free+0x102/0x150 /mm/kasan/common.c:451 kasan_slab_free+0xe/0x10 /mm/kasan/common.c:459 __cache_free /mm/slab.c:3432 [inline] kfree+0xcf/0x210 /mm/slab.c:3755 tomoyo_path_perm+0x218/0x380 /security/tomoyo/file.c:842 tomoyo_inode_getattr+0x13/0x20 /security/tomoyo/tomoyo.c:129 security_inode_getattr+0xb0/0x100 /security/security.c:1183 vfs_getattr+0x1c/0x40 /fs/stat.c:115 vfs_statx+0xd8/0x150 /fs/stat.c:191 vfs_fstatat /./include/linux/fs.h:3204 [inline] __do_sys_newfstatat+0x7d/0xd0 /fs/stat.c:368 __se_sys_newfstatat /fs/stat.c:362 [inline] __x64_sys_newfstatat+0x92/0xf0 /fs/stat.c:362 do_syscall_64+0xd0/0x530 /arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff888089a42cc0 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 28 bytes to the right of 32-byte region [ffff888089a42cc0, ffff888089a42ce0) The buggy address belongs to the page: page:ffffea0002269080 refcount:1 mapcount:0 mapping:ffff8880aa4001c0 index:0xffff888089a42fc1 flags: 0x1fffc0000000200(slab) raw: 01fffc0000000200 ffffea0002a56b48 ffffea00027ea408 ffff8880aa4001c0 raw: ffff888089a42fc1 ffff888089a42000 000000010000003f 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888089a42b80: fb fb fb fb fc fc fc fc 00 01 fc fc fc fc fc fc ffff888089a42c00: 00 00 06 fc fc fc fc fc fb fb fb fb fc fc fc fc >ffff888089a42c80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ^ ffff888089a42d00: 00 00 fc fc fc fc fc fc 00 00 00 00 fc fc fc fc ffff888089a42d80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ==================================================================