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: <CAEf4BzZhKOi9kX-49+qx0Tq1Gf+KGZLWuOmMx=i4D=m1vLx-Zg@mail.gmail.com>
Date:   Tue, 1 Dec 2020 17:23:46 -0800
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Florian Lehner <dev@...-flo.net>
Cc:     bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        john fastabend <john.fastabend@...il.com>,
        Krzesimir Nowak <krzesimir@...volk.io>
Subject: Re: [PATCH 2/2] selftests/bpf: Print reason when a tester could not
 run a program

On Sat, Nov 28, 2020 at 11:29 AM Florian Lehner <dev@...-flo.net> wrote:
>
> Print a message when the returned error is about a program type being
> not supported or because of permission problems.
> These messages are expected if the program to test was actually
> executed.
>
> Cc: Krzesimir Nowak <krzesimir@...volk.io>
> Signed-off-by: Florian Lehner <dev@...-flo.net>
> ---
>  tools/testing/selftests/bpf/test_verifier.c | 24 ++++++++++++++++-----
>  1 file changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
> index ceea9409639e..bd95894b7ea0 100644
> --- a/tools/testing/selftests/bpf/test_verifier.c
> +++ b/tools/testing/selftests/bpf/test_verifier.c
> @@ -875,19 +875,33 @@ static int do_prog_test_run(int fd_prog, bool unpriv, uint32_t expected_val,
>         __u8 tmp[TEST_DATA_LEN << 2];
>         __u32 size_tmp = sizeof(tmp);
>         uint32_t retval;
> -       int err;
> +       int err, saved_errno;
>
>         if (unpriv)
>                 set_admin(true);
>         err = bpf_prog_test_run(fd_prog, 1, data, size_data,
>                                 tmp, &size_tmp, &retval, NULL);
> +       saved_errno = errno;
> +
>         if (unpriv)
>                 set_admin(false);
> -       if (err && errno != 524/*ENOTSUPP*/ && errno != EPERM) {
> -               printf("Unexpected bpf_prog_test_run error ");
> -               return err;
> +
> +       if (err) {
> +               switch (errno) {

nit: stick to using saved_errno consistently, set_admin() does a lot
of things that can change errno

> +               case 524/*ENOTSUPP*/:
> +                       printf("Did not run the program (not supported) ");
> +                       return 0;
> +               case EPERM:
> +                       printf("Did not run the program (no permission) ");
> +                       return 0;

This should be ok to ignore *only* in unpriv mode, no?

> +               default:
> +                       printf("FAIL: Unexpected bpf_prog_test_run error (%s) ",
> +                               strerror(saved_errno));
> +                       return err;
> +               }
>         }
> -       if (!err && retval != expected_val &&
> +
> +       if (retval != expected_val &&
>             expected_val != POINTER_VALUE) {
>                 printf("FAIL retval %d != %d ", retval, expected_val);
>                 return 1;
> --
> 2.28.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ