* [PATCH bpf-next v3 1/4] bpf: Determine freplace staticness from BTF linkage
2026-10-18 0:53 [PATCH bpf-next v3 0/4] selftests/bpf: Fix selftests fails with clang23 KaFai Wan
@ 2026-10-18 0:53 ` KaFai Wan
2026-10-18 0:53 ` [PATCH bpf-next v3 2/4] selftests/bpf: Fix stack_arg precision backtracking log expectation KaFai Wan
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: KaFai Wan @ 2026-10-18 0:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Ihor Solodrai, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, Leon Hwang,
Donggeun Yoo, Menglong Dong, KaFai Wan, Mykyta Yatsenko,
Feng Jiang, Vineet Gupta, Puranjay Mohan, bpf, linux-kernel,
linux-kselftest, llvm
bpf_check_attach_target() rejects a freplace whose target is a static
function, using the subprog "unreliable" flag as a proxy for "static".
That flag is raised whenever a subprogram's BTF prototype disagrees with
the registers at its call site.
`147400e9c27c ("bpf: Compute parameters liveness in
bpf_compute_live_registers()")` made that work for static callees: a
static function with an unused argument no longer matches its BTF
prototype at the call site and is marked unreliable.
Since LLVM commit `29b36a16f111 ("[BPF] Emit ABI-accurate BTF
prototypes for DW_CC_nocall")` in 23.1 [1] that premise is gone:
BTFDebug may now drop arguments removed by the optimizer, so for
__noinline static int subprog(struct __sk_buff *ctx)
{
return bpf_ktime_get_ns();
}
compiled with clang 23 the BTF describes subprog() as
[75] FUNC_PROTO '(anon)' ret_type_id=2 vlen=0
[76] FUNC 'subprog' type_id=75 linkage=static
There is then no argument left to compare, the subprog stays reliable,
and the check in bpf_check_attach_target() is skipped. The freplace is
then rejected by the later linkage check instead, reporting "subprog()
is not a global function", and the selftest "exceptions" fails.
Determine staticness from the BTF linkage instead, and keep the
unreliable check for global functions whose BTF does not match their
call site.
There is no functional change: freplacing a static function was rejected
before and is still rejected with the same -EINVAL. Selftest "exceptions"
is updated to match.
[1] https://github.com/llvm/llvm-project/pull/198426
Fixes: 147400e9c27c ("bpf: Compute parameters liveness in bpf_compute_live_registers()")
Signed-off-by: KaFai Wan <kafai.wan@linux.dev>
---
kernel/bpf/verifier.c | 3 ++-
tools/testing/selftests/bpf/prog_tests/exceptions.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 2c812a5f1da87..519af2766032a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -22228,7 +22228,8 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,
}
conservative = aux->func_info_aux[subprog].unreliable;
if (prog_extension) {
- if (conservative) {
+ if (aux->func_info_aux[subprog].linkage != BTF_FUNC_GLOBAL ||
+ conservative) {
bpf_log(log,
"Cannot replace static functions\n");
return -EINVAL;
diff --git a/tools/testing/selftests/bpf/prog_tests/exceptions.c b/tools/testing/selftests/bpf/prog_tests/exceptions.c
index cea01d638f6fc..1bd15c4c125ba 100644
--- a/tools/testing/selftests/bpf/prog_tests/exceptions.c
+++ b/tools/testing/selftests/bpf/prog_tests/exceptions.c
@@ -333,7 +333,7 @@ static void test_exceptions_success(void)
bpf_program__fd(skel->progs.exception_throw_subprog),
"throwing_subprog"), "set_attach_target"))
goto done;
- }), "throwing_subprog() is not a global function", 0);
+ }), "Cannot replace static functions", 0);
if (test__start_subtest("non-throwing extension -> non-throwing subprog"))
/* non-throwing extension -> non-throwing global subprog : OK */
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH bpf-next v3 2/4] selftests/bpf: Fix stack_arg precision backtracking log expectation
2026-10-18 0:53 [PATCH bpf-next v3 0/4] selftests/bpf: Fix selftests fails with clang23 KaFai Wan
2026-10-18 0:53 ` [PATCH bpf-next v3 1/4] bpf: Determine freplace staticness from BTF linkage KaFai Wan
@ 2026-10-18 0:53 ` KaFai Wan
2026-10-18 0:53 ` [PATCH bpf-next v3 3/4] selftests/bpf: Fix stack arg pruning test JOIN " KaFai Wan
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: KaFai Wan @ 2026-10-18 0:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Ihor Solodrai, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, Leon Hwang,
Donggeun Yoo, Menglong Dong, KaFai Wan, Mykyta Yatsenko,
Feng Jiang, Vineet Gupta, Puranjay Mohan, bpf, linux-kernel,
linux-kselftest, llvm
Commit 147400e9c27c ("bpf: Compute parameters liveness in
bpf_compute_live_registers()") stopped assuming that a call to a static
subprogram reads r1..r5 and now uses the callee's entry live-in. R1-R5 are
not live at these call insns, so __clean_func_state() clears them from the
caller state and the backtracked parent state prints as:
mark_precise: frame0: parent state regs= stack=: R10=fp0
Update both expectations accordingly.
Fixes: 147400e9c27c ("bpf: Compute parameters liveness in bpf_compute_live_registers()")
Signed-off-by: KaFai Wan <kafai.wan@linux.dev>
---
tools/testing/selftests/bpf/progs/stack_arg_precision.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/stack_arg_precision.c b/tools/testing/selftests/bpf/progs/stack_arg_precision.c
index 7baa9c1c8e31e..c9564776d7333 100644
--- a/tools/testing/selftests/bpf/progs/stack_arg_precision.c
+++ b/tools/testing/selftests/bpf/progs/stack_arg_precision.c
@@ -74,7 +74,7 @@ __msg("mark_precise: frame1: parent state regs= stack=: frame1: R10=fp0")
__msg("mark_precise: frame0: parent state regs= stack=: R10=fp0")
__msg("mark_precise: frame1: last_idx 11 first_idx 11 subseq_idx 13")
__msg("mark_precise: frame1: regs= stack= before 11: (85) call pc+1")
-__msg("mark_precise: frame0: parent state regs= stack=: R1=1 R2=2 R3=3 R4=4 R5=5 R10=fp0")
+__msg("mark_precise: frame0: parent state regs= stack=: R10=fp0")
__msg("mark_precise: frame0: last_idx 9 first_idx 7 subseq_idx 11")
__msg("mark_precise: frame0: regs= stack= before 9: (05) goto pc+1")
__msg("mark_precise: frame0: regs= stack= before 8: (7a) *(u64 *)(r11 -8) = 4")
@@ -95,7 +95,7 @@ __msg("mark_precise: frame1: parent state regs= stack=: frame1: R10=fp0")
__msg("mark_precise: frame0: parent state regs= stack=: R10=fp0")
__msg("mark_precise: frame1: last_idx 11 first_idx 11 subseq_idx 13 ")
__msg("mark_precise: frame1: regs= stack= before 11: (85) call pc+1")
-__msg("mark_precise: frame0: parent state regs= stack=: R1=1 R2=2 R3=3 R4=4 R5=5 R10=fp0")
+__msg("mark_precise: frame0: parent state regs= stack=: R10=fp0")
__msg("mark_precise: frame0: last_idx 10 first_idx 10 subseq_idx 11 ")
__msg("mark_precise: frame0: regs= stack= before 10: (7a) *(u64 *)(r11 -8) = 6")
__naked void stack_arg_precision_bpf2bpf(void)
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH bpf-next v3 3/4] selftests/bpf: Fix stack arg pruning test JOIN log expectation
2026-10-18 0:53 [PATCH bpf-next v3 0/4] selftests/bpf: Fix selftests fails with clang23 KaFai Wan
2026-10-18 0:53 ` [PATCH bpf-next v3 1/4] bpf: Determine freplace staticness from BTF linkage KaFai Wan
2026-10-18 0:53 ` [PATCH bpf-next v3 2/4] selftests/bpf: Fix stack_arg precision backtracking log expectation KaFai Wan
@ 2026-10-18 0:53 ` KaFai Wan
2026-10-18 0:53 ` [PATCH bpf-next v3 4/4] selftests/bpf: Use _exit() in uprobe_multi_test clone-ed child KaFai Wan
2026-10-18 22:50 ` [PATCH bpf-next v3 0/4] selftests/bpf: Fix selftests fails with clang23 patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: KaFai Wan @ 2026-10-18 0:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Ihor Solodrai, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, Leon Hwang,
Donggeun Yoo, Menglong Dong, KaFai Wan, Mykyta Yatsenko,
Feng Jiang, Vineet Gupta, Puranjay Mohan, bpf, linux-kernel,
linux-kselftest, llvm
Commit f414d20879ae ("bpf: Save DFS postorder numbers for program
instructions") changed bpf_compute_postorder() to use a real DFS, which
changes the postorder of this test's instructions and thus the insn edge
the arg track join at insn 10 is reported on:
arg JOIN insn 8 -> 10 r1: _ + fp0-8 => fp0-8|fp0+0
arg JOIN insn 8 -> 10 sa0: _ + fp0-8 => fp0-8|fp0+0
Update the r1 and sa0 expectations to the new output.
Fixes: f414d20879ae ("bpf: Save DFS postorder numbers for program instructions")
Signed-off-by: KaFai Wan <kafai.wan@linux.dev>
---
tools/testing/selftests/bpf/progs/verifier_stack_arg.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/verifier_stack_arg.c b/tools/testing/selftests/bpf/progs/verifier_stack_arg.c
index f6a4a6aa0e617..b9f799f6e4051 100644
--- a/tools/testing/selftests/bpf/progs/verifier_stack_arg.c
+++ b/tools/testing/selftests/bpf/progs/verifier_stack_arg.c
@@ -117,8 +117,8 @@ SEC("tc")
__description("stack_arg: pruning with different stack arg types")
__failure __log_level(2)
__flag(BPF_F_TEST_STATE_FREQ)
-__msg("arg JOIN insn 9 -> 10 r1: fp0-8 + _ => fp0-8|fp0+0")
-__msg("arg JOIN insn 9 -> 10 sa0: fp0-8 + _ => fp0-8|fp0+0")
+__msg("arg JOIN insn 8 -> 10 r1: _ + fp0-8 => fp0-8|fp0+0")
+__msg("arg JOIN insn 8 -> 10 sa0: _ + fp0-8 => fp0-8|fp0+0")
__msg("R{{[0-9]}} invalid mem access 'scalar'")
__naked void stack_arg_pruning_type_mismatch(void)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH bpf-next v3 4/4] selftests/bpf: Use _exit() in uprobe_multi_test clone-ed child
2026-10-18 0:53 [PATCH bpf-next v3 0/4] selftests/bpf: Fix selftests fails with clang23 KaFai Wan
` (2 preceding siblings ...)
2026-10-18 0:53 ` [PATCH bpf-next v3 3/4] selftests/bpf: Fix stack arg pruning test JOIN " KaFai Wan
@ 2026-10-18 0:53 ` KaFai Wan
2026-10-18 22:50 ` [PATCH bpf-next v3 0/4] selftests/bpf: Fix selftests fails with clang23 patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: KaFai Wan @ 2026-10-18 0:53 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Ihor Solodrai, Shuah Khan, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, Leon Hwang,
Donggeun Yoo, Menglong Dong, KaFai Wan, Mykyta Yatsenko,
Feng Jiang, Vineet Gupta, Puranjay Mohan, bpf, linux-kernel,
linux-kselftest, llvm
child_func() terminates with exit(), but spawn_child_flag() also starts
it via clone(CLONE_VM), which shares the parent's address space. That
exit() then runs atexit handlers and static destructors against globals
the parent is still using.
LLVM commit `3c3ed59c6a2a ("[llvm] Add format check for
MCSubtargetFeatures")` [1], included in the LLVM 23.1 releases, added
Target::isValidFeatureListFormat() with a function-local static holding
the compiled regex:
static const llvm::Regex pattern("^([+-][^,]+)(,[+-][^,]+)*,?$");
return pattern.match(Features);
The child exit destroys that static while its guard variable still marks
it as initialized, so the regex is never rebuilt in the parent. From that
point on, get_jited_program_text() gets NULL from
LLVMCreateDisasmCPUFeatures(), so every jited program text check in the
tests running after filter_clone_vm fails, e.g. "verifier_jit_convergence",
"verifier_private_stack", "verifier_tailcall_jit" and "verifier_jit_inline".
Use _exit(), which runs neither atexit handlers nor static destructors, as
uprobe_syscall.c already does for its own CLONE_VM child.
[1] https://github.com/llvm/llvm-project/pull/180943
Fixes: d2520bdb1932f ("selftests/bpf: Add uprobe multi pid filter test for clone-ed processes")
Signed-off-by: KaFai Wan <kafai.wan@linux.dev>
---
tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
index f0baf5738b751..7fbcfddc3cc36 100644
--- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
+++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
@@ -94,14 +94,14 @@ static int child_func(void *arg)
/* wait for parent's kick */
err = read(child->go[0], &c, 1);
if (err != 1)
- exit(err);
+ _exit(err);
uprobe_multi_func_1();
uprobe_multi_func_2();
uprobe_multi_func_3();
usdt_trigger();
- exit(errno);
+ _exit(errno);
}
static int spawn_child_flag(struct child *child, bool clone_vm)
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH bpf-next v3 0/4] selftests/bpf: Fix selftests fails with clang23
2026-10-18 0:53 [PATCH bpf-next v3 0/4] selftests/bpf: Fix selftests fails with clang23 KaFai Wan
` (3 preceding siblings ...)
2026-10-18 0:53 ` [PATCH bpf-next v3 4/4] selftests/bpf: Use _exit() in uprobe_multi_test clone-ed child KaFai Wan
@ 2026-10-18 22:50 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-10-18 22:50 UTC (permalink / raw)
To: KaFai Wan
Cc: ast, daniel, john.fastabend, andrii, eddyz87, memxor, martin.lau,
song, yonghong.song, jolsa, emil, ihor.solodrai, shuah, nathan,
ndesaulniers, morbo, justinstitt, leon.hwang, donggeunyoo.kernel,
menglong8.dong, yatsenko, jiangfeng, vineet.gupta, puranjay, bpf,
linux-kernel, linux-kselftest, llvm
Hello:
This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Sun, 18 Oct 2026 08:53:44 +0800 you wrote:
> Building with clang/LLVM 23 breaks several selftests. Patches #1 to #4 fix
> those failures.
>
> Changes in v3:
> - Remove the patch already applied.
>
> Changes in v2:
> - https://lore.kernel.org/bpf/20261014113043.640435-1-kafai.wan@linux.dev/
> - Collect the selftest fixes from the two patches in v1
> patches: #1, #5, #6 and #7.
> - Add three new patches: #2, #3 and #4.
>
> [...]
Here is the summary with links:
- [bpf-next,v3,1/4] bpf: Determine freplace staticness from BTF linkage
https://git.kernel.org/bpf/bpf-next/c/0ceb2f21d3e0
- [bpf-next,v3,2/4] selftests/bpf: Fix stack_arg precision backtracking log expectation
https://git.kernel.org/bpf/bpf-next/c/8d637d4c62c1
- [bpf-next,v3,3/4] selftests/bpf: Fix stack arg pruning test JOIN log expectation
https://git.kernel.org/bpf/bpf-next/c/8342d47ad791
- [bpf-next,v3,4/4] selftests/bpf: Use _exit() in uprobe_multi_test clone-ed child
https://git.kernel.org/bpf/bpf-next/c/ce42271dc517
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread