From: Pedro Tammela <pctammela@gmail.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Pedro Tammela <pctammela@mojatatu.com>
Subject: [PATCH bpf-next] libbpf: handle ENOTSUPP errno in libbpf_strerror()
Date: Sat, 24 Apr 2021 19:16:48 -0300 [thread overview]
Message-ID: <20210424221648.809525-1-pctammela@mojatatu.com> (raw)
The 'bpf()' syscall is leaking the ENOTSUPP errno that is internal to the kernel[1].
More recent code is already using the correct EOPNOTSUPP, but changing
older return codes is not possible due to dependency concerns, so handle ENOTSUPP
in libbpf_strerror().
[1] https://lore.kernel.org/netdev/20200511165319.2251678-1-kuba@kernel.org/
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
---
tools/lib/bpf/libbpf_errno.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/lib/bpf/libbpf_errno.c b/tools/lib/bpf/libbpf_errno.c
index 0afb51f7a919..7de8bbc34a37 100644
--- a/tools/lib/bpf/libbpf_errno.c
+++ b/tools/lib/bpf/libbpf_errno.c
@@ -13,6 +13,9 @@
#include "libbpf.h"
+/* This errno is internal to the kernel but leaks in the bpf() syscall. */
+#define ENOTSUPP 524
+
/* make sure libbpf doesn't use kernel-only integer typedefs */
#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
@@ -43,6 +46,12 @@ int libbpf_strerror(int err, char *buf, size_t size)
err = err > 0 ? err : -err;
+ if (err == ENOTSUPP) {
+ snprintf(buf, size, "Operation not supported");
+ buf[size - 1] = '\0';
+ return 0;
+ }
+
if (err < __LIBBPF_ERRNO__START) {
int ret;
--
2.25.1
next reply other threads:[~2021-04-24 22:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-24 22:16 Pedro Tammela [this message]
2021-04-27 16:18 ` [PATCH bpf-next] libbpf: handle ENOTSUPP errno in libbpf_strerror() Daniel Borkmann
2021-04-30 14:16 ` Pedro Tammela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210424221648.809525-1-pctammela@mojatatu.com \
--to=pctammela@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pctammela@mojatatu.com \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).