Skip to contentSkip to conversation

bpf: fix warning for bpf_cpumask in verifier

PATCH Applied Hari Bathini 5 participants 7 messages Feb 8, 2024 – Feb 13, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: fix warning for bpf_cpumask in verifier

Compiling with CONFIG_BPF_SYSCALL & !CONFIG_BPF_JIT throws the below warning:

"WARN: resolve_btfids: unresolved symbol bpf_cpumask"

Fix it by adding the appropriate #ifdef.

---
 kernel/bpf/verifier.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/bpf/verifier.c +2 -0
index 65f598694d55..b263f093ee76 100644
@@ -5227,7 +5227,9 @@ BTF_ID(struct, prog_test_ref_kfunc)
 #ifdef CONFIG_CGROUPS
 BTF_ID(struct, cgroup)
 #endif
+#ifdef CONFIG_BPF_JIT
 BTF_ID(struct, bpf_cpumask)
+#endif
 BTF_ID(struct, task_struct)
 BTF_SET_END(rcu_protected_types)
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · Hari Bathini

Compiling with CONFIG_BPF_SYSCALL & !CONFIG_BPF_JIT throws the below warning:

"WARN: resolve_btfids: unresolved symbol bpf_cpumask"

Fix it by adding the appropriate #ifdef.

Can you explain a bit more on why CONFIG_BPF_JIT is appropriate here? kernel/bpf/cpumask.c seems to be gated by CONFIG_BPF_SYSCALL.
So presumably all those symbols should be still compiled in with !CONFIG_BPF_JIT?

#2 lore raw
Quoted 11 lines · Stanislav Fomichev
Quoted 6 lines · Hari Bathini

Compiling with CONFIG_BPF_SYSCALL & !CONFIG_BPF_JIT throws the below warning:

"WARN: resolve_btfids: unresolved symbol bpf_cpumask"

Fix it by adding the appropriate #ifdef.

Can you explain a bit more on why CONFIG_BPF_JIT is appropriate here? kernel/bpf/cpumask.c seems to be gated by CONFIG_BPF_SYSCALL.
So presumably all those symbols should be still compiled in with !CONFIG_BPF_JIT?

Actually, CONFIG_BPF_JIT is the precondition for cpumask.c where bpf_cpumask structure is defined.

  ifeq ($(CONFIG_BPF_JIT),y)
  obj-$(CONFIG_BPF_SYSCALL) += bpf_struct_ops.o
  obj-$(CONFIG_BPF_SYSCALL) += cpumask.o
  obj-${CONFIG_BPF_LSM} += bpf_lsm.o
  endif

Thanks
Hari

Acked-by on v1 1/1
#4 lore raw
In reply to Hari Bathini
Quoted 8 lines · Hari Bathini

Compiling with CONFIG_BPF_SYSCALL & !CONFIG_BPF_JIT throws the below warning:

"WARN: resolve_btfids: unresolved symbol bpf_cpumask"

Fix it by adding the appropriate #ifdef.

jirka

Quoted 22 lines
---
 kernel/bpf/verifier.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/bpf/verifier.c +2 -0
index 65f598694d55..b263f093ee76 100644
@@ -5227,7 +5227,9 @@ BTF_ID(struct, prog_test_ref_kfunc)
 #ifdef CONFIG_CGROUPS
 BTF_ID(struct, cgroup)
 #endif
+#ifdef CONFIG_BPF_JIT
 BTF_ID(struct, bpf_cpumask)
+#endif
 BTF_ID(struct, task_struct)
 BTF_SET_END(rcu_protected_types)
 
Signature · 1 line
2.43.0
#3 lore raw
In reply to Hari Bathini
Quoted 16 lines · Hari Bathini
Quoted 11 lines · Stanislav Fomichev
Quoted 6 lines · Hari Bathini

Compiling with CONFIG_BPF_SYSCALL & !CONFIG_BPF_JIT throws the below warning:

"WARN: resolve_btfids: unresolved symbol bpf_cpumask"

Fix it by adding the appropriate #ifdef.

Can you explain a bit more on why CONFIG_BPF_JIT is appropriate here? kernel/bpf/cpumask.c seems to be gated by CONFIG_BPF_SYSCALL.
So presumably all those symbols should be still compiled in with !CONFIG_BPF_JIT?

Quoted 8 lines

Actually, CONFIG_BPF_JIT is the precondition for cpumask.c where bpf_cpumask structure is defined.

   ifeq ($(CONFIG_BPF_JIT),y)
   obj-$(CONFIG_BPF_SYSCALL) += bpf_struct_ops.o
   obj-$(CONFIG_BPF_SYSCALL) += cpumask.o
   obj-${CONFIG_BPF_LSM} += bpf_lsm.o
   endif

Ah, good point!

#6 lore raw
In reply to Hari Bathini
This patch was applied to bpf/bpf.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This patch was applied to bpf/bpf.git (master)
by Andrii Nakryiko <[email protected]>:

Quoted 8 lines · On Thu, 8 Feb 2024 15:31:15 +0530 you wrote:

Compiling with CONFIG_BPF_SYSCALL & !CONFIG_BPF_JIT throws the below warning:

"WARN: resolve_btfids: unresolved symbol bpf_cpumask"

Fix it by adding the appropriate #ifdef.

[...]

Here is the summary with links:
- bpf: fix warning for bpf_cpumask in verifier

    https://git.kernel.org/bpf/bpf/c/11f522256e90

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html