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]
Date:   Mon, 30 Nov 2020 16:41:43 +0100
From:   Toke Høiland-Jørgensen <toke@...hat.com>
To:     daniel@...earbox.net, ast@...com, andrii@...nel.org
Cc:     Toke Høiland-Jørgensen <toke@...hat.com>,
        bpf@...r.kernel.org, netdev@...r.kernel.org
Subject: [PATCH bpf] libbpf: reset errno after probing kernel features

The kernel feature probing results in 'errno' being set if the probing
fails (as is often the case). This can stick around and leak to the caller,
which can lead to confusion later. So let's make sure we always reset errno
after calling a probe function.

Fixes: 47b6cb4d0add ("libbpf: Make kernel feature probing lazy")
Signed-off-by: Toke Høiland-Jørgensen <toke@...hat.com>
---
 tools/lib/bpf/libbpf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 28baee7ba1ca..8d05132e1945 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -4021,6 +4021,8 @@ static bool kernel_supports(enum kern_feature_id feat_id)
 			pr_warn("Detection of kernel %s support failed: %d\n", feat->desc, ret);
 			WRITE_ONCE(feat->res, FEAT_MISSING);
 		}
+		/* reset errno after probing to prevent leaking it to caller */
+		errno = 0;
 	}
 
 	return READ_ONCE(feat->res) == FEAT_SUPPORTED;
-- 
2.29.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ