From: Leon Hwang <leon.hwang@linux.dev>
To: bpf@vger.kernel.org
Cc: "Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
"Shuah Khan" <shuah@kernel.org>,
"Feng Yang" <yangfeng@kylinos.cn>,
"Leon Hwang" <leon.hwang@linux.dev>,
"Menglong Dong" <menglong8.dong@gmail.com>,
"Puranjay Mohan" <puranjay@kernel.org>,
"Björn Töpel" <bjorn@kernel.org>, "Pu Lehui" <pulehui@huawei.com>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
netdev@vger.kernel.org, kernel-patches-bot@fb.com
Subject: [PATCH bpf-next 7/8] selftests/bpf: Add a test to verify call_get_func_ip compatibility enforcement
Date: Tue, 24 Feb 2026 23:40:23 +0800 [thread overview]
Message-ID: <20260224154024.12504-8-leon.hwang@linux.dev> (raw)
In-Reply-To: <20260224154024.12504-1-leon.hwang@linux.dev>
Add prog_array coverage for tracing programs that differ in
bpf_get_func_ip() dependency.
The test verifies one-way enforcement: !call_get_func_ip programs
cannot tail-call call_get_func_ip programs.
Assisted-by: Codex:gpt-5.3-codex
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
---
.../bpf/prog_tests/get_func_ip_test.c | 46 +++++++++++++++++++
.../selftests/bpf/progs/get_func_ip_test.c | 6 +++
2 files changed, 52 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c b/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c
index 7772a0f288d3..670457d4e159 100644
--- a/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c
+++ b/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c
@@ -139,3 +139,49 @@ void test_get_func_ip_test(void)
test_function_entry();
test_function_body();
}
+
+static void test_prog_array_call_get_func_ip_compat(void)
+{
+ __u32 key = 0, with_get_func_ip_fd, without_get_func_ip_fd;
+ struct get_func_ip_test *skel = NULL;
+ int map_fd = -1, err;
+
+ skel = get_func_ip_test__open();
+ if (!ASSERT_OK_PTR(skel, "get_func_ip_test__open"))
+ return;
+
+ err = get_func_ip_test__load(skel);
+ if (!ASSERT_OK(err, "get_func_ip_test__load"))
+ goto cleanup;
+
+ with_get_func_ip_fd = bpf_program__fd(skel->progs.test1);
+ without_get_func_ip_fd = bpf_program__fd(skel->progs.test1_dummy);
+ if (!ASSERT_GE(with_get_func_ip_fd, 0, "with_get_func_ip_fd"))
+ goto cleanup;
+ if (!ASSERT_GE(without_get_func_ip_fd, 0, "without_get_func_ip_fd"))
+ goto cleanup;
+
+ map_fd = bpf_map_create(BPF_MAP_TYPE_PROG_ARRAY, NULL, sizeof(key),
+ sizeof(__u32), 1, NULL);
+ if (!ASSERT_GE(map_fd, 0, "bpf_map_create"))
+ goto cleanup;
+
+ err = bpf_map_update_elem(map_fd, &key, &without_get_func_ip_fd, BPF_ANY);
+ if (!ASSERT_OK(err, "bpf_map_update_elem success"))
+ goto cleanup;
+
+ err = bpf_map_update_elem(map_fd, &key, &with_get_func_ip_fd, BPF_ANY);
+ if (!ASSERT_ERR(err, "bpf_map_update_elem failure"))
+ goto cleanup;
+ ASSERT_EQ(errno, EINVAL, "bpf_map_update_elem errno");
+
+cleanup:
+ if (map_fd >= 0)
+ close(map_fd);
+ get_func_ip_test__destroy(skel);
+}
+
+void test_get_func_ip_test_prog_map_compatible(void)
+{
+ test_prog_array_call_get_func_ip_compat();
+}
diff --git a/tools/testing/selftests/bpf/progs/get_func_ip_test.c b/tools/testing/selftests/bpf/progs/get_func_ip_test.c
index 45eaa54d1ac7..6a7d306af96e 100644
--- a/tools/testing/selftests/bpf/progs/get_func_ip_test.c
+++ b/tools/testing/selftests/bpf/progs/get_func_ip_test.c
@@ -32,6 +32,12 @@ int BPF_PROG(test1, int a)
return 0;
}
+SEC("fentry/bpf_fentry_test1")
+int BPF_PROG(test1_dummy, int a)
+{
+ return 0;
+}
+
__u64 test2_result = 0;
SEC("fexit/bpf_fentry_test2")
int BPF_PROG(test2, int a)
--
2.52.0
next prev parent reply other threads:[~2026-02-24 15:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 15:40 [PATCH bpf-next 0/8] bpf: Enhance __bpf_prog_map_compatible() Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 1/8] bpf: Add fsession to verbose log in check_get_func_ip() Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 2/8] bpf: Disallow !kprobe_write_ctx progs tail-calling kprobe_write_ctx progs Leon Hwang
2026-02-24 16:22 ` bot+bpf-ci
2026-02-24 16:57 ` Alexei Starovoitov
2026-02-25 15:15 ` Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 3/8] bpf: Disallow !call_get_func_ip progs tail-calling call_get_func_ip progs Leon Hwang
2026-02-24 16:35 ` bot+bpf-ci
2026-02-24 15:40 ` [PATCH bpf-next 4/8] bpf: Disallow !call_session_cookie progs tail-calling call_session_cookie progs Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 5/8] bpf: Disallow !call_session_is_return progs tail-calling call_session_is_return progs Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 6/8] selftests/bpf: Add a test to verify kprobe_write_ctx compatibility enforcement Leon Hwang
2026-02-24 15:40 ` Leon Hwang [this message]
2026-02-24 15:40 ` [PATCH bpf-next 8/8] selftests/bpf: Add a test to verify session-kfunc " Leon Hwang
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=20260224154024.12504-8-leon.hwang@linux.dev \
--to=leon.hwang@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-patches-bot@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=menglong8.dong@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pulehui@huawei.com \
--cc=puranjay@kernel.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yangfeng@kylinos.cn \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox