* [PATCH bpf-next] libbpf: Fix unintentional success return code in bpf_object__load
@ 2020-08-26 7:55 Alex Gartrell
2020-08-26 22:17 ` Alexei Starovoitov
0 siblings, 1 reply; 2+ messages in thread
From: Alex Gartrell @ 2020-08-26 7:55 UTC (permalink / raw)
To: netdev, bpf, ast, daniel; +Cc: kernel-team, Alex Gartrell
There are code paths where EINVAL is returned directly without setting
errno. In that case, errno could be 0, which would mask the
failure. For example, if a careless programmer set log_level to 10000
out of laziness, they would have to spend a long time trying to figure
out why.
Fixes: 4f33ddb4e3e2 ("libbpf: Propagate EPERM to caller on program load")
Signed-off-by: Alex Gartrell <alexgartrell@gmail.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 2e2523d8bb6d..8f9e7d281225 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -6067,7 +6067,7 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
free(log_buf);
goto retry_load;
}
- ret = -errno;
+ ret = errno ? -errno : -LIBBPF_ERRNO__LOAD;
cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
pr_warn("load bpf program failed: %s\n", cp);
pr_perm_msg(ret);
--
2.26.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next] libbpf: Fix unintentional success return code in bpf_object__load
2020-08-26 7:55 [PATCH bpf-next] libbpf: Fix unintentional success return code in bpf_object__load Alex Gartrell
@ 2020-08-26 22:17 ` Alexei Starovoitov
0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2020-08-26 22:17 UTC (permalink / raw)
To: Alex Gartrell
Cc: Network Development, bpf, Alexei Starovoitov, Daniel Borkmann,
Kernel Team
On Wed, Aug 26, 2020 at 12:56 AM Alex Gartrell <alexgartrell@gmail.com> wrote:
>
> There are code paths where EINVAL is returned directly without setting
> errno. In that case, errno could be 0, which would mask the
> failure. For example, if a careless programmer set log_level to 10000
> out of laziness, they would have to spend a long time trying to figure
> out why.
>
> Fixes: 4f33ddb4e3e2 ("libbpf: Propagate EPERM to caller on program load")
> Signed-off-by: Alex Gartrell <alexgartrell@gmail.com>
Applied. Thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-26 22:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 7:55 [PATCH bpf-next] libbpf: Fix unintentional success return code in bpf_object__load Alex Gartrell
2020-08-26 22:17 ` Alexei Starovoitov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).