lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210424221648.809525-1-pctammela@mojatatu.com>
Date:   Sat, 24 Apr 2021 19:16:48 -0300
From:   Pedro Tammela <pctammela@...il.com>
To:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>, netdev@...r.kernel.org,
        bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Pedro Tammela <pctammela@...atatu.com>
Subject: [PATCH bpf-next] libbpf: handle ENOTSUPP errno in libbpf_strerror()

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@...atatu.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ