Skip to contentSkip to conversation

bpf: Use an UNUSED id for bpf_session_cookie without FPROBE

PATCH In review Sebastian Andrzej Siewior 3 participants 4 messages May 29, 2024 – May 31, 2024

Subsystems (5)
BPF Tracing BPF core BPF tracing +1 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: Use an UNUSED id for bpf_session_cookie without FPROBE

bpf_session_cookie() is only available with CONFIG_FPROBE=y leading to an unresolved symbol otherwise.

Use BTF_ID_UNUSED instead of bpf_session_cookie for CONFIG_FPROBE=n.

Fixes 5c919acef8514 ("bpf: Add support for kprobe session cookie")
---
 kernel/bpf/verifier.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/bpf/verifier.c +4 -0
index 77da1f438becc..436f72bfcb9b9 100644
@@ -11124,7 +11124,11 @@ BTF_ID(func, bpf_iter_css_task_new)
 #else
 BTF_ID_UNUSED
 #endif
+#ifdef CONFIG_FPROBE
 BTF_ID(func, bpf_session_cookie)
+#else
+BTF_ID_UNUSED
+#endif
 
 static bool is_kfunc_ret_null(struct bpf_kfunc_call_arg_meta *meta)
 {
Signature · 1 line
2.45.1
#1 lore raw
Quoted 17 lines · Sebastian Andrzej Siewior

bpf_session_cookie() is only available with CONFIG_FPROBE=y leading to an unresolved symbol otherwise.

Use BTF_ID_UNUSED instead of bpf_session_cookie for CONFIG_FPROBE=n.

Fixes 5c919acef8514 ("bpf: Add support for kprobe session cookie")
---
 kernel/bpf/verifier.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/bpf/verifier.c +0 -0
index 77da1f438becc..436f72bfcb9b9 100644

kernel/bpf/verifier.c BTF_ID(func, bpf_iter_css_task_new) · line 11131

Quoted 8 lines
kernel/bpf/verifier.c +4 -0
@@ -11124,7 +11124,11 @@ BTF_ID(func, bpf_iter_css_task_new)
 #else
 BTF_ID_UNUSED
 #endif
+#ifdef CONFIG_FPROBE
 BTF_ID(func, bpf_session_cookie)
+#else
+BTF_ID_UNUSED
+#endif

Instead of this fix..
Jiri,
maybe remove ifdef CONFIG_FPROBE hiding of this kfunc in kernel/tace/bpf_trace.c ?
The less ifdef-s the better. imo

#2 lore raw
Quoted 25 lines · Alexei Starovoitov
Quoted 23 lines · Sebastian Andrzej Siewior

bpf_session_cookie() is only available with CONFIG_FPROBE=y leading to an unresolved symbol otherwise.

Use BTF_ID_UNUSED instead of bpf_session_cookie for CONFIG_FPROBE=n.

Fixes 5c919acef8514 ("bpf: Add support for kprobe session cookie")
---
 kernel/bpf/verifier.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/bpf/verifier.c +2 -0
index 77da1f438becc..436f72bfcb9b9 100644
@@ -11124,7 +11124,11 @@ BTF_ID(func, bpf_iter_css_task_new)
 #else
 BTF_ID_UNUSED
 #endif
+#ifdef CONFIG_FPROBE
 BTF_ID(func, bpf_session_cookie)
+#else
Quoted 8 lines

kernel/bpf/verifier.c BTF_ID(func, bpf_iter_css_task_new) · line 11131

Quoted 2 lines
kernel/bpf/verifier.c +2 -0
+BTF_ID_UNUSED
+#endif

Instead of this fix..
Jiri,
maybe remove ifdef CONFIG_FPROBE hiding of this kfunc in kernel/tace/bpf_trace.c ?
The less ifdef-s the better. imo

yes, that seems to work

Sebastian, do you want to send it as v2 or should I post it?

thanks,
jirka

---

kernel/trace/bpf_trace.c +0 -2
index f5154c051d2c..cc90d56732eb 100644
@@ -3519,7 +3519,6 @@ static u64 bpf_uprobe_multi_entry_ip(struct bpf_run_ctx *ctx)
 }
 #endif /* CONFIG_UPROBES */
 
-#ifdef CONFIG_FPROBE
 __bpf_kfunc_start_defs();
 
 __bpf_kfunc bool bpf_session_is_return(void)
@@ -3568,4 +3567,3 @@ static int __init bpf_kprobe_multi_kfuncs_init(void)
 }
 
 late_initcall(bpf_kprobe_multi_kfuncs_init);
-#endif
#3 lore raw
Quoted 12 lines · Jiri Olsa
Quoted 11 lines

Review

Quoted 5 lines
(quoted diff) +4 -0
+#ifdef CONFIG_FPROBE
 BTF_ID(func, bpf_session_cookie)
+#else
+BTF_ID_UNUSED
+#endif

Instead of this fix..
Jiri,
maybe remove ifdef CONFIG_FPROBE hiding of this kfunc in kernel/tace/bpf_trace.c ?
The less ifdef-s the better. imo

Quoted 3 lines

yes, that seems to work

Sebastian, do you want to send it as v2 or should I post it?

Now that I look again, ifdef CONFIG_FPROBE isn't enough it requires additionally CONFIG_UPROBE_EVENTS.
So the suggested snippet does not work if CONFIG_UPROBE_EVENTS is not enabled.

Quoted 2 lines

thanks,
jirka

Sebastian