Ubuntu-focal-kernel/tools
Andreas Ziegler fd556b8af6 libbpf: Add NULL checks to bpf_object__{prev_map,next_map}
BugLink: https://bugs.launchpad.net/bugs/2081278

[ 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>
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
2024-09-27 10:50:33 +02:00
..
accounting
arch x86/insn: Fix PUSH instruction in x86 instruction decoder opcode map 2024-07-05 10:51:59 +02:00
bpf
build
cgroup
debugging
firewire
firmware
gpio
hv
iio tools: iio: replace seekdir() in iio_generic_buffer 2024-06-07 15:01:41 +02:00
include tools: move alignment-related macros to new <linux/align.h> 2024-09-27 10:50:27 +02:00
io_uring
kvm/kvm_stat
laptop
leds
lib libbpf: Add NULL checks to bpf_object__{prev_map,next_map} 2024-09-27 10:50:33 +02:00
memory-model tools/memory-model: Fix bug in lock.cat 2024-09-27 10:50:14 +02:00
nfsd
objtool objtool: Add support for intra-function calls 2024-06-07 15:01:36 +02:00
pci
pcmcia
perf perf report: Fix condition in sort__sym_cmp() 2024-09-27 10:50:12 +02:00
power tools/power turbostat: Fix Bzy_MHz documentation typo 2024-07-05 10:51:52 +02:00
scripts
spi
testing tc-testing: don't access non-existent variable on exception 2024-09-27 10:50:26 +02:00
thermal/tmon
time
usb
virtio
vm
wmi
Makefile