History

bpf: Fix configuration-dependent BTF function references

These BTF functions are not available unconditionally, only reference them when they are available. Avoid the following build warnings: BTF .tmp_vmlinux1.btf.o btf_encoder__tag_kfunc: failed to find kfunc 'bpf_send_signal_task' in BTF btf_encoder__tag_kfuncs: failed to tag kfunc 'bpf_send_signal_task' NM .tmp_vmlinux1.syms KSYMS .tmp_vmlinux1.kallsyms.S AS .tmp_vmlinux1.kallsyms.o LD .tmp_vmlinux2 NM .tmp_vmlinux2.syms KSYMS .tmp_vmlinux2.kallsyms.S AS .tmp_vmlinux2.kallsyms.o LD vmlinux BTFIDS vmlinux WARN: resolve_btfids: unresolved symbol prog_test_ref_kfunc WARN: resolve_btfids: unresolved symbol bpf_crypto_ctx WARN: resolve_btfids: unresolved symbol bpf_send_signal_task WARN: resolve_btfids: unresolved symbol bpf_modify_return_test_tp WARN: resolve_btfids: unresolved symbol bpf_dynptr_from_xdp WARN: resolve_btfids: unresolved symbol bpf_dynptr_from_skb

Thomas Weißschuh committed 1 year ago

Commit 00a5acd1 parent 3d1af4b2 files · +12 −0Browse files

Unified · Split

2 files
  1. kernel/bpf/helpers.c +4 −0
  2. kernel/bpf/verifier.c +8 −0
kernel/bpf/helpers.c+4−0
@@ -3104,7 +3104,9 @@ BTF_ID_FLAGS(func, bpf_task_get_cgroup1, KF_ACQUIRE | KF_RCU | KF_RET_NULL) · 3103 unmodified lines
31043104 BTF_ID_FLAGS(func, bpf_task_from_pid, KF_ACQUIRE | KF_RET_NULL)
31053105 BTF_ID_FLAGS(func, bpf_task_from_vpid, KF_ACQUIRE | KF_RET_NULL)
31063106 BTF_ID_FLAGS(func, bpf_throw)
3107+#ifdef CONFIG_BPF_EVENTS
31073108 BTF_ID_FLAGS(func, bpf_send_signal_task, KF_TRUSTED_ARGS)
3109+#endif
31083110 BTF_KFUNCS_END(generic_btf_ids)
31093111
31103112 static const struct btf_kfunc_id_set generic_kfunc_set = {
@@ -3150,7 +3152,9 @@ BTF_ID_FLAGS(func, bpf_dynptr_is_null) · 39 unmodified lines
31503152 BTF_ID_FLAGS(func, bpf_dynptr_is_rdonly)
31513153 BTF_ID_FLAGS(func, bpf_dynptr_size)
31523154 BTF_ID_FLAGS(func, bpf_dynptr_clone)
3155+#ifdef CONFIG_NET
31533156 BTF_ID_FLAGS(func, bpf_modify_return_test_tp)
3157+#endif
31543158 BTF_ID_FLAGS(func, bpf_wq_init)
31553159 BTF_ID_FLAGS(func, bpf_wq_set_callback_impl)
31563160 BTF_ID_FLAGS(func, bpf_wq_start)
kernel/bpf/verifier.c+8−0
@@ -5681,7 +5681,9 @@ static bool in_rcu_cs(struct bpf_verifier_env *env) · 5680 unmodified lines
56815681
56825682 /* Once GCC supports btf_type_tag the following mechanism will be replaced with tag check */
56835683 BTF_SET_START(rcu_protected_types)
5684+#ifdef CONFIG_NET
56845685 BTF_ID(struct, prog_test_ref_kfunc)
5686+#endif
56855687 #ifdef CONFIG_CGROUPS
56865688 BTF_ID(struct, cgroup)
56875689 #endif
@@ -5689,7 +5691,9 @@ BTF_ID(struct, cgroup) · 1 unmodified line
56895691 BTF_ID(struct, bpf_cpumask)
56905692 #endif
56915693 BTF_ID(struct, task_struct)
5694+#ifdef CONFIG_CRYPTO
56925695 BTF_ID(struct, bpf_crypto_ctx)
5696+#endif
56935697 BTF_SET_END(rcu_protected_types)
56945698
56955699 static bool rcu_protected_object(const struct btf *btf, u32 btf_id)
@@ -11722,8 +11726,10 @@ BTF_ID(func, bpf_rdonly_cast) · 6026 unmodified lines
1172211726 BTF_ID(func, bpf_rbtree_remove)
1172311727 BTF_ID(func, bpf_rbtree_add_impl)
1172411728 BTF_ID(func, bpf_rbtree_first)
11729+#ifdef CONFIG_NET
1172511730 BTF_ID(func, bpf_dynptr_from_skb)
1172611731 BTF_ID(func, bpf_dynptr_from_xdp)
11732+#endif
1172711733 BTF_ID(func, bpf_dynptr_slice)
1172811734 BTF_ID(func, bpf_dynptr_slice_rdwr)
1172911735 BTF_ID(func, bpf_dynptr_clone)
@@ -11751,8 +11757,10 @@ BTF_ID(func, bpf_rcu_read_unlock) · 21 unmodified lines
1175111757 BTF_ID(func, bpf_rbtree_remove)
1175211758 BTF_ID(func, bpf_rbtree_add_impl)
1175311759 BTF_ID(func, bpf_rbtree_first)
11760+#ifdef CONFIG_NET
1175411761 BTF_ID(func, bpf_dynptr_from_skb)
1175511762 BTF_ID(func, bpf_dynptr_from_xdp)
11763+#endif
1175611764 BTF_ID(func, bpf_dynptr_slice)
1175711765 BTF_ID(func, bpf_dynptr_slice_rdwr)
1175811766 BTF_ID(func, bpf_dynptr_clone)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t