bpf: fix WARNING in __bpf_prog_ret0_warn when jit failed
PATCH 1/1 bpf: fix WARNING in __bpf_prog_ret0_warn when jit failed
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 #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Workqueue: ipv6_addrconf addrconf_dad_work RIP: 0010:__bpf_prog_ret0_warn+0xa/0x20 kernel/bpf/core.c:2357 RSP: 0018:ffffc900031f6c18 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffc9000006e000 RCX: 1ffff9200000dc06 RDX: ffff8880234ba440 RSI: ffffffff81ca6979 RDI: ffff888031e93040 RBP: ffffc900031f6cb8 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff88802b61e010 R13: ffff888031e93040 R14: 00000000000000a0 R15: ffff88802c3d4800 FS: 0000000000000000(0000) GS:ffff8880d6ce2000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055557b6d2ca8 CR3: 000000002473e000 CR4: 0000000000352ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 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. Currently the value of bpf_jit_enable is available from 0 to 2, 0 means use interpreter and not jit, 1 and 2 means need to jit. When CONFIG_BPF_JIT_ALWAYS_ON is enabled, bpf_jit_enable is permanently set to 1, when it's not set or disabled, we can set bpf_jit_enable via proc.
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).
--- kernel/bpf/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/core.c +1 -1
@@ -2474,7 +2474,7 @@ struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err)/* In case of BPF to BPF calls, verifier did all the prep * work with regards to JITing, etc. */ -bool jit_needed = false; +bool jit_needed = fp->jit_requested;if (fp->bpf_func) goto finalize;
Signature · 1 line
2.43.0
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 27 lines · On Mon, 26 May 2025 21:33:58 +0800 you wrote:
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 #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Workqueue: ipv6_addrconf addrconf_dad_work RIP: 0010:__bpf_prog_ret0_warn+0xa/0x20 kernel/bpf/core.c:2357 RSP: 0018:ffffc900031f6c18 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffc9000006e000 RCX: 1ffff9200000dc06 RDX: ffff8880234ba440 RSI: ffffffff81ca6979 RDI: ffff888031e93040 RBP: ffffc900031f6cb8 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff88802b61e010 R13: ffff888031e93040 R14: 00000000000000a0 R15: ffff88802c3d4800 FS: 0000000000000000(0000) GS:ffff8880d6ce2000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055557b6d2ca8 CR3: 000000002473e000 CR4: 0000000000352ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 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 ...
Quoted 1 line
[...]
Here is the summary with links:
- [bpf-next,1/1] bpf: fix WARNING in __bpf_prog_ret0_warn when jit failed
https://git.kernel.org/bpf/bpf-next/c/86bc9c742426
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Hi,
Quoted 39 lines · KaFai Wan
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 #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Workqueue: ipv6_addrconf addrconf_dad_work RIP: 0010:__bpf_prog_ret0_warn+0xa/0x20 kernel/bpf/core.c:2357 RSP: 0018:ffffc900031f6c18 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffc9000006e000 RCX: 1ffff9200000dc06 RDX: ffff8880234ba440 RSI: ffffffff81ca6979 RDI: ffff888031e93040 RBP: ffffc900031f6cb8 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff88802b61e010 R13: ffff888031e93040 R14: 00000000000000a0 R15: ffff88802c3d4800 FS: 0000000000000000(0000) GS:ffff8880d6ce2000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055557b6d2ca8 CR3: 000000002473e000 CR4: 0000000000352ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 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 onbpf_jit_enable. Currently the value ofbpf_jit_enableis available from 0 to 2, 0 means use interpreter and not jit, 1 and 2 means need to jit. WhenCONFIG_BPF_JIT_ALWAYS_ONis enabled,bpf_jit_enableis permanently set to 1, when it's not set or disabled, we can setbpf_jit_enablevia proc.This issue is triggered because of
CONFIG_BPF_JIT_ALWAYS_ONis not set andbpf_jit_enableis set to 1, causing the arch to attempt JIT the prog, but jit failed due toFAULT_INJECTION. As a result, incorrectly treats the program as valid, when the program runs it calls__bpf_prog_ret0_warnand triggers theWARN_ON_ONCE(1).
Quoted 4 lines
Reported-by [email protected]Fixes fa9dd599b4da ("bpf: get rid of pure_initcall dependency to enable jits")Signed-off-by KaFai Wan <[email protected]>
I think this patch may have caused a regression in configurations with CONFIG_BPF_JIT_DEFAULT_ON=y when programs can't be JITed. Attaching the program fails with error -ENOTSUPP.
Please see https://github.com/openwrt/openwrt/issues/19405 for more information.
- Felix
Yonghong Song
reviewerQuoted 42 lines · Felix Fietkau
Hi,
Quoted 39 lines · KaFai Wan
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 #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Workqueue: ipv6_addrconf addrconf_dad_work RIP: 0010:__bpf_prog_ret0_warn+0xa/0x20 kernel/bpf/core.c:2357 RSP: 0018:ffffc900031f6c18 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffc9000006e000 RCX: 1ffff9200000dc06 RDX: ffff8880234ba440 RSI: ffffffff81ca6979 RDI: ffff888031e93040 RBP: ffffc900031f6cb8 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff88802b61e010 R13: ffff888031e93040 R14: 00000000000000a0 R15: ffff88802c3d4800 FS: 0000000000000000(0000) GS:ffff8880d6ce2000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055557b6d2ca8 CR3: 000000002473e000 CR4: 0000000000352ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 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 onbpf_jit_enable. Currently the value ofbpf_jit_enableis available from 0 to 2, 0 means use interpreter and not jit, 1 and 2 means need to jit. WhenCONFIG_BPF_JIT_ALWAYS_ONis enabled,bpf_jit_enableis permanently set to 1, when it's not set or disabled, we can setbpf_jit_enablevia proc.This issue is triggered because of
CONFIG_BPF_JIT_ALWAYS_ONis not set andbpf_jit_enableis set to 1, causing the arch to attempt JIT the prog, but jit failed due toFAULT_INJECTION. As a result, incorrectly treats the program as valid, when the program runs it calls__bpf_prog_ret0_warnand triggers theWARN_ON_ONCE(1).
Quoted 6 lines
Quoted 4 lines
Reported-by [email protected]Fixes fa9dd599b4da ("bpf: get rid of pure_initcall dependency to enable jits")Signed-off-by KaFai Wan <[email protected]>I think this patch may have caused a regression in configurations with
CONFIG_BPF_JIT_DEFAULT_ON=ywhen programs can't be JITed. Attaching the program fails with error-ENOTSUPP.
Could you explain why there is an issue here?CONFIG_BPF_JIT_DEFAULT_ON=y but prog cannot be jit'ed. So the end result is to return -ENOTSUPP. It looks okay to me since the jit is required but jit failed, the only choice for the kernel is to return an error.
Quoted 4 lines
Please see https://github.com/openwrt/openwrt/issues/19405 for more information.
- Felix
Yonghong Song
reviewerQuoted 50 lines · Yonghong Song
Quoted 48 lines · Felix Fietkau
Hi,
Quoted 44 lines · KaFai Wan
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 #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Workqueue: ipv6_addrconf addrconf_dad_work RIP: 0010:__bpf_prog_ret0_warn+0xa/0x20 kernel/bpf/core.c:2357 RSP: 0018:ffffc900031f6c18 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffc9000006e000 RCX: 1ffff9200000dc06 RDX: ffff8880234ba440 RSI: ffffffff81ca6979 RDI: ffff888031e93040 RBP: ffffc900031f6cb8 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff88802b61e010 R13: ffff888031e93040 R14: 00000000000000a0 R15: ffff88802c3d4800 FS: 0000000000000000(0000) GS:ffff8880d6ce2000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055557b6d2ca8 CR3: 000000002473e000 CR4: 0000000000352ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 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 onbpf_jit_enable. Currently the value ofbpf_jit_enableis available from 0 to 2, 0 means use interpreter and not jit, 1 and 2 means need to jit. WhenCONFIG_BPF_JIT_ALWAYS_ONis enabled,bpf_jit_enableis permanently set to 1, when it's not set or disabled, we can setbpf_jit_enablevia proc.This issue is triggered because of
CONFIG_BPF_JIT_ALWAYS_ONis not set andbpf_jit_enableis set to 1, causing the arch to attempt JIT the prog, but jit failed due toFAULT_INJECTION. As a result, incorrectly treats the program as valid, when the program runs it calls__bpf_prog_ret0_warnand triggers theWARN_ON_ONCE(1).Reported-by [email protected]Fixes fa9dd599b4da ("bpf: get rid of pure_initcall dependency to enable jits")Signed-off-by KaFai Wan <[email protected]>
Quoted 6 lines
Quoted 1 line
I think this patch may have caused a regression in configurations with
CONFIG_BPF_JIT_DEFAULT_ON=ywhen programs can't be JITed. Attaching the program fails with error-ENOTSUPP.Could you explain why there is an issue here?
CONFIG_BPF_JIT_DEFAULT_ON=ybut prog cannot be jit'ed. So the end result is to return-ENOTSUPP. It looks okay to me since the jit is required but jit failed, the only choice for the kernel is to return an error.
BTW, you mentioned programs cannot be jited. Could you explain why programs cannot be jitted? It would be strange that a program cannot be jitted but can be interpreted.
Quoted 7 lines
Quoted 5 lines
Please see https://github.com/openwrt/openwrt/issues/19405 for more information.
- Felix