eBPF-based security platform
.github: let a poison pragma name the C library's integer types
Daniel Borkmann38bc041cdd4b
diff --git a/.github/scripts/check-style.sh b/.github/scripts/check-style.shindex 6f8c57e7..c2191e39 100755--- a/.github/scripts/check-style.sh+++ b/.github/scripts/check-style.sh@@ -177,17 +177,18 @@ locate_checkpatch() {# library's uint32_t. checkpatch's PREFER_KERNEL_TYPES suggests the# kernel-internal u32 and leaves tools/ out, so it stays off and this# reports an added line that names uint8_t through int64_t outside a-# string or a comment, in the form checkpatch reports in, and in-# userspace one that names unsigned char, short, int or long. Those stay-# where an interface fixes them: BPF programs spell hook arguments as-# the kernel's prototypes do, include/shirudo/misc.h defines the kernel-# types from them, util/elf_target.c hands libbpf the unsigned long **-# it takes, and util/sign.c is vendored. A call to strtoul() and its kin-# or atoi() is reported too, outside the tests: a number is parsed with-# parse_u64() and its kin from <shirudo/string.h>, which take a length,-# read nothing past it and refuse a sign, blank or base prefix. So is a-# string copied with strcpy() and its kin or with snprintf("%s") on one-# line: strscpy() always terminates and says when it cut.+# string, a comment or the #pragma GCC poison that refuses them, in the+# form checkpatch reports in, and in userspace one that names unsigned+# char, short, int or long. Those stay where an interface fixes them: BPF+# programs spell hook arguments as the kernel's prototypes do,+# include/shirudo/misc.h defines the kernel types from them,+# util/elf_target.c hands libbpf the unsigned long ** it takes, and+# util/sign.c is vendored. A call to strtoul() and its kin or atoi() is+# reported too, outside the tests: a number is parsed with parse_u64() and+# its kin from <shirudo/string.h>, which take a length, read nothing past+# it and refuse a sign, blank or base prefix. So is a string copied with+# strcpy() and its kin or with snprintf("%s") on one line: strscpy() always+# terminates and says when it cut.check_spellings() {awk 'function c_names_kept(f) {@@ -239,6 +240,8 @@ check_spellings() {nextif (substr($0, 1, 1) != "+")next+ if (code ~ /^[ \t]*#[ \t]*pragma[ \t]+GCC[ \t]+poison[ \t]/)+ nextif (match(code, /(^|[^A-Za-z0-9_])u?int(8|16|32|64)_t([^A-Za-z0-9_]|$)/)) {type = substr(code, RSTART, RLENGTH)gsub(/[^A-Za-z0-9_]/, "", type)diff --git a/testing/t0043-check-style.sh b/testing/t0043-check-style.shindex 64818553..46769fbb 100644--- a/testing/t0043-check-style.sh+++ b/testing/t0043-check-style.sh@@ -193,6 +193,7 @@ test_expect_success 'the C library'"'"'s integer names are refused in code only'printf "%s\n" "/* uint32_t in a comment */" \"static const char *name = \"uint64_t\";" \"static __u16 kept;" "static uint32_t width;" \+ "#pragma GCC poison uint8_t uint32_t" \"static unsigned long mask;" "static unsigned char byte;" \>>"$R/good.c" &&! check --diff &&