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: <CAEf4BzazZ4esM0z5ZTM9PGfODfTtQB1AskPc1g139t5emUWb1Q@mail.gmail.com>
Date:   Tue, 5 May 2020 23:14:56 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Yonghong Song <yhs@...com>
Cc:     Andrii Nakryiko <andriin@...com>, bpf <bpf@...r.kernel.org>,
        Martin KaFai Lau <kafai@...com>,
        Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Kernel Team <kernel-team@...com>
Subject: Re: [PATCH bpf-next v2 19/20] tools/bpf: selftests: add iter progs
 for bpf_map/task/task_file

On Sun, May 3, 2020 at 11:27 PM Yonghong Song <yhs@...com> wrote:
>
> The implementation is arbitrary, just to show how the bpf programs
> can be written for bpf_map/task/task_file. They can be costomized
> for specific needs.
>
> For example, for bpf_map, the iterator prints out:
>   $ cat /sys/fs/bpf/my_bpf_map
>       id   refcnt  usercnt  locked_vm
>        3        2        0         20
>        6        2        0         20
>        9        2        0         20
>       12        2        0         20
>       13        2        0         20
>       16        2        0         20
>       19        2        0         20
>       === END ===
>
> For task, the iterator prints out:
>   $ cat /sys/fs/bpf/my_task
>     tgid      gid
>        1        1
>        2        2
>     ....
>     1944     1944
>     1948     1948
>     1949     1949
>     1953     1953
>     === END ===
>
> For task/file, the iterator prints out:
>   $ cat /sys/fs/bpf/my_task_file
>     tgid      gid       fd      file
>        1        1        0 ffffffff95c97600
>        1        1        1 ffffffff95c97600
>        1        1        2 ffffffff95c97600
>     ....
>     1895     1895      255 ffffffff95c8fe00
>     1932     1932        0 ffffffff95c8fe00
>     1932     1932        1 ffffffff95c8fe00
>     1932     1932        2 ffffffff95c8fe00
>     1932     1932        3 ffffffff95c185c0
>
> This is able to print out all open files (fd and file->f_op), so user can compare
> f_op against a particular kernel file operations to find what it is.
> For example, from /proc/kallsyms, we can find
>   ffffffff95c185c0 r eventfd_fops
> so we will know tgid 1932 fd 3 is an eventfd file descriptor.
>
> Signed-off-by: Yonghong Song <yhs@...com>
> ---

LGTM.

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

>  .../selftests/bpf/progs/bpf_iter_bpf_map.c    | 29 +++++++++++++++++++
>  .../selftests/bpf/progs/bpf_iter_task.c       | 26 +++++++++++++++++
>  .../selftests/bpf/progs/bpf_iter_task_file.c  | 27 +++++++++++++++++
>  3 files changed, 82 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_bpf_map.c
>  create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task.c
>  create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_file.c
>
> diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_bpf_map.c b/tools/testing/selftests/bpf/progs/bpf_iter_bpf_map.c
> new file mode 100644
> index 000000000000..d0af0e82b74c
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/bpf_iter_bpf_map.c
> @@ -0,0 +1,29 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2020 Facebook */
> +#include "vmlinux.h"
> +#include <bpf/bpf_helpers.h>
> +#include <bpf/bpf_tracing.h>
> +#include <bpf/bpf_endian.h>

bpf_endian.h doesn't seem to be really used and it's actually
incompatible with vmlinux.h, so maybe let's drop it?
Same for previous patch, I believe.

> +
> +char _license[] SEC("license") = "GPL";
> +

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ