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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzZ4X67E7dxWA8sdiBpuyFfeWZ4yNAagQpwho+FncJv=GQ@mail.gmail.com>
Date:   Fri, 10 Jul 2020 13:55:10 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Alan Maguire <alan.maguire@...cle.com>
Cc:     Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andriin@...com>, Martin Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        john fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...omium.org>,
        open list <linux-kernel@...r.kernel.org>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH v2 bpf-next 2/2] selftests/bpf: add selftests verifying
 bpf_trace_printk() behaviour

On Fri, Jul 10, 2020 at 7:25 AM Alan Maguire <alan.maguire@...cle.com> wrote:
>
> Simple selftests that verifies bpf_trace_printk() returns a sensible
> value and tracing messages appear.
>
> Signed-off-by: Alan Maguire <alan.maguire@...cle.com>
> ---

see pedantic note below, but I don't think that's an issue in practice

Acked-by: Andrii Nakryiko <andriin@...com>

>  .../selftests/bpf/prog_tests/trace_printk.c        | 74 ++++++++++++++++++++++
>  tools/testing/selftests/bpf/progs/trace_printk.c   | 21 ++++++
>  2 files changed, 95 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/trace_printk.c
>  create mode 100644 tools/testing/selftests/bpf/progs/trace_printk.c
>

[...]

> +
> +       /* verify our search string is in the trace buffer */
> +       while (read(fd, buf, sizeof(buf)) >= 0 || errno == EAGAIN) {

There is a minor chance that "testing,testing" won't be found, if it
so happened that the first part is in the first read buffer, and the
second is in the second. I don't think it's ever the case for our CI
and for my local testing setup, but could be a cause of some
instability if there is something else emitting data to trace_pipe,
right?

Maybe line-based reading would be more reliable (unless printk can
intermix, not sure about that, in which case there is simply no way to
solve this 100% reliably).


> +               if (strstr(buf, SEARCHMSG) != NULL)
> +                       found++;
> +               if (found == bss->trace_printk_ran)
> +                       break;
> +               if (++iter > 1000)
> +                       break;
> +       }
> +
> +       if (CHECK(!found, "message from bpf_trace_printk not found",
> +                 "no instance of %s in %s", SEARCHMSG, TRACEBUF))
> +               goto cleanup;
> +
> +       printf("ran %d times; last return value %d, with %d instances of msg\n",
> +              bss->trace_printk_ran, bss->trace_printk_ret, found);

Is this needed or it's some debug leftover?

> +cleanup:
> +       trace_printk__destroy(skel);
> +       if (fd != -1)
> +               close(fd);
> +}

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ