Netdev List
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/3] bpf: Fix builds broken by fatal resolve_btfids warnings
@ 2026-10-19 21:10 Sasha Levin
  2026-10-19 21:10 ` [PATCH bpf-next 1/3] bpf: Drop unused entries from special_kfunc_list again Sasha Levin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sasha Levin @ 2026-10-19 21:10 UTC (permalink / raw)
  To: bpf
  Cc: Sasha Levin, Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, Ihor Solodrai, Eric Dumazet, Kuniyuki Iwashima,
	Paolo Abeni, Willem de Bruijn, David S. Miller, Jakub Kicinski,
	Simon Horman, Amery Hung, Puranjay Mohan, Stanislav Fomichev,
	Mahe Tardy, Jiayuan Chen, linux-kernel, netdev, Petr Pavlu,
	Leon Hwang

Commit 201a454df948 ("resolve_btfids: Fix the --fatal_warnings exit
status") makes resolve_btfids warnings fail the build again with
CONFIG_WERROR=y. That exposed BTF ID references to functions some
configs don't build. KernelCI has been seeing i386
i386_defconfig+kselftest builds fail on linux-next since next-20261015:

  WARN: resolve_btfids: unresolved symbol bpf_arena_reserve_pages
  WARN: resolve_btfids: unresolved symbol bpf_arena_free_pages
  WARN: resolve_btfids: unresolved symbol bpf_arena_alloc_pages
  Failed to generate BTF for vmlinux
  Try to disable CONFIG_DEBUG_INFO_BTF

https://files.kernelci.org/kbuild-gcc-14-i386-kselftest-6ad2315ca3f195e1aa930c8a/build.log.gz

Patch 1 drops three special_kfunc_list entries that have no users,
bpf_arena_reserve_pages among them. Patch 2 makes the remaining arena
entries depend on the condition arena.o is built with. Patch 3 fixes the
same problem for bpf_lsm_socket_sendmsg in bpf_ksock.c, which breaks
x86_64 builds with CONFIG_BPF_LSM=y and CONFIG_SECURITY_NETWORK=n.

The entries left in special_kfunc_list resolve to the same IDs as
before, and the IDs that become BTF_ID_UNUSED were already zero.

Tested by building vmlinux with CONFIG_DEBUG_INFO_BTF=y and
CONFIG_WERROR=y for i386, x86_64, and x86_64 with CONFIG_BPF_LSM=y and
both CONFIG_SECURITY_NETWORK=n and =y, and comparing special_kfunc_list
and bpf_lsm_socket_sendmsg_id before and after the series.

Sasha Levin (3):
  bpf: Drop unused entries from special_kfunc_list again
  bpf: Don't reference arena kfuncs when arena isn't built
  bpf: Fix ksock build with BPF_LSM=y and SECURITY_NETWORK=n

 kernel/bpf/verifier.c | 11 +++++------
 net/core/bpf_ksock.c  |  7 ++++++-
 2 files changed, 11 insertions(+), 7 deletions(-)


base-commit: 25bb03f0a47b622b9025a1558bf2095ec1f55d26
-- 
2.53.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH bpf-next 1/3] bpf: Drop unused entries from special_kfunc_list again
  2026-10-19 21:10 [PATCH bpf-next 0/3] bpf: Fix builds broken by fatal resolve_btfids warnings Sasha Levin
@ 2026-10-19 21:10 ` Sasha Levin
  2026-10-19 21:10 ` [PATCH bpf-next 2/3] bpf: Don't reference arena kfuncs when arena isn't built Sasha Levin
  2026-10-19 21:10 ` [PATCH bpf-next 3/3] bpf: Fix ksock build with BPF_LSM=y and SECURITY_NETWORK=n Sasha Levin
  2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-10-19 21:10 UTC (permalink / raw)
  To: bpf
  Cc: Sasha Levin, Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, Ihor Solodrai, Eric Dumazet, Kuniyuki Iwashima,
	Paolo Abeni, Willem de Bruijn, David S. Miller, Jakub Kicinski,
	Simon Horman, Amery Hung, Puranjay Mohan, Stanislav Fomichev,
	Mahe Tardy, Jiayuan Chen, linux-kernel, netdev, Petr Pavlu,
	Leon Hwang

Commit 6f033615ef8f ("bpf: Trim special_kfunc_list in verifier") dropped
bpf_arena_reserve_pages, bpf_stream_vprintk and bpf_stream_print_stack
from special_kfunc_list once nothing used them anymore, but commit
ab7fff217fd1 ("bpf: Check helper and kfunc arguments in one path")
brought all three back without adding any users.

Besides being dead, the bpf_arena_reserve_pages entry can't be resolved
on 32-bit and !MMU kernels, which don't build arena.o, and since commit
201a454df948 ("resolve_btfids: Fix the --fatal_warnings exit status")
the resulting resolve_btfids warning fails the build with
CONFIG_WERROR=y:

  WARN: resolve_btfids: unresolved symbol bpf_arena_reserve_pages

Drop the three entries again.

Fixes: ab7fff217fd1 ("bpf: Check helper and kfunc arguments in one path")
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/verifier.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index d138688468236..22f095b9dca2d 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -13549,10 +13549,7 @@ enum special_kfunc_type {
 	KF_bpf_call_rcu_tasks_trace,
 	KF_bpf_arena_alloc_pages,
 	KF_bpf_arena_free_pages,
-	KF_bpf_arena_reserve_pages,
 	KF_bpf_session_is_return,
-	KF_bpf_stream_vprintk,
-	KF_bpf_stream_print_stack,
 };
 
 BTF_ID_LIST(special_kfunc_list)
@@ -13644,14 +13641,11 @@ BTF_ID(func, bpf_call_rcu)
 BTF_ID(func, bpf_call_rcu_tasks_trace)
 BTF_ID(func, bpf_arena_alloc_pages)
 BTF_ID(func, bpf_arena_free_pages)
-BTF_ID(func, bpf_arena_reserve_pages)
 #ifdef CONFIG_BPF_EVENTS
 BTF_ID(func, bpf_session_is_return)
 #else
 BTF_ID_UNUSED
 #endif
-BTF_ID(func, bpf_stream_vprintk)
-BTF_ID(func, bpf_stream_print_stack)
 
 static bool is_bpf_cast_to_kern_ctx_kfunc(const struct bpf_call_arg_meta *meta)
 {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH bpf-next 2/3] bpf: Don't reference arena kfuncs when arena isn't built
  2026-10-19 21:10 [PATCH bpf-next 0/3] bpf: Fix builds broken by fatal resolve_btfids warnings Sasha Levin
  2026-10-19 21:10 ` [PATCH bpf-next 1/3] bpf: Drop unused entries from special_kfunc_list again Sasha Levin
@ 2026-10-19 21:10 ` Sasha Levin
  2026-10-19 21:10 ` [PATCH bpf-next 3/3] bpf: Fix ksock build with BPF_LSM=y and SECURITY_NETWORK=n Sasha Levin
  2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-10-19 21:10 UTC (permalink / raw)
  To: bpf
  Cc: Sasha Levin, Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, Ihor Solodrai, Eric Dumazet, Kuniyuki Iwashima,
	Paolo Abeni, Willem de Bruijn, David S. Miller, Jakub Kicinski,
	Simon Horman, Amery Hung, Puranjay Mohan, Stanislav Fomichev,
	Mahe Tardy, Jiayuan Chen, linux-kernel, netdev, Petr Pavlu,
	Leon Hwang

kernel/bpf/Makefile builds arena.o only for CONFIG_MMU && CONFIG_64BIT,
but special_kfunc_list references bpf_arena_alloc_pages() and
bpf_arena_free_pages() unconditionally, so on 32-bit and !MMU kernels
resolve_btfids can't resolve them:

  WARN: resolve_btfids: unresolved symbol bpf_arena_free_pages
  WARN: resolve_btfids: unresolved symbol bpf_arena_alloc_pages

Since commit 201a454df948 ("resolve_btfids: Fix the --fatal_warnings
exit status") these warnings fail the build with CONFIG_WERROR=y, which
breaks i386 builds with CONFIG_DEBUG_INFO_BTF=y:

  Failed to generate BTF for vmlinux
  Try to disable CONFIG_DEBUG_INFO_BTF

Only reference them under the condition arena.o is built with, and use
BTF_ID_UNUSED otherwise to keep the list in sync with enum
special_kfunc_type. An unresolved ID is zero, like BTF_ID_UNUSED, so the
contents of the list don't change.

Fixes: b8467290edab ("bpf: arena: make arena kfuncs any context safe")
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/verifier.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 22f095b9dca2d..12229713a4528 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -13639,8 +13639,13 @@ BTF_ID(func, bpf_task_work_schedule_signal)
 BTF_ID(func, bpf_task_work_schedule_resume)
 BTF_ID(func, bpf_call_rcu)
 BTF_ID(func, bpf_call_rcu_tasks_trace)
+#if defined(CONFIG_MMU) && defined(CONFIG_64BIT)
 BTF_ID(func, bpf_arena_alloc_pages)
 BTF_ID(func, bpf_arena_free_pages)
+#else
+BTF_ID_UNUSED
+BTF_ID_UNUSED
+#endif
 #ifdef CONFIG_BPF_EVENTS
 BTF_ID(func, bpf_session_is_return)
 #else
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH bpf-next 3/3] bpf: Fix ksock build with BPF_LSM=y and SECURITY_NETWORK=n
  2026-10-19 21:10 [PATCH bpf-next 0/3] bpf: Fix builds broken by fatal resolve_btfids warnings Sasha Levin
  2026-10-19 21:10 ` [PATCH bpf-next 1/3] bpf: Drop unused entries from special_kfunc_list again Sasha Levin
  2026-10-19 21:10 ` [PATCH bpf-next 2/3] bpf: Don't reference arena kfuncs when arena isn't built Sasha Levin
@ 2026-10-19 21:10 ` Sasha Levin
  2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-10-19 21:10 UTC (permalink / raw)
  To: bpf
  Cc: Sasha Levin, Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, Ihor Solodrai, Eric Dumazet, Kuniyuki Iwashima,
	Paolo Abeni, Willem de Bruijn, David S. Miller, Jakub Kicinski,
	Simon Horman, Amery Hung, Puranjay Mohan, Stanislav Fomichev,
	Mahe Tardy, Jiayuan Chen, linux-kernel, netdev, Petr Pavlu,
	Leon Hwang

bpf_ksock.c references bpf_lsm_socket_sendmsg() whenever
CONFIG_BPF_LSM=y, but the socket LSM hooks, and with them the BPF LSM
socket_sendmsg hook, only exist with CONFIG_SECURITY_NETWORK=y. Without
it resolve_btfids warns:

  WARN: resolve_btfids: unresolved symbol bpf_lsm_socket_sendmsg

and since commit 201a454df948 ("resolve_btfids: Fix the --fatal_warnings
exit status") that fails the build with CONFIG_WERROR=y.

Only reference the hook with CONFIG_SECURITY_NETWORK=y, and use
BTF_ID_UNUSED otherwise. The ID stays zero, as it was when unresolved,
so bpf_ksock_kfunc_filter() keeps allowing LSM programs: none can be
attached to socket_sendmsg without CONFIG_SECURITY_NETWORK.

Fixes: 7ae4eb14c5f9 ("bpf: Add ksock kfuncs")
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/core/bpf_ksock.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/core/bpf_ksock.c b/net/core/bpf_ksock.c
index 7bf796193ab61..48a2e2327acef 100644
--- a/net/core/bpf_ksock.c
+++ b/net/core/bpf_ksock.c
@@ -258,7 +258,12 @@ BTF_ID_FLAGS(func, bpf_ksock_send, KF_SLEEPABLE)
 BTF_KFUNCS_END(ksock_kfunc_btf_ids)
 
 #ifdef CONFIG_BPF_LSM
-BTF_ID_LIST_SINGLE(bpf_lsm_socket_sendmsg_id, func, bpf_lsm_socket_sendmsg)
+BTF_ID_LIST(bpf_lsm_socket_sendmsg_id)
+#ifdef CONFIG_SECURITY_NETWORK
+BTF_ID(func, bpf_lsm_socket_sendmsg)
+#else
+BTF_ID_UNUSED
+#endif
 #endif
 
 static int bpf_ksock_kfunc_filter(const struct bpf_prog *prog, u32 kfunc_id)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-19 21:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 21:10 [PATCH bpf-next 0/3] bpf: Fix builds broken by fatal resolve_btfids warnings Sasha Levin
2026-10-19 21:10 ` [PATCH bpf-next 1/3] bpf: Drop unused entries from special_kfunc_list again Sasha Levin
2026-10-19 21:10 ` [PATCH bpf-next 2/3] bpf: Don't reference arena kfuncs when arena isn't built Sasha Levin
2026-10-19 21:10 ` [PATCH bpf-next 3/3] bpf: Fix ksock build with BPF_LSM=y and SECURITY_NETWORK=n Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox