* [PATCH bpf-next] bpf: fix a libbpf loader issue
@ 2018-11-21 19:22 Yonghong Song
2018-11-21 20:02 ` Martin Lau
2018-11-21 21:23 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Yonghong Song @ 2018-11-21 19:22 UTC (permalink / raw)
To: ast, daniel, netdev; +Cc: kernel-team
Commit 2993e0515bb4 ("tools/bpf: add support to read .BTF.ext sections")
added support to read .BTF.ext sections from an object file, create
and pass prog_btf_fd and func_info to the kernel.
The program btf_fd (prog->btf_fd) is initialized to be -1 to please
zclose so we do not need special handling dur prog close.
Passing -1 to the kernel, however, will cause loading error.
Passing btf_fd 0 to the kernel if prog->btf_fd is invalid
fixed the problem.
Fixes: 2993e0515bb4 ("tools/bpf: add support to read .BTF.ext sections")
Reported-by: Andrey Ignatov <rdna@fb.com>
Reported-by: Emre Cantimur <haydum@fb.com>
Tested-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
---
tools/lib/bpf/libbpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index cb6565d79603..f022ac82e882 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1387,7 +1387,7 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
load_attr.license = license;
load_attr.kern_version = kern_version;
load_attr.prog_ifindex = prog->prog_ifindex;
- load_attr.prog_btf_fd = prog->btf_fd;
+ load_attr.prog_btf_fd = prog->btf_fd >= 0 ? prog->btf_fd : 0;
load_attr.func_info = prog->func_info;
load_attr.func_info_rec_size = prog->func_info_rec_size;
load_attr.func_info_cnt = func_info_cnt;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] bpf: fix a libbpf loader issue
2018-11-21 19:22 [PATCH bpf-next] bpf: fix a libbpf loader issue Yonghong Song
@ 2018-11-21 20:02 ` Martin Lau
2018-11-21 21:23 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Martin Lau @ 2018-11-21 20:02 UTC (permalink / raw)
To: Yonghong Song
Cc: Alexei Starovoitov, daniel@iogearbox.net, netdev@vger.kernel.org,
Kernel Team
On Wed, Nov 21, 2018 at 11:22:42AM -0800, Yonghong Song wrote:
> Commit 2993e0515bb4 ("tools/bpf: add support to read .BTF.ext sections")
> added support to read .BTF.ext sections from an object file, create
> and pass prog_btf_fd and func_info to the kernel.
>
> The program btf_fd (prog->btf_fd) is initialized to be -1 to please
> zclose so we do not need special handling dur prog close.
> Passing -1 to the kernel, however, will cause loading error.
> Passing btf_fd 0 to the kernel if prog->btf_fd is invalid
> fixed the problem.
Acked-by: Martin KaFai Lau <kafai@fb.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] bpf: fix a libbpf loader issue
2018-11-21 19:22 [PATCH bpf-next] bpf: fix a libbpf loader issue Yonghong Song
2018-11-21 20:02 ` Martin Lau
@ 2018-11-21 21:23 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2018-11-21 21:23 UTC (permalink / raw)
To: Yonghong Song, ast, netdev; +Cc: kernel-team
On 11/21/2018 08:22 PM, Yonghong Song wrote:
> Commit 2993e0515bb4 ("tools/bpf: add support to read .BTF.ext sections")
> added support to read .BTF.ext sections from an object file, create
> and pass prog_btf_fd and func_info to the kernel.
>
> The program btf_fd (prog->btf_fd) is initialized to be -1 to please
> zclose so we do not need special handling dur prog close.
> Passing -1 to the kernel, however, will cause loading error.
> Passing btf_fd 0 to the kernel if prog->btf_fd is invalid
> fixed the problem.
>
> Fixes: 2993e0515bb4 ("tools/bpf: add support to read .BTF.ext sections")
> Reported-by: Andrey Ignatov <rdna@fb.com>
> Reported-by: Emre Cantimur <haydum@fb.com>
> Tested-by: Andrey Ignatov <rdna@fb.com>
> Signed-off-by: Yonghong Song <yhs@fb.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-22 7:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-21 19:22 [PATCH bpf-next] bpf: fix a libbpf loader issue Yonghong Song
2018-11-21 20:02 ` Martin Lau
2018-11-21 21:23 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox