selftests/bpf: Fix tests for llvm23 true signature
Subsystems (3)
Yonghong Song
reviewerv2 cover selftests/bpf: Fix tests for llvm23 true signature
LLVM23 ([1]) records the 'true' function signature in BTF, i.e. the signature inferred after optimization rather than the one written in C. This caused two kinds of selftest failures (see below).
Case 1: keep int return type for tailcall subprogs
The verifier requires any subprog that issues a bpf_tail_call to return an 'int' (see check_btf_func() in kernel/bpf/check_btf.c, which rejects it with "tail_call is only allowed in functions that return 'int'").
Several tailcall subprogs do 'return 0' (or another constant) whose result no caller uses. With llvm23 the compiler folds the constant and, since the return value is dead, optimizes the subprog to effectively return 'void' and records 'void' in BTF, so the program fails to load.
Use barrier_var() and __sink() to prevent returned value from being optimized.
Case 2: adjust tracing prog ctx layout for the true signature
test_pkt_access_subprog2() has an unused argument that llvm optimizes away. Before llvm23 the BTF signature did not match the optimized assembly, so the verifier fell back to MAX_BPF_FUNC_REG_ARGS (5) u64 arguments and the fexit return value sat after args[5]. With llvm23 the true signature has a single argument, so the return value moves to the slot after args[1]. Select the matching ctx struct based on __clang_major__ so the test works with both old and new llvm.
[1] https://github.com/llvm/llvm-project/pull/198426
Changelogs:
v1 -> v2:
- v1: https://lore.kernel.org/bpf/[email protected]/
- Do not use bpf array map or bpf global var. Use __sink() instead.
Yonghong Song (2):
selftests/bpf: Keep int return type for tailcall subprogs selftests/bpf: Adjust fexit_bpf2bpf ctx layout for llvm23 true
signature
.../selftests/bpf/progs/fexit_bpf2bpf.c | 13 ++++++++-- .../selftests/bpf/progs/tailcall_bpf2bpf2.c | 5 +++- .../bpf/progs/tailcall_bpf2bpf_hierarchy1.c | 13 ++++++---- .../bpf/progs/tailcall_bpf2bpf_hierarchy2.c | 24 +++++++++++++------ .../bpf/progs/tailcall_bpf2bpf_hierarchy3.c | 13 +++++++--- .../progs/tailcall_bpf2bpf_hierarchy_fentry.c | 13 +++++++--- .../selftests/bpf/progs/verifier_sock.c | 9 +++++-- 7 files changed, 68 insertions(+), 22 deletions(-)
Signature · 1 line
2.53.0-Meta
Yonghong Song
reviewerPATCH v2 1/2 selftests/bpf: Keep int return type for tailcall subprogs
LLVM23 ([1]) supports 'true' function signature in BTF. The return type of the caller of a tailcall must be an 'int'. Otherwise, verification will fail (see check_btf_func() in check_btf.c). So with llvm23, it is possible that the compiler may change the caller's return type from 'int' to 'void'. To prevent this, barrier_var() and __sink() are used to avoid returning a constant prone to be optimized.
[1] https://github.com/llvm/llvm-project/pull/198426
--- .../selftests/bpf/progs/tailcall_bpf2bpf2.c | 5 +++- .../bpf/progs/tailcall_bpf2bpf_hierarchy1.c | 13 ++++++---- .../bpf/progs/tailcall_bpf2bpf_hierarchy2.c | 24 +++++++++++++------ .../bpf/progs/tailcall_bpf2bpf_hierarchy3.c | 13 +++++++--- .../progs/tailcall_bpf2bpf_hierarchy_fentry.c | 13 +++++++--- .../selftests/bpf/progs/verifier_sock.c | 9 +++++-- 6 files changed, 57 insertions(+), 20 deletions(-)
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf2.c +4 -1
@@ -13,11 +13,14 @@ struct {static __noinline int subprog_tail(struct __sk_buff *skb) { +int ret =1 ; +if (load_byte (skb,0 ))bpf_tail_call_static (skb, &jmp_table,1 );else bpf_tail_call_static (skb, &jmp_table,0 ); -return 1 ; +barrier_var (ret); +return ret; }int count =0 ;
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy1.c +9 -4
@@ -16,20 +16,25 @@ int count = 0;static __noinline int subprog_tail(struct __sk_buff *skb) { +int ret =0 ; +bpf_tail_call_static (skb, &jmp_table,0 ); -return 0 ; +barrier_var (ret); +return ret; } SEC("tc")int entry (struct __sk_buff *skb) { -int ret =1 ; +int ret =1 , ret1, ret2;clobber_regs_stack (); count++; -subprog_tail (skb); -subprog_tail (skb); + ret1 =subprog_tail (skb); + ret2 =subprog_tail (skb); +__sink (ret1); +__sink (ret2);return ret; }
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +17 -7
@@ -25,8 +25,11 @@ int count1 = 0;static __noinline int subprog_tail0(struct __sk_buff *skb) { +int ret =0 ; +bpf_tail_call_static (skb, &jmp_table,0 ); -return 0 ; +barrier_var (ret); +return ret; } __auxiliary
@@ -41,16 +44,22 @@ int classifier_0(struct __sk_buff *skb)static __noinline int subprog_tail1(struct __sk_buff *skb) { +int ret =0 ; +bpf_tail_call_static (skb, &jmp_table,1 ); -return 0 ; +barrier_var (ret); +return ret; } __auxiliary SEC("tc")int classifier_1 (struct __sk_buff *skb) { +int ret; + count1++; -subprog_tail1 (skb); + ret =subprog_tail1 (skb); +__sink (ret);return 0 ; }
@@ -59,13 +68,14 @@ __retval(33) SEC("tc")int tailcall_bpf2bpf_hierarchy_2 (struct __sk_buff *skb) { -int ret =0 ; +int ret =0 , ret1, ret2;clobber_regs_stack (); -subprog_tail0 (skb); -subprog_tail1 (skb); - + ret1 =subprog_tail0 (skb); + ret2 =subprog_tail1 (skb); +__sink (ret1); +__sink (ret2);__sink (ret);return (count1 <<16 ) | count0; }
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy3.c +10 -3
@@ -33,17 +33,24 @@ int count = 0;static __noinline int subprog_tail(struct __sk_buff *skb, void *jmp_table) { +int ret =0 ; +bpf_tail_call_static (skb, jmp_table,0 ); -return 0 ; +barrier_var (ret); +return ret; } __auxiliary SEC("tc")int classifier_0 (struct __sk_buff *skb) { +int ret1, ret2; + count++; -subprog_tail (skb, &jmp_table0); -subprog_tail (skb, &jmp_table1); + ret1 =subprog_tail (skb, &jmp_table0); + ret2 =subprog_tail (skb, &jmp_table1); +__sink (ret1); +__sink (ret2);return count; }
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy_fentry.c +10 -3
@@ -18,18 +18,25 @@ int count = 0;static __noinline int subprog_tail(void *ctx) { +int ret =0 ; +bpf_tail_call_static (ctx, &jmp_table,0 ); -return 0 ; +barrier_var (ret); +return ret; } SEC("fentry/dummy")int BPF_PROG (fentry ,struct sk_buff *skb) { +int ret1, ret2; +clobber_regs_stack (); count++; -subprog_tail (ctx); -subprog_tail (ctx); + ret1 =subprog_tail (ctx); + ret2 =subprog_tail (ctx); +__sink (ret1); +__sink (ret2);return 0 ; }
tools/testing/selftests/bpf/progs/verifier_sock.c +7 -2
@@ -1120,8 +1120,11 @@ int tail_call(struct __sk_buff *sk)static __noinline int static_tail_call(struct __sk_buff *sk) { +int ret =0 ; +bpf_tail_call_static (sk, &jmp_table,0 ); -return 0 ; +barrier_var (ret); +return ret; }/* Tail calls in sub-programs invalidate packet pointers. */
@@ -1144,10 +1147,12 @@ __failure __msg("invalid mem access")int invalidate_pkt_pointers_by_static_tail_call (struct __sk_buff *sk) {int *p = (void *)(long )sk->data; +int ret;if ((void *)(p +1 ) > (void *)(long )sk->data_end)return TCX_DROP ; -static_tail_call (sk); + ret =static_tail_call (sk); +__sink (ret); *p =42 ;/* this is unsafe */ return TCX_PASS ; }
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH bpf-next v2 1/2] selftests/bpf: Keep int return type for tailcall subprogs
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Incomplete application of compiler optimization mitigation in `classifier_0`. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incomplete application of compiler optimization mitigation in classifier_0. --
commit 230de7228ec64290b0e30a90f68ca96dd2ee6dd0
Author: Yonghong Song <[email protected]> selftests/bpf: Keep int return type for tailcall subprogs
This commit updates tailcall subprograms to prevent LLVM 23 from optimizing their return types from 'int' to 'void', which would cause verifier failures. It uses barrier_var() and __sink() to ensure the compiler retains the int return type.
Quoted 4 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +0
-0
[ ... ]
Quoted 14 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1@@ -41,16 +44,22 @@ int classifier_0(struct __sk_buff *skb)static __noinline int subprog_tail1(struct __sk_buff *skb) { +int ret =0 ; +bpf_tail_call_static (skb, &jmp_table,1 ); -return 0 ; +barrier_var (ret); +return ret; } __auxiliary SEC("tc")
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c int classifier_0(struct __sk_buff *skb) · line 64
Quoted 10 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1int classifier_1 (struct __sk_buff *skb) { +int ret; + count1++; -subprog_tail1 (skb); + ret =subprog_tail1 (skb); +__sink (ret);return 0 ; }
[Severity: Medium]
In classifier_1() here, the return value of subprog_tail1() is captured and sunk using __sink() to prevent optimization. Should classifier_0() also be updated symmetrically to capture and sink the return value of subprog_tail0()?
Looking at classifier_0() in the same file:
__auxiliarySEC("tc")
int classifier_0(struct __sk_buff *skb)
{
count0++;
subprog_tail0(skb);
return 0;
}While the return value of subprog_tail0() is currently sunk elsewhere in tailcall_bpf2bpf_hierarchy_2(), leaving this callsite unsunk could potentially leave the code fragile to LLVM optimizations that might create a void-returning clone of subprog_tail0() specifically for classifier_0().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Yonghong Song
reviewerRe: [PATCH bpf-next v2 1/2] selftests/bpf: Keep int return type for tailcall subprogs
Quoted 58 lines · On 6/9/26 4:42 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incomplete application of compiler optimization mitigation inclassifier_0. --commit
230de7228ec64290b0e30a90f68ca96dd2ee6dd0
Author: Yonghong Song <[email protected]> selftests/bpf: Keep int return type for tailcall subprogsThis commit updates tailcall subprograms to prevent LLVM 23 from optimizing their return types from 'int' to 'void', which would cause verifier failures. It uses
barrier_var()and__sink()to ensure the compiler retains the int return type.Quoted 4 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +0
-0[ ... ]
Quoted 14 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1@@ -41,16 +44,22 @@ int classifier_0(struct __sk_buff *skb)static __noinline int subprog_tail1(struct __sk_buff *skb) { +int ret =0 ; +bpf_tail_call_static (skb, &jmp_table,1 ); -return 0 ; +barrier_var (ret); +return ret; } __auxiliary SEC("tc")tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c int classifier_0(struct __sk_buff *skb) · line 64
Quoted 10 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1int classifier_1 (struct __sk_buff *skb) { +int ret; + count1++; -subprog_tail1 (skb); + ret =subprog_tail1 (skb); +__sink (ret);return 0 ; }[Severity: Medium]
Inclassifier_1()here, the return value ofsubprog_tail1()is captured and sunk using__sink()to prevent optimization. Shouldclassifier_0()also be updated symmetrically to capture and sink the return value ofsubprog_tail0()?Looking at
classifier_0()in the same file:
__auxiliarySEC("tc")
intclassifier_0(struct __sk_buff *skb){ count0++; subprog_tail0(skb); return 0; }
Quoted 4 lines
While the return value of
subprog_tail0()is currently sunk elsewhere intailcall_bpf2bpf_hierarchy_2(), leaving this callsite unsunk could potentially leave the code fragile to LLVM optimizations that might create a void-returning clone ofsubprog_tail0()specifically forclassifier_0().
We should be fine. In the same file, we have SEC("tc")
int tailcall_bpf2bpf_hierarchy_2(struct __sk_buff *skb) {
- int ret = 0;
+ int ret = 0, ret1, ret2;
clobber_regs_stack();
- subprog_tail0(skb);
- subprog_tail1(skb);
-
+ ret1 = subprog_tail0(skb);
+ ret2 = subprog_tail1(skb);
+ __sink(ret1);
+ __sink(ret2);
__sink(ret);
return (count1 << 16) | count0;
}
This will guarantee subprog_tail0() will have a return value.
Yonghong Song
reviewerRe: [PATCH bpf-next v2 1/2] selftests/bpf: Keep int return type for tailcall subprogs
In reply to [email protected]Quoted 58 lines · On 6/9/26 4:42 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incomplete application of compiler optimization mitigation inclassifier_0. --commit
230de7228ec64290b0e30a90f68ca96dd2ee6dd0
Author: Yonghong Song <[email protected]> selftests/bpf: Keep int return type for tailcall subprogsThis commit updates tailcall subprograms to prevent LLVM 23 from optimizing their return types from 'int' to 'void', which would cause verifier failures. It uses
barrier_var()and__sink()to ensure the compiler retains the int return type.Quoted 4 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +0
-0[ ... ]
Quoted 14 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1@@ -41,16 +44,22 @@ int classifier_0(struct __sk_buff *skb)static __noinline int subprog_tail1(struct __sk_buff *skb) { +int ret =0 ; +bpf_tail_call_static (skb, &jmp_table,1 ); -return 0 ; +barrier_var (ret); +return ret; } __auxiliary SEC("tc")tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c int classifier_0(struct __sk_buff *skb) · line 64
Quoted 10 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1int classifier_1 (struct __sk_buff *skb) { +int ret; + count1++; -subprog_tail1 (skb); + ret =subprog_tail1 (skb); +__sink (ret);return 0 ; }[Severity: Medium]
Inclassifier_1()here, the return value ofsubprog_tail1()is captured and sunk using__sink()to prevent optimization. Shouldclassifier_0()also be updated symmetrically to capture and sink the return value ofsubprog_tail0()?Looking at
classifier_0()in the same file:
__auxiliarySEC("tc")
intclassifier_0(struct __sk_buff *skb){ count0++; subprog_tail0(skb); return 0; }
Quoted 4 lines
While the return value of
subprog_tail0()is currently sunk elsewhere intailcall_bpf2bpf_hierarchy_2(), leaving this callsite unsunk could potentially leave the code fragile to LLVM optimizations that might create a void-returning clone ofsubprog_tail0()specifically forclassifier_0().
clone is possible. But I would say it is extremely unlikely.
In https://github.com/llvm/llvm-project/pull/165310, for all kernel functions, I only find one clone (specialization) with thin-lto mode.
[email protected]
AI reviewRe: [PATCH bpf-next v2 1/2] selftests/bpf: Keep int return type for tailcall subprogs
In reply to Yonghong SongThe patch adds barrier_var() to subprog_tail0() to prevent the compiler from optimizing its return type from int to void. However, is the approach sufficient for classifier_0()?
Quoted 4 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf2.c +0
-0
[ ... ]
Quoted 20 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1@@ -25,8 +25,11 @@ int count1 = 0;static __noinline int subprog_tail0(struct __sk_buff *skb) { +int ret =0 ; +bpf_tail_call_static (skb, &jmp_table,0 ); -return 0 ; +barrier_var (ret); +return ret; } __auxiliary
SEC("tc")
intclassifier_0(struct __sk_buff *skb)
{
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c int classifier_0(struct __sk_buff *skb) · line 64
Quoted 4 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +0
-0count0++;subprog_tail0 (skb);return 0 ; }
The patch adds barrier_var() to subprog_tail0() to prevent the compiler from optimizing its return type from int to void. However, is the approach sufficient for classifier_0()?
Looking at how the patch handles other callers like classifier_1():
Quoted 14 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1@@ -41,16 +44,22 @@ int classifier_0(struct __sk_buff *skb)static __noinline int subprog_tail1(struct __sk_buff *skb) { +int ret =0 ; +bpf_tail_call_static (skb, &jmp_table,1 ); -return 0 ; +barrier_var (ret); +return ret; } __auxiliary SEC("tc")
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c int classifier_0(struct __sk_buff *skb) · line 64
Quoted 10 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1int classifier_1 (struct __sk_buff *skb) { +int ret; + count1++; -subprog_tail1 (skb); + ret =subprog_tail1 (skb); +__sink (ret);return 0 ; }
In classifier_1(), the return value is captured and passed to __sink(). This creates a use at the callsite that forces the compiler to preserve the int return type.
Without capturing and sinking the return value in classifier_0(), could LLVM still create a void-returning clone of subprog_tail0() for this specific callsite? While subprog_tail0() is also called from tailcall_bpf2bpf_hierarchy_2() where its return value is properly sunk, the compiler might still specialize the function differently for the two callsites.
[ ... ]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/27243286945
Yonghong Song
reviewerRe: [PATCH bpf-next v2 1/2] selftests/bpf: Keep int return type for tailcall subprogs
Quoted 64 lines · On 6/9/26 5:07 PM, [email protected] wrote:
Quoted 4 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf2.c +0
-0[ ... ]
Quoted 17 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1@@ -25,8 +25,11 @@ int count1 = 0;static __noinline int subprog_tail0(struct __sk_buff *skb) { +int ret =0 ; +bpf_tail_call_static (skb, &jmp_table,0 ); -return 0 ; +barrier_var (ret); +return ret; } __auxiliaryQuoted 7 lines
SEC("tc") int classifier_0(struct __sk_buff *skb) { count0++; subprog_tail0(skb); return 0; }The patch adds
barrier_var()tosubprog_tail0()to prevent the compiler from optimizing its return type from int to void. However, is the approach sufficient forclassifier_0()?Looking at how the patch handles other callers like
classifier_1():Quoted 14 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1@@ -41,16 +44,22 @@ int classifier_0(struct __sk_buff *skb)static __noinline int subprog_tail1(struct __sk_buff *skb) { +int ret =0 ; +bpf_tail_call_static (skb, &jmp_table,1 ); -return 0 ; +barrier_var (ret); +return ret; } __auxiliary SEC("tc")tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c int classifier_0(struct __sk_buff *skb) · line 64
Quoted 10 lines
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_hierarchy2.c +4
-1int classifier_1 (struct __sk_buff *skb) { +int ret; + count1++; -subprog_tail1 (skb); + ret =subprog_tail1 (skb); +__sink (ret);return 0 ; }In
classifier_1(), the return value is captured and passed to__sink(). This creates a use at the callsite that forces the compiler to preserve the int return type.
Quoted 6 lines
Without capturing and sinking the return value in
classifier_0(), could LLVM still create a void-returning clone ofsubprog_tail0()for this specific callsite? Whilesubprog_tail0()is also called fromtailcall_bpf2bpf_hierarchy_2()where its return value is properly sunk, the compiler might still specialize the function differently for the two callsites.
We should be fine. In the same file, we have SEC("tc")
__success__retval(33)SEC("tc")
int tailcall_bpf2bpf_hierarchy_2(struct __sk_buff *skb)
{
int ret = 0, ret1, ret2;
clobber_regs_stack();
ret1 = subprog_tail0(skb);
ret2 = subprog_tail1(skb);
__sink(ret1);
__sink(ret2);
__sink(ret);
return (count1 << 16) | count0;
}This will guarantee subprog_tail0() will have a return value.
Quoted 9 lines
[ ... ]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.mdCI run summary: https://github.com/kernel-patches/bpf/actions/runs/27243286945
Yonghong Song
reviewerPATCH v2 2/2 selftests/bpf: Adjust fexit_bpf2bpf ctx layout for llvm23 true signature
In reply to Yonghong Songtest_pkt_access_subprog2() is defined in C as
int test_pkt_access_subprog2(int val, volatile struct __sk_buff *skb)
but llvm optimizes away the unused 'int val' argument. Before llvm23 the BTF signature did not match the optimized assembly, so the verifier set attach_func_proto to NULL and fell back to MAX_BPF_FUNC_REG_ARGS (5) u64 arguments (see btf_ctx_access()). The fexit ctx struct therefore placed the return value after args[5].
With llvm23 the 'true' signature
int test_pkt_access_subprog2(volatile struct __sk_buff *skb)
is recorded in BTF, so nr_args becomes 1 and the return value moves to the slot right after args[1]. Select the matching args_subprog2 layout based on __clang_major__ so the test works with both old and new llvm.
--- tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c +11 -2
@@ -53,14 +53,23 @@ int BPF_PROG(test_subprog1, struct sk_buff *skb, int ret)* r0 = *(u32 *)(r1 + 0) * w0 <<= 1 * exit -* In such case the verifier falls back to conservative and +* Before llvm23, in such case the verifier falls back to conservative and * tracing program can access arguments and return value as u64 -* instead of accurate types. +* instead of accurate types. With llvm23, the true signature +* int test_pkt_access_subprog2(volatile struct __sk_buff *skb) +* is available in btf. */ +#if __clang_major__ >=23 +struct args_subprog2 { +__u64 args[1 ]; +__u64 ret; +}; +#else struct args_subprog2 {__u64 args[5 ];__u64 ret; }; +#endif __u64 test_result_subprog2 =0 ; SEC("fexit/test_pkt_access_subprog2")int test_subprog2 (struct args_subprog2 *ctx)
Signature · 1 line
2.53.0-Meta
This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 11 lines · On Tue, 9 Jun 2026 16:34:02 -0700 you wrote:
LLVM23 ([1]) records the 'true' function signature in BTF, i.e. the signature inferred after optimization rather than the one written in C. This caused two kinds of selftest failures (see below).
Case 1: keep int return type for tailcall subprogs
The verifier requires any subprog that issues a
bpf_tail_callto return an 'int' (seecheck_btf_func()inkernel/bpf/check_btf.c, which rejects it with "tail_callis only allowed in functions that return 'int'").[...]
Here is the summary with links:
- [bpf-next,v2,1/2] selftests/bpf: Keep int return type for tailcall subprogs
https://git.kernel.org/bpf/bpf-next/c/be1d838b88e4 - [bpf-next,v2,2/2] selftests/bpf: Adjust fexit_bpf2bpf ctx layout for llvm23 true signature https://git.kernel.org/bpf/bpf-next/c/e775c522a455
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html