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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190625200823.GB10487@mini-arch>
Date:   Tue, 25 Jun 2019 13:08:23 -0700
From:   Stanislav Fomichev <sdf@...ichev.me>
To:     Krzesimir Nowak <krzesimir@...volk.io>
Cc:     netdev@...r.kernel.org, Alban Crequy <alban@...volk.io>,
        Iago López Galeiras <iago@...volk.io>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
        Stanislav Fomichev <sdf@...gle.com>
Subject: Re: [bpf-next v2 03/10] selftests/bpf: Avoid another case of errno
 clobbering

On 06/25, Krzesimir Nowak wrote:
> Commit 8184d44c9a57 ("selftests/bpf: skip verifier tests for
> unsupported program types") added a check for an unsupported program
> type. The function doing it changes errno, so test_verifier should
> save it before calling it if test_verifier wants to print a reason why
> verifying a BPF program of a supported type failed.
> 
> Fixes: 8184d44c9a57 ("selftests/bpf: skip verifier tests for unsupported program types")
> Cc: Stanislav Fomichev <sdf@...gle.com>
> Signed-off-by: Krzesimir Nowak <krzesimir@...volk.io>
> ---
>  tools/testing/selftests/bpf/test_verifier.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
> index 12589da13487..779e30b96ded 100644
> --- a/tools/testing/selftests/bpf/test_verifier.c
> +++ b/tools/testing/selftests/bpf/test_verifier.c
> @@ -867,6 +867,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
>  	int fixup_skips;
>  	__u32 pflags;
>  	int i, err;
> +	int saved_errno;
Reverse Christmas tree. Otherwise LGTM.

>  
>  	for (i = 0; i < MAX_NR_MAPS; i++)
>  		map_fds[i] = -1;
> @@ -894,6 +895,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
>  		pflags |= BPF_F_ANY_ALIGNMENT;
>  	fd_prog = bpf_verify_program(prog_type, prog, prog_len, pflags,
>  				     "GPL", 0, bpf_vlog, sizeof(bpf_vlog), 4);
> +	saved_errno = errno;
>  	if (fd_prog < 0 && !bpf_probe_prog_type(prog_type, 0)) {
>  		printf("SKIP (unsupported program type %d)\n", prog_type);
>  		skips++;
> @@ -910,7 +912,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
>  	if (expected_ret == ACCEPT) {
>  		if (fd_prog < 0) {
>  			printf("FAIL\nFailed to load prog '%s'!\n",
> -			       strerror(errno));
> +			       strerror(saved_errno));
>  			goto fail_log;
>  		}
>  #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
> -- 
> 2.20.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ