On 1/16/25 8:23 AM, Jared Kangas wrote:
diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
index 2f4ed83a75ae..74584dd12550 100644
--- a/net/core/bpf_sk_storage.c
+++ b/net/core/bpf_sk_storage.c
@@ -352,8 +352,8 @@ const struct bpf_func_proto bpf_sk_storage_delete_proto = {
static bool bpf_sk_storage_tracing_allowed(const struct bpf_prog *prog)
{
- const struct btf *btf_vmlinux;
const struct btf_type *t;
+ const struct btf *btf;
const char *tname;
u32 btf_id;
@@ -371,12 +371,12 @@ static bool bpf_sk_storage_tracing_allowed(const struct bpf_prog *prog)
return true;
case BPF_TRACE_FENTRY:
case BPF_TRACE_FEXIT:
- btf_vmlinux = bpf_get_btf_vmlinux();
- if (IS_ERR_OR_NULL(btf_vmlinux))
+ btf = prog->aux->attach_btf;
+ if (!btf)
return false;
btf_id = prog->aux->attach_btf_id;
- t = btf_type_by_id(btf_vmlinux, btf_id);
- tname = btf_name_by_offset(btf_vmlinux, t->name_off);
+ t = btf_type_by_id(btf, btf_id);
+ tname = btf_name_by_offset(btf, t->name_off);
return !!strncmp(tname, "bpf_sk_storage",
strlen("bpf_sk_storage"));
Thanks for the report.
There is a prog->aux->attach_func_name, so it can be directly used, like:
case BPF_TRACE_FENTRY:
case BPF_TRACE_FEXIT:
return !!strncmp(prog->aux->attach_func_name, "bpf_sk_storage",
strlen("bpf_sk_storage"));
The above should do for the fix.
No need to check for null on attach_func_name. It should have been checked
earlier in bpf_check_attach_target (the "tname" variable).
pw-bot: cr