linux-yocto/kernel/bpf
KaFai Wan e7fb4ebee6 bpf: Avoid __bpf_prog_ret0_warn when jit fails
[ Upstream commit 86bc9c7424 ]

syzkaller reported an issue:

WARNING: CPU: 3 PID: 217 at kernel/bpf/core.c:2357 __bpf_prog_ret0_warn+0xa/0x20 kernel/bpf/core.c:2357
Modules linked in:
CPU: 3 UID: 0 PID: 217 Comm: kworker/u32:6 Not tainted 6.15.0-rc4-syzkaller-00040-g8bac8898fe39
RIP: 0010:__bpf_prog_ret0_warn+0xa/0x20 kernel/bpf/core.c:2357
Call Trace:
 <TASK>
 bpf_dispatcher_nop_func include/linux/bpf.h:1316 [inline]
 __bpf_prog_run include/linux/filter.h:718 [inline]
 bpf_prog_run include/linux/filter.h:725 [inline]
 cls_bpf_classify+0x74a/0x1110 net/sched/cls_bpf.c:105
 ...

When creating bpf program, 'fp->jit_requested' depends on bpf_jit_enable.
This issue is triggered because of CONFIG_BPF_JIT_ALWAYS_ON is not set
and bpf_jit_enable is set to 1, causing the arch to attempt JIT the prog,
but jit failed due to FAULT_INJECTION. As a result, incorrectly
treats the program as valid, when the program runs it calls
`__bpf_prog_ret0_warn` and triggers the WARN_ON_ONCE(1).

Reported-by: syzbot+0903f6d7f285e41cdf10@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/bpf/6816e34e.a70a0220.254cdc.002c.GAE@google.com
Fixes: fa9dd599b4 ("bpf: get rid of pure_initcall dependency to enable jits")
Signed-off-by: KaFai Wan <mannkafai@gmail.com>
Link: https://lore.kernel.org/r/20250526133358.2594176-1-mannkafai@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-27 11:05:14 +01:00
..
preload
arraymap.c bpf: Check percpu map value size first 2024-10-17 15:11:49 +02:00
bpf_inode_storage.c
bpf_iter.c
bpf_local_storage.c bpf: Annotate data races in bpf_local_storage 2023-05-24 17:36:44 +01:00
bpf_lru_list.c bpf: Address KCSAN report on bpf_lru_list 2024-03-01 13:21:55 +01:00
bpf_lru_list.h bpf: Address KCSAN report on bpf_lru_list 2024-03-01 13:21:55 +01:00
bpf_lsm.c
bpf_struct_ops_types.h
bpf_struct_ops.c bpf: Handle return value of BPF_PROG_TYPE_STRUCT_OPS prog 2021-09-14 11:09:50 -07:00
bpf_task_storage.c bpf: Use this_cpu_{inc|dec|inc_return} for bpf_task_storage_busy 2022-10-26 12:34:41 +02:00
btf.c bpf: Eliminate remaining "make W=1" warnings in kernel/bpf/btf.o 2024-08-19 05:44:59 +02:00
cgroup.c bpf: Don't EFAULT for {g,s}setsockopt with wrong optlen 2023-07-23 13:46:49 +02:00
core.c bpf: Avoid __bpf_prog_ret0_warn when jit fails 2025-06-27 11:05:14 +01:00
cpumap.c xdp: Move conversion to xdp_frame out of map functions 2024-05-17 11:50:47 +02:00
devmap.c bpf: fix OOB devmap writes when deleting elements 2024-12-14 19:51:33 +01:00
disasm.c bpf: Relicense disassembler as GPL-2.0-only OR BSD-2-Clause 2021-09-02 14:49:23 +02:00
disasm.h bpf: Relicense disassembler as GPL-2.0-only OR BSD-2-Clause 2021-09-02 14:49:23 +02:00
dispatcher.c
hashtab.c bpf: fix possible endless loop in BPF map iteration 2025-06-04 14:37:54 +02:00
helpers.c bpf: Check rcu_read_lock_trace_held() before calling bpf map helpers 2025-05-02 07:44:21 +02:00
inode.c bpf: Fix mount source show for bpffs 2022-01-27 11:05:26 +01:00
Kconfig
local_storage.c
lpm_trie.c bpf: Fix exact match conditions in trie_get_next_key() 2024-12-14 19:51:31 +01:00
Makefile
map_in_map.c bpf: Defer the free of inner map when necessary 2024-03-26 18:21:12 -04:00
map_in_map.h bpf: Add map and need_defer parameters to .map_fd_put_ptr() 2024-02-23 08:54:42 +01:00
map_iter.c bpf: Introduce MEM_RDONLY flag 2022-05-01 17:22:24 +02:00
net_namespace.c
offload.c bpf: restore the ebpf program ID for BPF_AUDIT_UNLOAD and PERF_BPF_EVENT_PROG_UNLOAD 2023-01-24 07:22:46 +01:00
percpu_freelist.c bpf: Initialize same number of free nodes for each pcpu_freelist 2022-11-26 09:24:38 +01:00
percpu_freelist.h
prog_iter.c
queue_stack_maps.c bpf: Avoid deadlock when using queue and stack maps from NMI 2023-10-06 13:18:04 +02:00
reuseport_array.c
ringbuf.c bpf: Fix overrunning reservations in ringbuf 2024-07-27 10:46:06 +02:00
stackmap.c bpf: Fix stackmap overflow check on 32-bit arches 2024-03-26 18:21:22 -04:00
syscall.c bpf: avoid holding freeze_mutex during mmap operation 2025-05-02 07:44:21 +02:00
sysfs_btf.c
task_iter.c bpf: Consolidate task_struct BTF_ID declarations 2021-08-25 10:37:05 -07:00
tnum.c
trampoline.c x86/ibt,ftrace: Search for __fentry__ location 2024-07-05 09:14:12 +02:00
verifier.c bpf: sync_linked_regs() must preserve subreg_def 2024-12-19 18:07:22 +01:00