]> git.ipfire.org Git - thirdparty/linux.git/commit
bpftool: btf: Validate root_type_ids early
authorDaniel Xu <dxu@dxuuu.xyz>
Fri, 13 Dec 2024 19:44:10 +0000 (12:44 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 13 Dec 2024 22:35:42 +0000 (14:35 -0800)
commit7f5819e1ace85632cf58c43ab6c38d2d4b0aa161
tree8cfd36650eaa316201b814b3faeac3222fb156be
parent5e3ad22d82238e8bcb4c7ec26a20533217ddfb18
bpftool: btf: Validate root_type_ids early

Handle invalid root_type_ids early, as an invalid ID will cause dumpers
to half-emit valid boilerplate and then bail with an unclean exit. This
is ugly and possibly confusing for users, so preemptively handle the
common error case before any dumping begins.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/33e09a08a6072f8381cb976218a009709309b7e1.1734119028.git.dxu@dxuuu.xyz
tools/bpf/bpftool/btf.c