tools: bpf: make use of reallocarray
authorJakub Kicinski <[email protected]>
Tue, 10 Jul 2018 21:43:05 +0000 (14:43 -0700)
committerDaniel Borkmann <[email protected]>
Wed, 11 Jul 2018 20:13:34 +0000 (22:13 +0200)
commit531b014e7a2fedaeff0b19b2934d830cd4b35dc0
tree0de8355e9d533b4f6f90c3b389f58c992e75bb14
parent8d13406c02f9c38f106416e1dbe0e68059b9f59a
tools: bpf: make use of reallocarray

reallocarray() is a safer variant of realloc which checks for
multiplication overflow in case of array allocation.  Since it's
not available in Glibc < 2.26 import kernel's overflow.h and
add a static inline implementation when needed.  Use feature
detection to probe for existence of reallocarray.

Signed-off-by: Jakub Kicinski <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Reviewed-by: Jiong Wang <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
tools/bpf/bpftool/Makefile
tools/bpf/bpftool/main.h
tools/bpf/bpftool/xlated_dumper.c
tools/build/feature/Makefile
tools/build/feature/test-reallocarray.c [new file with mode: 0644]
tools/include/linux/compiler-gcc.h
tools/include/linux/overflow.h [new file with mode: 0644]
tools/include/tools/libc_compat.h [new file with mode: 0644]
tools/lib/bpf/Makefile
tools/lib/bpf/libbpf.c