lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251022071825.238909-1-jiayuan.chen@linux.dev>
Date: Wed, 22 Oct 2025 15:18:20 +0800
From: Jiayuan Chen <jiayuan.chen@...ux.dev>
To: bpf@...r.kernel.org
Cc: Jiayuan Chen <jiayuan.chen@...ux.dev>,
	Andrii Nakryiko <andrii@...nel.org>,
	Eduard Zingerman <eddyz87@...il.com>,
	Alexei Starovoitov <ast@...nel.org>,
	Daniel Borkmann <daniel@...earbox.net>,
	Martin KaFai Lau <martin.lau@...ux.dev>,
	Song Liu <song@...nel.org>,
	Yonghong Song <yonghong.song@...ux.dev>,
	John Fastabend <john.fastabend@...il.com>,
	KP Singh <kpsingh@...nel.org>,
	Stanislav Fomichev <sdf@...ichev.me>,
	Hao Luo <haoluo@...gle.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Shuah Khan <shuah@...nel.org>,
	Nathan Chancellor <nathan@...nel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
	Bill Wendling <morbo@...gle.com>,
	Justin Stitt <justinstitt@...gle.com>,
	Puranjay Mohan <puranjay@...nel.org>,
	linux-kselftest@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	llvm@...ts.linux.dev
Subject: [PATCH bpf-next v1] selftests/bpf: Guard addr_space_cast code with __BPF_FEATURE_ADDR_SPACE_CAST

When compiling the BPF selftests with Clang versions that do not support
the addr_space_cast builtin, the build fails with assembly errors in
"verifier_ldsx.c" [1].

The root cause is that the inline assembly using addr_space_cast is
being processed by a compiler that lacks this feature. To resolve this,
wrap the affected code sections (specifically the arena_ldsx_* test
functions) with #if defined(__BPF_FEATURE_ADDR_SPACE_CAST). This
ensures the code is only compiled when the Clang supports the necessary
feature, preventing build failures on older or incompatible compiler
versions.

This change maintains test coverage for systems with support while
allowing the tests to build successfully in all environments.

[1]:
root:tools/testing/selftests/bpf$ make

  CLNG-BPF [test_progs] verifier_ldsx.bpf.o
progs/verifier_ldsx.c:322:2: error: invalid operand for instruction
  322 |         "r1 = %[arena] ll;"
      |         ^
<inline asm>:1:52: note: instantiated into assembly here
    1 |         r1 = arena ll;r0 = 0xdeadbeef;r0 = addr_space_cast(r0,...
      |                                                           ^

Fixes: f61654912404 ("selftests: bpf: Add tests for signed loads from arena")
Signed-off-by: Jiayuan Chen <jiayuan.chen@...ux.dev>
---
 tools/testing/selftests/bpf/progs/verifier_ldsx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/progs/verifier_ldsx.c b/tools/testing/selftests/bpf/progs/verifier_ldsx.c
index c8494b682c31..cefa02e417d3 100644
--- a/tools/testing/selftests/bpf/progs/verifier_ldsx.c
+++ b/tools/testing/selftests/bpf/progs/verifier_ldsx.c
@@ -263,6 +263,7 @@ __naked void ldsx_ctx_8(void)
 	: __clobber_all);
 }
 
+#if defined(__BPF_FEATURE_ADDR_SPACE_CAST)
 SEC("syscall")
 __description("Arena LDSX Disasm")
 __success
@@ -425,6 +426,7 @@ __naked void arena_ldsx_s32(void *ctx)
 	:  __clobber_all
 	);
 }
+#endif
 
 /* to retain debug info for BTF generation */
 void kfunc_root(void)
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ