diff options
author | Alexei Starovoitov <ast@kernel.org> | 2021-12-01 21:10:34 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-01-27 13:03:24 +0300 |
commit | db3c2121d191ab82d68d54c02f6e90aeac33226f (patch) | |
tree | 3b3dcf2ac6ea598bbab70feb012da380b6f4471b /tools | |
parent | e833ef0b545e1a5b3eaf00af391c4fd1fb47ffd8 (diff) | |
download | linux-db3c2121d191ab82d68d54c02f6e90aeac33226f.tar.xz |
libbpf: Clean gen_loader's attach kind.
[ Upstream commit 19250f5fc0c283892a61f3abf9d65e6325f63897 ]
The gen_loader has to clear attach_kind otherwise the programs
without attach_btf_id will fail load if they follow programs
with attach_btf_id.
Fixes: 67234743736a ("libbpf: Generate loader program out of BPF ELF file.")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211201181040.23337-12-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/bpf/gen_loader.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/lib/bpf/gen_loader.c b/tools/lib/bpf/gen_loader.c index 8df718a6b142..33c19590ee43 100644 --- a/tools/lib/bpf/gen_loader.c +++ b/tools/lib/bpf/gen_loader.c @@ -663,9 +663,11 @@ void bpf_gen__prog_load(struct bpf_gen *gen, debug_ret(gen, "prog_load %s insn_cnt %d", attr.prog_name, attr.insn_cnt); /* successful or not, close btf module FDs used in extern ksyms and attach_btf_obj_fd */ cleanup_relos(gen, insns); - if (gen->attach_kind) + if (gen->attach_kind) { emit_sys_close_blob(gen, attr_field(prog_load_attr, attach_btf_obj_fd)); + gen->attach_kind = 0; + } emit_check_err(gen); /* remember prog_fd in the stack, if successful */ emit(gen, BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_7, |