OSDN Git Service

libbpf: Fail early when loading programs with unspecified type
authorAndrei Matei <andreimatei1@gmail.com>
Thu, 3 Dec 2020 04:34:10 +0000 (23:34 -0500)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 3 Dec 2020 19:37:05 +0000 (11:37 -0800)
commit80b2b5c3a701d56de98d00d99bc9cc384fb316d9
treede3e4fcc2771f5974b06446cb2decd09c28ebf22
parenta8b415c9bde69dc194e57db8c27cb96908b30aca
libbpf: Fail early when loading programs with unspecified type

Before this patch, a program with unspecified type
(BPF_PROG_TYPE_UNSPEC) would be passed to the BPF syscall, only to have
the kernel reject it with an opaque invalid argument error. This patch
makes libbpf reject such programs with a nicer error message - in
particular libbpf now tries to diagnose bad ELF section names at both
open time and load time.

Signed-off-by: Andrei Matei <andreimatei1@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20201203043410.59699-1-andreimatei1@gmail.com
tools/lib/bpf/libbpf.c