[PATCH] bpf: Fix holes in special_kfunc_list if !CONFIG_NET

Thomas Weißschuh posted 1 patch 1 year, 1 month ago
kernel/bpf/verifier.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] bpf: Fix holes in special_kfunc_list if !CONFIG_NET
Posted by Thomas Weißschuh 1 year, 1 month ago
If the function is not available its entry has to be replaced with
BTF_ID_UNUSED instead of skipped.
Otherwise the list doesn't work correctly.

Reported-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Closes: https://lore.kernel.org/lkml/CAADnVQJQpVziHzrPCCpGE5=8uzw2OkxP8gqe1FkJ6_XVVyVbNw@mail.gmail.com/
Fixes: 00a5acdbf398 ("bpf: Fix configuration-dependent BTF function references")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 kernel/bpf/verifier.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index f27274e933e55342dcefa482a9ac75313d0d3469..44616b492f87cf4e1dc354e34d9158f13079dda7 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -11739,6 +11739,9 @@ BTF_ID(func, bpf_rbtree_first)
 #ifdef CONFIG_NET
 BTF_ID(func, bpf_dynptr_from_skb)
 BTF_ID(func, bpf_dynptr_from_xdp)
+#else
+BTF_ID_UNUSED
+BTF_ID_UNUSED
 #endif
 BTF_ID(func, bpf_dynptr_slice)
 BTF_ID(func, bpf_dynptr_slice_rdwr)

---
base-commit: c2ce3bb13ae7f4445a5e8fb12254b2dacefd309c
change-id: 20241219-bpf-fix-special_kfunc_list-cddcf0ba5216

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>

Re: [PATCH] bpf: Fix holes in special_kfunc_list if !CONFIG_NET
Posted by Jiri Olsa 1 year, 1 month ago
On Thu, Dec 19, 2024 at 10:41:41PM +0100, Thomas Weißschuh wrote:
> If the function is not available its entry has to be replaced with
> BTF_ID_UNUSED instead of skipped.
> Otherwise the list doesn't work correctly.
> 
> Reported-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
> Closes: https://lore.kernel.org/lkml/CAADnVQJQpVziHzrPCCpGE5=8uzw2OkxP8gqe1FkJ6_XVVyVbNw@mail.gmail.com/
> Fixes: 00a5acdbf398 ("bpf: Fix configuration-dependent BTF function references")
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

Acked-by: Jiri Olsa <jolsa@kernel.org>

jirka

> ---
>  kernel/bpf/verifier.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index f27274e933e55342dcefa482a9ac75313d0d3469..44616b492f87cf4e1dc354e34d9158f13079dda7 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -11739,6 +11739,9 @@ BTF_ID(func, bpf_rbtree_first)
>  #ifdef CONFIG_NET
>  BTF_ID(func, bpf_dynptr_from_skb)
>  BTF_ID(func, bpf_dynptr_from_xdp)
> +#else
> +BTF_ID_UNUSED
> +BTF_ID_UNUSED
>  #endif
>  BTF_ID(func, bpf_dynptr_slice)
>  BTF_ID(func, bpf_dynptr_slice_rdwr)
> 
> ---
> base-commit: c2ce3bb13ae7f4445a5e8fb12254b2dacefd309c
> change-id: 20241219-bpf-fix-special_kfunc_list-cddcf0ba5216
> 
> Best regards,
> -- 
> Thomas Weißschuh <linux@weissschuh.net>
>