bisecting cause commit starting from 89099d855bf084c3e428ca257b50d77d1a468437 building syzkaller on 1656845f45f284c574eb4f8bfe85dd7916a47a3a testing commit 89099d855bf084c3e428ca257b50d77d1a468437 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 89099d855bf084c3e428ca257b50d77d1a468437 v5.2 Bisecting: 6217 revisions left to test after this (roughly 13 steps) [97ff4ca46d3279134cec49752de8c5a62dc68460] Merge tag 'char-misc-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc testing commit 97ff4ca46d3279134cec49752de8c5a62dc68460 with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad 97ff4ca46d3279134cec49752de8c5a62dc68460 Bisecting: 3095 revisions left to test after this (roughly 12 steps) [7011b7e1b702cc76f9e969b41d9a95969f2aecaa] Merge tag 'printk-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk testing commit 7011b7e1b702cc76f9e969b41d9a95969f2aecaa with gcc (GCC) 8.1.0 all runs: OK # git bisect good 7011b7e1b702cc76f9e969b41d9a95969f2aecaa Bisecting: 1562 revisions left to test after this (roughly 11 steps) [f6dc1264f1c01976a84239d1038359604ee42001] net/mlx5e: Disallow tc redirect offload cases we don't support testing commit f6dc1264f1c01976a84239d1038359604ee42001 with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad f6dc1264f1c01976a84239d1038359604ee42001 Bisecting: 766 revisions left to test after this (roughly 10 steps) [48debfd736d5cb5d26f973d71ec3933f12f9b61c] Merge branch 'net-Enable-nexthop-objects-with-IPv4-and-IPv6-routes' testing commit 48debfd736d5cb5d26f973d71ec3933f12f9b61c with gcc (GCC) 8.1.0 all runs: OK # git bisect good 48debfd736d5cb5d26f973d71ec3933f12f9b61c Bisecting: 383 revisions left to test after this (roughly 9 steps) [0e09edcce7ad9c8120eb8462334e1c9e8f3be09a] ipv6: introduce RT6_LOOKUP_F_DST_NOREF flag in ip6_pol_route() testing commit 0e09edcce7ad9c8120eb8462334e1c9e8f3be09a with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad 0e09edcce7ad9c8120eb8462334e1c9e8f3be09a Bisecting: 191 revisions left to test after this (roughly 8 steps) [d346c9e86d8685d7cdceddf5b2e9c4376334620c] dpaa2-ptp: reuse ptp_qoriq driver testing commit d346c9e86d8685d7cdceddf5b2e9c4376334620c with gcc (GCC) 8.1.0 all runs: OK # git bisect good d346c9e86d8685d7cdceddf5b2e9c4376334620c Bisecting: 95 revisions left to test after this (roughly 7 steps) [dcc5e1f9cad0e31198c4a4254981928299b49054] selftests: tc: add ingress device matching support testing commit dcc5e1f9cad0e31198c4a4254981928299b49054 with gcc (GCC) 8.1.0 all runs: OK # git bisect good dcc5e1f9cad0e31198c4a4254981928299b49054 Bisecting: 47 revisions left to test after this (roughly 6 steps) [aeee380ccfc59c05a4c6e8e762fd645c6bdc773a] selftests/bpf: fix tests testing commit aeee380ccfc59c05a4c6e8e762fd645c6bdc773a with gcc (GCC) 8.1.0 all runs: crashed: KASAN: slab-out-of-bounds Read in do_jit # git bisect bad aeee380ccfc59c05a4c6e8e762fd645c6bdc773a Bisecting: 23 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: 11 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: 5 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: 2 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: 0 revisions 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: 3h35m58.592420783s (build: 1h32m25.246770178s, test: 1h58m43.761075479s) 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 ffff8880a42813fc by task syz-executor.3/7555 CPU: 1 PID: 7555 Comm: syz-executor.3 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+0x113/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+0x2fd/0xb1c /arch/x86/net/bpf_jit_comp.c:1168 bpf_prog_select_runtime+0x43e/0x850 /kernel/bpf/core.c:1730 bpf_prog_load+0xaeb/0x1210 /kernel/bpf/syscall.c:1700 __do_sys_bpf+0x9d4/0x33a0 /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:00007fba57a6cc78 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: 00007fba57a6d6d4 R13: 00000000004bfc7c R14: 00000000004d16d8 R15: 00000000ffffffff Allocated by task 1: 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_track_caller+0x159/0x750 /mm/slab.c:3675 kstrdup+0x2c/0x60 /mm/util.c:52 kstrdup_const+0x1f/0x30 /mm/util.c:74 kvasprintf_const+0xce/0x140 /lib/kasprintf.c:48 kobject_set_name_vargs+0x46/0x120 /lib/kobject.c:289 kobject_add_varg /lib/kobject.c:384 [inline] kobject_init_and_add+0xa9/0x120 /lib/kobject.c:473 bus_add_driver+0x1ca/0x4f0 /drivers/base/bus.c:638 driver_register+0x18e/0x320 /drivers/base/driver.c:170 acpi_bus_register_driver+0xf3/0x130 /drivers/acpi/bus.c:871 crb_acpi_driver_init+0x10/0x12 /drivers/char/tpm/tpm_crb.c:695 do_one_initcall+0xbc/0x545 /init/main.c:915 do_initcall_level /init/main.c:983 [inline] do_initcalls /init/main.c:991 [inline] do_basic_setup /init/main.c:1009 [inline] kernel_init_freeable+0x461/0x500 /init/main.c:1169 kernel_init+0xc/0x107 /init/main.c:1087 ret_from_fork+0x24/0x30 /arch/x86/entry/entry_64.S:352 Freed by task 0: (stack is not available) The buggy address belongs to the object at ffff8880a42813c0 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 28 bytes to the right of 32-byte region [ffff8880a42813c0, ffff8880a42813e0) The buggy address belongs to the page: page:ffffea000290a040 refcount:1 mapcount:0 mapping:ffff8880aa4001c0 index:0xffff8880a4281fc1 flags: 0x1fffc0000000200(slab) raw: 01fffc0000000200 ffffea0002a90308 ffffea00028fba08 ffff8880aa4001c0 raw: ffff8880a4281fc1 ffff8880a4281000 000000010000003f 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a4281280: 00 00 fc fc fc fc fc fc 00 00 fc fc fc fc fc fc ffff8880a4281300: 00 00 fc fc fc fc fc fc 00 00 fc fc fc fc fc fc >ffff8880a4281380: fb fb fb fb fc fc fc fc 00 fc fc fc fc fc fc fc ^ ffff8880a4281400: 00 00 fc fc fc fc fc fc fb fb fb fb fc fc fc fc ffff8880a4281480: fb fb fb fb fc fc fc fc 07 fc fc fc fc fc fc fc ==================================================================