diff options
author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2019-01-28 10:01:21 -0800 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-01-28 23:59:46 +0100 |
commit | 8c79b35693380d856dcbbc21629682a90f26ca62 (patch) | |
tree | 7d5369d287051417dc10d1c79c492cc5b9728b20 /net | |
parent | c9e4576743eeda8d24dedc164d65b78877f9a98c (diff) | |
download | lwn-8c79b35693380d856dcbbc21629682a90f26ca62.tar.gz lwn-8c79b35693380d856dcbbc21629682a90f26ca62.zip |
tools: bpftool: fix crash with un-owned prog arrays
Prog arrays don't have 'owner_prog_type' and 'owner_jited'
fields in their fdinfo when they are created. Those fields
are set and reported when first program is checked for
compatibility by bpf_prog_array_compatible().
This means that bpftool cannot expect the fields to always
be there. Currently trying to show maps on a system with
an un-owned prog array leads to a crash:
$ bpftool map show
389: prog_array name tail_call_map flags 0x0
Error: key 'owner_prog_type' not found in fdinfo
Error: key 'owner_jited' not found in fdinfo
key 4B value 4B max_entries 4 memlock 4096B
Segmentation fault (core dumped)
We pass a NULL pointer to atoi().
Remove the assumption that fdinfo keys are always present.
Add missing validations and remove the p_err() calls which
may lead to broken JSON output as caller will not propagate
the failure.
Fixes: 99a44bef5870 ("tools: bpftool: add owner_prog_type and owner_jited to bpftool output")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'net')
0 files changed, 0 insertions, 0 deletions