]> git.baikalelectronics.ru Git - kernel.git/commit
tools, bpftool: Skip type probe if name is not found
authorQuentin Monnet <quentin@isovalent.com>
Fri, 24 Jul 2020 09:06:17 +0000 (10:06 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 27 Jul 2020 20:40:25 +0000 (22:40 +0200)
commit28d6d8c2ece38f5541ec3390f11ceac9235bc170
treedc3a2d7515e3ba07d9e4610a1501a26d7662682d
parent4023e47b85bc4542e53953b358180fb775d94c69
tools, bpftool: Skip type probe if name is not found

For probing program and map types, bpftool loops on type values and uses
the relevant type name in prog_type_name[] or map_type_name[]. To ensure
the name exists, we exit from the loop if we go over the size of the
array.

However, this is not enough in the case where the arrays have "holes" in
them, program or map types for which they have no name, but not at the
end of the list. This is currently the case for BPF_PROG_TYPE_LSM, not
known to bpftool and which name is a null string. When probing for
features, bpftool attempts to strlen() that name and segfaults.

Let's fix it by skipping probes for "unknown" program and map types,
with an informational message giving the numeral value in that case.

Fixes: cbe2671ae9b1 ("tools/bpftool: Add name mappings for SK_LOOKUP prog and attach type")
Reported-by: Paul Chaignon <paul@cilium.io>
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200724090618.16378-2-quentin@isovalent.com
tools/bpf/bpftool/feature.c