The added fsession does not prevent running on those architectures, that
haven't added fsession support.
For example, try to run fsession tests on arm64:
test_fsession_basic:PASS:fsession_test__open_and_load 0 nsec
test_fsession_basic:PASS:fsession_attach 0 nsec
check_result:FAIL:test_run_opts err unexpected error: -14 (errno 14)
In order to prevent such errors, add bpf_jit_supports_fsession() to guard
those architectures.
Fixes: 2d419c44658f ("bpf: add fsession support")
Acked-by: Puranjay Mohan <puranjay@kernel.org>
Tested-by: Puranjay Mohan <puranjay@kernel.org>
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
---
arch/x86/net/bpf_jit_comp.c | 5 +++
include/linux/filter.h | 1 +
kernel/bpf/core.c | 5 +++
kernel/bpf/verifier.c | 3 ++
.../selftests/bpf/prog_tests/fsession_test.c | 32 ++++++++++++++-----
5 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 5a075e06cf45..070ba80e39d7 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -4112,3 +4112,8 @@ bool bpf_jit_supports_timed_may_goto(void)
{
return true;
}
+
+bool bpf_jit_supports_fsession(void)
+{
+ return true;
+}
diff --git a/include/linux/filter.h b/include/linux/filter.h
index fd54fed8f95f..4e1cb4f91f49 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1167,6 +1167,7 @@ bool bpf_jit_supports_arena(void);
bool bpf_jit_supports_insn(struct bpf_insn *insn, bool in_arena);
bool bpf_jit_supports_private_stack(void);
bool bpf_jit_supports_timed_may_goto(void);
+bool bpf_jit_supports_fsession(void);
u64 bpf_arch_uaddress_limit(void);
void arch_bpf_stack_walk(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp), void *cookie);
u64 arch_bpf_timed_may_goto(void);
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index e0b8a8a5aaa9..3b1eb632bf7c 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -3142,6 +3142,11 @@ bool __weak bpf_jit_supports_insn(struct bpf_insn *insn, bool in_arena)
return false;
}
+bool __weak bpf_jit_supports_fsession(void)
+{
+ return false;
+}
+
u64 __weak bpf_arch_uaddress_limit(void)
{
#if defined(CONFIG_64BIT) && defined(CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index e7ff8394e0da..6e0693ac723e 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -24874,6 +24874,9 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,
case BPF_TRACE_FENTRY:
case BPF_TRACE_FEXIT:
case BPF_TRACE_FSESSION:
+ if (prog->expected_attach_type == BPF_TRACE_FSESSION &&
+ !bpf_jit_supports_fsession())
+ return -EOPNOTSUPP;
if (!btf_type_is_func(t)) {
bpf_log(log, "attach_btf_id %u is not a function\n",
btf_id);
diff --git a/tools/testing/selftests/bpf/prog_tests/fsession_test.c b/tools/testing/selftests/bpf/prog_tests/fsession_test.c
index 0c4b428e1cee..a299aeb8cc2e 100644
--- a/tools/testing/selftests/bpf/prog_tests/fsession_test.c
+++ b/tools/testing/selftests/bpf/prog_tests/fsession_test.c
@@ -29,8 +29,16 @@ static void test_fsession_basic(void)
struct fsession_test *skel = NULL;
int err;
- skel = fsession_test__open_and_load();
- if (!ASSERT_OK_PTR(skel, "fsession_test__open_and_load"))
+ skel = fsession_test__open();
+ if (!ASSERT_OK_PTR(skel, "fsession_test__open"))
+ return;
+
+ err = fsession_test__load(skel);
+ if (err == -EOPNOTSUPP) {
+ test__skip();
+ goto cleanup;
+ }
+ if (!ASSERT_OK(err, "fsession_test__load"))
goto cleanup;
err = fsession_test__attach(skel);
@@ -47,8 +55,16 @@ static void test_fsession_reattach(void)
struct fsession_test *skel = NULL;
int err;
- skel = fsession_test__open_and_load();
- if (!ASSERT_OK_PTR(skel, "fsession_test__open_and_load"))
+ skel = fsession_test__open();
+ if (!ASSERT_OK_PTR(skel, "fsession_test__open"))
+ return;
+
+ err = fsession_test__load(skel);
+ if (err == -EOPNOTSUPP) {
+ test__skip();
+ goto cleanup;
+ }
+ if (!ASSERT_OK(err, "fsession_test__load"))
goto cleanup;
/* first attach */
@@ -94,6 +110,10 @@ static void test_fsession_cookie(void)
bpf_program__set_autoload(skel->progs.test6, false);
err = fsession_test__load(skel);
+ if (err == -EOPNOTSUPP) {
+ test__skip();
+ goto cleanup;
+ }
if (!ASSERT_OK(err, "fsession_test__load"))
goto cleanup;
@@ -111,10 +131,6 @@ static void test_fsession_cookie(void)
void test_fsession_test(void)
{
-#if !defined(__x86_64__)
- test__skip();
- return;
-#endif
if (test__start_subtest("fsession_test"))
test_fsession_basic();
if (test__start_subtest("fsession_reattach"))
--
2.52.0
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > index e7ff8394e0..6e0693ac72 100644 > --- a/kernel/bpf/verifier.c > +++ b/kernel/bpf/verifier.c > @@ -24874,6 +24874,9 @@ int bpf_check_attach_target(struct bpf_verifier_log *log, > case BPF_TRACE_FENTRY: > case BPF_TRACE_FEXIT: > case BPF_TRACE_FSESSION: > + if (prog->expected_attach_type == BPF_TRACE_FSESSION && > + !bpf_jit_supports_fsession()) > + return -EOPNOTSUPP; This isn't a bug, but other similar bpf_jit_supports_*() checks in this file include a bpf_log() message before returning an error. For example: bpf_jit_supports_kfunc_call() -> "JIT does not support calling kernel function" bpf_jit_supports_exceptions() -> "JIT does not support calling kfunc..." bpf_jit_supports_arena() -> "JIT doesn't support arena" bpf_jit_supports_private_stack() -> "Private stack not supported by jit" Should this check also include a message like "JIT does not support fsession" for consistency with other similar checks in the verifier? --- 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/21482297342 AI-authorship-score: low AI-authorship-explanation: The commit demonstrates specific debugging context with actual test output and errno values, correct understanding of kernel BPF conventions, and follows established patterns - typical of experienced human kernel developers. issues-found: 1 issue-severity-score: low issue-severity-explanation: Minor consistency issue - missing bpf_log() error message compared to similar checks in the same file; does not affect functionality or stability.
On Thu Jan 29, 2026 at 10:54 PM +08, bot+bpf-ci wrote: >> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c >> index e7ff8394e0..6e0693ac72 100644 >> --- a/kernel/bpf/verifier.c >> +++ b/kernel/bpf/verifier.c >> @@ -24874,6 +24874,9 @@ int bpf_check_attach_target(struct bpf_verifier_log *log, >> case BPF_TRACE_FENTRY: >> case BPF_TRACE_FEXIT: >> case BPF_TRACE_FSESSION: >> + if (prog->expected_attach_type == BPF_TRACE_FSESSION && >> + !bpf_jit_supports_fsession()) >> + return -EOPNOTSUPP; > > This isn't a bug, but other similar bpf_jit_supports_*() checks in > this file include a bpf_log() message before returning an error. For > example: > > bpf_jit_supports_kfunc_call() -> "JIT does not support calling kernel function" > bpf_jit_supports_exceptions() -> "JIT does not support calling kfunc..." > bpf_jit_supports_arena() -> "JIT doesn't support arena" > bpf_jit_supports_private_stack() -> "Private stack not supported by jit" > > Should this check also include a message like "JIT does not support > fsession" for consistency with other similar checks in the verifier? > That makes sense. Let me add the log message. Thanks, Leon > > --- > 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/21482297342 > > AI-authorship-score: low > AI-authorship-explanation: The commit demonstrates specific debugging context with actual test output and errno values, correct understanding of kernel BPF conventions, and follows established patterns - typical of experienced human kernel developers. > issues-found: 1 > issue-severity-score: low > issue-severity-explanation: Minor consistency issue - missing bpf_log() error message compared to similar checks in the same file; does not affect functionality or stability.
© 2016 - 2026 Red Hat, Inc.