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 <jakub.kicinski@netronome.com> Reviewed-by:
Quentin Monnet <quentin.monnet@netronome.com> Reviewed-by:
Jiong Wang <jiong.wang@netronome.com> Signed-off-by:
Daniel Borkmann <daniel@iogearbox.net>
Showing
- tools/bpf/bpftool/Makefile 5 additions, 1 deletiontools/bpf/bpftool/Makefile
- tools/bpf/bpftool/main.h 1 addition, 0 deletionstools/bpf/bpftool/main.h
- tools/bpf/bpftool/xlated_dumper.c 3 additions, 3 deletionstools/bpf/bpftool/xlated_dumper.c
- tools/build/feature/Makefile 4 additions, 0 deletionstools/build/feature/Makefile
- tools/build/feature/test-reallocarray.c 8 additions, 0 deletionstools/build/feature/test-reallocarray.c
- tools/include/linux/compiler-gcc.h 4 additions, 0 deletionstools/include/linux/compiler-gcc.h
- tools/include/linux/overflow.h 278 additions, 0 deletionstools/include/linux/overflow.h
- tools/include/tools/libc_compat.h 20 additions, 0 deletionstools/include/tools/libc_compat.h
- tools/lib/bpf/Makefile 5 additions, 1 deletiontools/lib/bpf/Makefile
- tools/lib/bpf/libbpf.c 6 additions, 4 deletionstools/lib/bpf/libbpf.c
Loading
Please register or sign in to comment