kernel_samsung_a53x/tools/lib
Andreas Ziegler 892da579fb libbpf: Add NULL checks to bpf_object__{prev_map,next_map}
[ Upstream commit cedc12c5b57f7efa6dbebfb2b140e8675f5a2616 ]

In the current state, an erroneous call to
bpf_object__find_map_by_name(NULL, ...) leads to a segmentation
fault through the following call chain:

  bpf_object__find_map_by_name(obj = NULL, ...)
  -> bpf_object__for_each_map(pos, obj = NULL)
  -> bpf_object__next_map((obj = NULL), NULL)
  -> return (obj = NULL)->maps

While calling bpf_object__find_map_by_name with obj = NULL is
obviously incorrect, this should not lead to a segmentation
fault but rather be handled gracefully.

As __bpf_map__iter already handles this situation correctly, we
can delegate the check for the regular case there and only add
a check in case the prev or next parameter is NULL.

Signed-off-by: Andreas Ziegler <ziegler.andreas@siemens.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20240703083436.505124-1-ziegler.andreas@siemens.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-01-19 00:10:00 +01:00
..
api libapi: Add missing linux/types.h header to get the __u64 type on io.h 2024-11-18 12:12:49 +01:00
bpf libbpf: Add NULL checks to bpf_object__{prev_map,next_map} 2025-01-19 00:10:00 +01:00
lockdep Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
perf libperf evlist: Avoid out-of-bounds access 2024-11-19 09:23:14 +01:00
subcmd libsubcmd: Fix parse-options memory leak 2024-11-19 12:27:05 +01:00
symbol Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
traceevent Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
argv_split.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bitmap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ctype.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
find_bit.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hweight.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rbtree.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
str_error_r.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
string.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vsprintf.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
zalloc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00