]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
libbpf: Centralize poisoning and poison reallocarray()
authorAndrii Nakryiko <andriin@fb.com>
Wed, 19 Aug 2020 01:36:06 +0000 (18:36 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 19 Aug 2020 01:38:25 +0000 (18:38 -0700)
Most of libbpf source files already include libbpf_internal.h, so it's a good
place to centralize identifier poisoning. So move kernel integer type
poisoning there. And also add reallocarray to a poison list to prevent
accidental use of it. libbpf_reallocarray() should be used universally
instead.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200819013607.3607269-4-andriin@fb.com
12 files changed:
tools/lib/bpf/bpf.c
tools/lib/bpf/bpf_prog_linfo.c
tools/lib/bpf/btf.c
tools/lib/bpf/btf_dump.c
tools/lib/bpf/hashmap.c
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_internal.h
tools/lib/bpf/libbpf_probes.c
tools/lib/bpf/netlink.c
tools/lib/bpf/nlattr.c
tools/lib/bpf/ringbuf.c
tools/lib/bpf/xsk.c

index 0750681057c28c0337d6d849c4fb7118f8c4cc07..82b983ff65697aca5ca47b49b364572b9e25ee0a 100644 (file)
@@ -32,9 +32,6 @@
 #include "libbpf.h"
 #include "libbpf_internal.h"
 
-/* make sure libbpf doesn't use kernel-only integer typedefs */
-#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-
 /*
  * When building perf, unistd.h is overridden. __NR_bpf is
  * required to be defined explicitly.
index bafca49cb1e65de5ef8c918ab405971c6d746b6d..3ed1a27b5f7ce2cf9589c12a5dd8a3da3ad33844 100644 (file)
@@ -8,9 +8,6 @@
 #include "libbpf.h"
 #include "libbpf_internal.h"
 
-/* make sure libbpf doesn't use kernel-only integer typedefs */
-#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-
 struct bpf_prog_linfo {
        void *raw_linfo;
        void *raw_jited_linfo;
index 1b7d85d94a07eb79a1a73edf51c5ac4ba51c1c9c..a3d259e614b0e5bf166ce8a1aed734218ef32d36 100644 (file)
@@ -21,9 +21,6 @@
 #include "libbpf_internal.h"
 #include "hashmap.h"
 
-/* make sure libbpf doesn't use kernel-only integer typedefs */
-#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-
 #define BTF_MAX_NR_TYPES 0x7fffffffU
 #define BTF_MAX_STR_OFFSET 0x7fffffffU
 
index 1ad852ad0a86bcd24c9152e71af18d545028a41d..0eaafd9bcfea5bf1a4385ae23e77486d53dfe771 100644 (file)
@@ -19,9 +19,6 @@
 #include "libbpf.h"
 #include "libbpf_internal.h"
 
-/* make sure libbpf doesn't use kernel-only integer typedefs */
-#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-
 static const char PREFIXES[] = "\t\t\t\t\t\t\t\t\t\t\t\t\t";
 static const size_t PREFIX_CNT = sizeof(PREFIXES) - 1;
 
index a405dad068f59dd6ab96a40759adc683fdcbf2c2..3c20b126d60d869aa136b24d4b01c93d6302938e 100644 (file)
@@ -15,6 +15,9 @@
 /* make sure libbpf doesn't use kernel-only integer typedefs */
 #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
 
+/* prevent accidental re-addition of reallocarray() */
+#pragma GCC poison reallocarray
+
 /* start with 4 buckets */
 #define HASHMAP_MIN_CAP_BITS 2
 
index 2653bcee73b778985e031f1eeed488684b87b1d3..4b96e0eefea841d9151c50a2c6088db46d67a240 100644 (file)
@@ -55,9 +55,6 @@
 #include "libbpf_internal.h"
 #include "hashmap.h"
 
-/* make sure libbpf doesn't use kernel-only integer typedefs */
-#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-
 #ifndef EM_BPF
 #define EM_BPF 247
 #endif
index 65931e989eea23900bbb571593efb95c4e9a8e31..c8ed352671d5b4f012d89e727350bf5a8ef41efc 100644 (file)
 #define __LIBBPF_LIBBPF_INTERNAL_H
 
 #include <stdlib.h>
+
+/* make sure libbpf doesn't use kernel-only integer typedefs */
+#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
+
+/* prevent accidental re-addition of reallocarray() */
+#pragma GCC poison reallocarray
+
 #include "libbpf.h"
 
 #define BTF_INFO_ENC(kind, kind_flag, vlen) \
index 5a3d3f07840816597c4c8c35a767e77e79fa4609..010c9a76fd2bc056635aa7a5cf0ecc7ee894bb00 100644 (file)
@@ -17,9 +17,6 @@
 #include "libbpf.h"
 #include "libbpf_internal.h"
 
-/* make sure libbpf doesn't use kernel-only integer typedefs */
-#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-
 static bool grep(const char *buffer, const char *pattern)
 {
        return !!strstr(buffer, pattern);
index 2465538a5ba997bf75fc8655e2d66a38af2b12ec..4dd73de00b6f1c0a413ff01c15c5352f824f4167 100644 (file)
@@ -15,9 +15,6 @@
 #include "libbpf_internal.h"
 #include "nlattr.h"
 
-/* make sure libbpf doesn't use kernel-only integer typedefs */
-#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-
 #ifndef SOL_NETLINK
 #define SOL_NETLINK 270
 #endif
index 0ad41dfea8eb2b9152dd9ecb4eeb80cde791a064..b607fa9852b1cb59a59541463a2fa5cb32a360a0 100644 (file)
@@ -7,14 +7,11 @@
  */
 
 #include <errno.h>
-#include "nlattr.h"
-#include "libbpf_internal.h"
-#include <linux/rtnetlink.h>
 #include <string.h>
 #include <stdio.h>
-
-/* make sure libbpf doesn't use kernel-only integer typedefs */
-#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
+#include <linux/rtnetlink.h>
+#include "nlattr.h"
+#include "libbpf_internal.h"
 
 static uint16_t nla_attr_minlen[LIBBPF_NLA_TYPE_MAX+1] = {
        [LIBBPF_NLA_U8]         = sizeof(uint8_t),
index 5bd234be8a147a61054d8d453916b9b9f2c19215..5c6522c89af1673c9870ecf09b0d649cf9468ccd 100644 (file)
@@ -21,9 +21,6 @@
 #include "libbpf_internal.h"
 #include "bpf.h"
 
-/* make sure libbpf doesn't use kernel-only integer typedefs */
-#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-
 struct ring {
        ring_buffer_sample_fn sample_cb;
        void *ctx;
index f7f4efb70a4c1046af9afec34be288f8f4f254e7..a9b02103767b885d45d548dc7d9fb8c8badd7760 100644 (file)
@@ -32,9 +32,6 @@
 #include "libbpf_internal.h"
 #include "xsk.h"
 
-/* make sure libbpf doesn't use kernel-only integer typedefs */
-#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-
 #ifndef SOL_XDP
  #define SOL_XDP 283
 #endif