All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thiébaud Weksteen" <tweek@google.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	 Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	 Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Shuah Khan <shuah@kernel.org>,
	 Siddharth Nayyar <sidnayyar@google.com>
Cc: "Thiébaud Weksteen" <tweek@google.com>,
	bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	"Ihor Solodrai" <ihor.solodrai@linux.dev>
Subject: [PATCH bpf-next 2/2] selftests/bpf: Test missing strong typeless ksym in light skeleton
Date: Wed,  2 Dec 2026 11:32:34 +1100	[thread overview]
Message-ID: <20261202003234.2630157-3-tweek@google.com> (raw)
In-Reply-To: <20261202003234.2630157-1-tweek@google.com>

Add a test_ksyms_strong_typeless light skeleton and a
ksyms_btf/strong_typeless_lskel subtest referencing a nonexistent strong
typeless ksym. Light skeleton generation succeeds at build time even
though the symbol does not exist on the build host, and loading the
generated skeleton fails with -ENOENT on the target kernel.

Signed-off-by: Thiébaud Weksteen <tweek@google.com>
---
 tools/testing/selftests/bpf/Makefile.skel     |  3 ++-
 .../selftests/bpf/prog_tests/ksyms_btf.c      | 19 +++++++++++++++++++
 .../bpf/progs/test_ksyms_strong_typeless.c    | 16 ++++++++++++++++
 3 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_ksyms_strong_typeless.c

diff --git a/tools/testing/selftests/bpf/Makefile.skel b/tools/testing/selftests/bpf/Makefile.skel
index 334342928d01..1c639b089c99 100644
--- a/tools/testing/selftests/bpf/Makefile.skel
+++ b/tools/testing/selftests/bpf/Makefile.skel
@@ -35,7 +35,8 @@ LSKELS := fexit_sleep.c trace_printk.c trace_vprintk.c map_ptr_kern.c 	\
 	core_kern.c core_kern_overflow.c test_ringbuf.c			\
 	test_ringbuf_n.c test_ringbuf_map_key.c test_ringbuf_write.c    \
 	test_ringbuf_overwrite.c callx_rodata.c many_progs.c		\
-	struct_ops_vmlinux.c struct_ops_mod.c
+	struct_ops_vmlinux.c struct_ops_mod.c				\
+	test_ksyms_strong_typeless.c
 
 LSKELS_SIGNED := fentry_test.c fexit_test.c atomics.c
 
diff --git a/tools/testing/selftests/bpf/prog_tests/ksyms_btf.c b/tools/testing/selftests/bpf/prog_tests/ksyms_btf.c
index 1d7a2f1e0731..1bc3089f10fc 100644
--- a/tools/testing/selftests/bpf/prog_tests/ksyms_btf.c
+++ b/tools/testing/selftests/bpf/prog_tests/ksyms_btf.c
@@ -9,6 +9,7 @@
 #include "test_ksyms_weak.skel.h"
 #include "test_ksyms_weak.lskel.h"
 #include "test_ksyms_btf_write_check.skel.h"
+#include "test_ksyms_strong_typeless.lskel.h"
 
 static int duration;
 
@@ -138,6 +139,21 @@ static void test_weak_syms_lskel(void)
 	test_ksyms_weak_lskel__destroy(skel);
 }
 
+static void test_strong_typeless_lskel(void)
+{
+	struct test_ksyms_strong_typeless_lskel *skel;
+	int err;
+
+	skel = test_ksyms_strong_typeless_lskel__open();
+	if (!ASSERT_OK_PTR(skel, "test_ksyms_strong_typeless_lskel__open"))
+		return;
+
+	err = test_ksyms_strong_typeless_lskel__load(skel);
+	ASSERT_EQ(err, -ENOENT, "strong_missing_ksym_load");
+
+	test_ksyms_strong_typeless_lskel__destroy(skel);
+}
+
 static void test_write_check(bool test_handler1)
 {
 	struct test_ksyms_btf_write_check *skel;
@@ -183,6 +199,9 @@ void test_ksyms_btf(void)
 	if (test__start_subtest("weak_ksyms_lskel"))
 		test_weak_syms_lskel();
 
+	if (test__start_subtest("strong_typeless_lskel"))
+		test_strong_typeless_lskel();
+
 	if (test__start_subtest("write_check1"))
 		test_write_check(true);
 
diff --git a/tools/testing/selftests/bpf/progs/test_ksyms_strong_typeless.c b/tools/testing/selftests/bpf/progs/test_ksyms_strong_typeless.c
new file mode 100644
index 000000000000..e7f20cd34f0d
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/test_ksyms_strong_typeless.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2026 Google */
+
+#include <linux/bpf.h>
+#include <bpf/bpf_helpers.h>
+
+/* Strong typeless ksym that does not exist in the kernel. */
+extern const void bpf_nonexistent_strong_ksym __ksym;
+
+SEC("raw_tp/sys_enter")
+int handler(const void *ctx)
+{
+	return (int)(__u64)&bpf_nonexistent_strong_ksym;
+}
+
+char _license[] SEC("license") = "GPL";
-- 
2.56.1.987.g2ec0ab4260-goog


      parent reply	other threads:[~2026-12-02  0:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  0:32 [PATCH bpf-next 0/2] libbpf: Skip host /proc/kallsyms for typeless ksyms in gen_loader Thiébaud Weksteen
2026-12-02  0:32 ` [PATCH bpf-next 1/2] libbpf: Skip reading " Thiébaud Weksteen
2026-12-02  4:58   ` Alexei Starovoitov
2026-12-02  0:32 ` Thiébaud Weksteen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202003234.2630157-3-tweek@google.com \
    --to=tweek@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=shuah@kernel.org \
    --cc=sidnayyar@google.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.