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, 13 Nov 2020 23:01:48 -0800
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Alan Maguire <alan.maguire@...cle.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@...omium.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>, Hao Luo <haoluo@...gle.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Quentin Monnet <quentin@...valent.com>,
        open list <linux-kernel@...r.kernel.org>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [RFC bpf-next 3/3] selftests/bpf: verify module-specific types
 can be shown via bpf_snprintf_btf

On Fri, Nov 13, 2020 at 10:11 AM Alan Maguire <alan.maguire@...cle.com> wrote:
>
> Verify that specifying a module name in "struct btf_ptr *" along
> with a type id of a module-specific type will succeed.
>
> veth_stats_rx() is chosen because its function signature consists
> of a module-specific type "struct veth_stats" and a kernel-specific
> one "struct net_device".
>
> Signed-off-by: Alan Maguire <alan.maguire@...cle.com>
> ---
>  .../selftests/bpf/prog_tests/snprintf_btf_mod.c    | 96 ++++++++++++++++++++++
>  tools/testing/selftests/bpf/progs/btf_ptr.h        |  1 +
>  tools/testing/selftests/bpf/progs/veth_stats_rx.c  | 73 ++++++++++++++++
>  3 files changed, 170 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/snprintf_btf_mod.c
>  create mode 100644 tools/testing/selftests/bpf/progs/veth_stats_rx.c
>

[...]

> +       err = veth_stats_rx__load(skel);
> +       if (CHECK(err, "skel_load", "failed to load skeleton: %d\n", err))
> +               goto cleanup;
> +
> +       bss = skel->bss;
> +
> +       bss->veth_stats_btf_id = btf__find_by_name(veth_btf, "veth_stats");

This is really awkward that this needs to be done from user-space.
Libbpf will be able to do this regardless of whether the type is in
vmlinux or kernel module. See my comments on patch #1.

> +
> +       if (CHECK(bss->veth_stats_btf_id <= 0, "find 'struct veth_stats'",
> +                 "could not find 'struct veth_stats' in veth BTF: %d",
> +                 bss->veth_stats_btf_id))
> +               goto cleanup;
> +

[...]

> +       btf_ids[0] = veth_stats_btf_id;
> +       ptrs[0] = (void *)PT_REGS_PARM1_CORE(ctx);
> +#if __has_builtin(__builtin_btf_type_id)

nit: there are a bunch of selftests that just assume we have this
built-in, so I don't think you need to guard it with #if here.

> +       btf_ids[1] = bpf_core_type_id_kernel(struct net_device);
> +       ptrs[1] = (void *)PT_REGS_PARM2_CORE(ctx);
> +#endif

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ