diff options
author | Andreas Ziegler <ziegler.andreas@siemens.com> | 2024-07-03 10:34:36 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2024-07-08 18:13:07 +0200 |
commit | cedc12c5b57f7efa6dbebfb2b140e8675f5a2616 (patch) | |
tree | 3465b787ffaef87b551ab865061c932184ca5ab3 /fs | |
parent | 02480fe8a6a6d44c16900b1d3a2a66d140d0a005 (diff) |
libbpf: Add NULL checks to bpf_object__{prev_map,next_map}
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
Diffstat (limited to 'fs')
0 files changed, 0 insertions, 0 deletions