summaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/bpf_helpers.h
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2021-04-23 11:13:34 -0700
committerAlexei Starovoitov <ast@kernel.org>2021-04-23 14:05:26 -0700
commitaea28a602fa19fb4fe66374030ab7e2c8ddf643e (patch)
tree044aaf22b476bf1e16840f21a1a34eb996eed748 /tools/lib/bpf/bpf_helpers.h
parent0fec7a3cee1cf8e4f86ff563d229408ccbdc2d66 (diff)
downloadlinux-stable-aea28a602fa19fb4fe66374030ab7e2c8ddf643e.tar.gz
linux-stable-aea28a602fa19fb4fe66374030ab7e2c8ddf643e.tar.bz2
linux-stable-aea28a602fa19fb4fe66374030ab7e2c8ddf643e.zip
libbpf: Mark BPF subprogs with hidden visibility as static for BPF verifier
Define __hidden helper macro in bpf_helpers.h, which is a short-hand for __attribute__((visibility("hidden"))). Add libbpf support to mark BPF subprograms marked with __hidden as static in BTF information to enforce BPF verifier's static function validation algorithm, which takes more information (caller's context) into account during a subprogram validation. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20210423181348.1801389-5-andrii@kernel.org
Diffstat (limited to 'tools/lib/bpf/bpf_helpers.h')
-rw-r--r--tools/lib/bpf/bpf_helpers.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h
index 75c7581b304c..9720dc0b4605 100644
--- a/tools/lib/bpf/bpf_helpers.h
+++ b/tools/lib/bpf/bpf_helpers.h
@@ -47,6 +47,14 @@
#define __weak __attribute__((weak))
#endif
+/*
+ * Use __hidden attribute to mark a non-static BPF subprogram effectively
+ * static for BPF verifier's verification algorithm purposes, allowing more
+ * extensive and permissive BPF verification process, taking into account
+ * subprogram's caller context.
+ */
+#define __hidden __attribute__((visibility("hidden")))
+
/* When utilizing vmlinux.h with BPF CO-RE, user BPF programs can't include
* any system-level headers (such as stddef.h, linux/version.h, etc), and
* commonly-used macros like NULL and KERNEL_VERSION aren't available through