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]
Date:   Fri, 23 Jul 2021 17:23:07 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Johan Almbladh <johan.almbladh@...finetworks.com>
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>, Martin Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        john fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Tony Ambardar <Tony.Ambardar@...il.com>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH] bpf/tests: do not PASS tests without actually testing the result

On Wed, Jul 21, 2021 at 3:39 AM Johan Almbladh
<johan.almbladh@...finetworks.com> wrote:
>
> Each test case can have a set of sub-tests, where each sub-test can
> run the cBPF/eBPF test snippet with its own data_size and expected
> result. Before, the end of the sub-test array was indicated by both
> data_size and result being zero. However, most or all of the internal
> eBPF tests has a data_size of zero already. When such a test also had
> an expected value of zero, the test was never run but reported as
> PASS anyway.
>
> Now the test runner always runs the first sub-test, regardless of the
> data_size and result values. The sub-test array zero-termination only
> applies for any additional sub-tests.
>
> There are other ways fix it of course, but this solution at least
> removes the surprise of eBPF tests with a zero result always succeeding.
>
> Signed-off-by: Johan Almbladh <johan.almbladh@...finetworks.com>
> ---
>  lib/test_bpf.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/lib/test_bpf.c b/lib/test_bpf.c
> index d500320778c7..baff847a02da 100644
> --- a/lib/test_bpf.c
> +++ b/lib/test_bpf.c
> @@ -6659,7 +6659,14 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
>                 u64 duration;
>                 u32 ret;
>
> -               if (test->test[i].data_size == 0 &&
> +               /*
> +                * NOTE: Several sub-tests may be present, in which case
> +                * a zero {data_size, result} tuple indicates the end of
> +                * the sub-test array. The first test is always run,
> +                * even if both data_size and result happen to be zero.
> +                */
> +               if (i > 0 &&

This feels pretty arbitrary, of course, but I don't see how to improve
this easily without tons of code churn for each test specification.
Applied to bpf-next, thanks!

> +                   test->test[i].data_size == 0 &&
>                     test->test[i].result == 0)
>                         break;
>
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ