Re: [PATCH bpf-next v2 17/23] selftests/bpf: Add tests for stack argument validation

Yonghong Song <[email protected]> Sun, 10 May 2026 10:23:23 -0700
Newsgroups dev.linux.lists.sashiko,org.kernel.vger.bpf
Message-ID <[email protected]>

On 5/9/26 3:30 AM, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] Unconditional use of the 'r11' register in inline assembly will cause selftest build failures on older Clang compilers.
> --
>
> commit 6f66b8fd81d82b7d1f5f683d16976b8d486d440b
> Author: Yonghong Song <[email protected]>
>
> selftests/bpf: Add tests for stack argument validation
>
> This commit adds negative tests to verify that kfuncs properly reject large
> structs passed as stack arguments. It also adds tests to ensure the verifier
> rejects invalid uses of the r11 register for stack arguments.
>
>> diff --git a/tools/testing/selftests/bpf/progs/stack_arg_fail.c b/tools/testing/selftests/bpf/progs/stack_arg_fail.c
>> new file mode 100644
>> index 0000000000000..c6db302549cbd
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/progs/stack_arg_fail.c
> [ ... ]
>
>> +#else
>> +
>> +SEC("tc")
>> +__description("stack_arg_fail: not supported, dummy test")
>> +__success
>> +int test_stack_arg_big(struct __sk_buff *skb)
>> +{
>> +	return 0;
>> +}
>> +
>> +#endif
>> +
>> +SEC("socket")
>> +__description("r11 in ALU instruction")
>> +__failure __msg("R11 is invalid")
>> +__naked void r11_alu_reject(void)
>> +{
>> +	asm volatile (
>> +	"r11 += 1;"
> Could these inline assembly blocks using r11 cause build failures on older
> Clang compilers?
>
> The r11 register is a relatively new addition to the BPF ISA and LLVM backend.
> Because these naked assembly functions are placed outside of the
> __BPF_FEATURE_STACK_ARGUMENT guard, compiling this file with an older
> toolchain might result in fatal assembler errors regarding an invalid operand.
>
> Would it be safer to move these r11 tests inside the feature guard to
> maintain selftest compatibility across toolchains?

Indeed. Will fix.

>
> [ ... ]
>