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:   Wed, 4 Mar 2020 07:34:53 -0800
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Daniel Borkmann <daniel@...earbox.net>
Cc:     Andrii Nakryiko <andriin@...com>, bpf <bpf@...r.kernel.org>,
        Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        Kernel Team <kernel-team@...com>
Subject: Re: [PATCH v3 bpf-next 0/3] Convert BPF UAPI constants into enum values

On Wed, Mar 4, 2020 at 7:21 AM Daniel Borkmann <daniel@...earbox.net> wrote:
>
> On 3/3/20 1:32 AM, Andrii Nakryiko wrote:
> > Convert BPF-related UAPI constants, currently defined as #define macro, into
> > anonymous enums. This has no difference in terms of usage of such constants in
> > C code (they are still could be used in all the compile-time contexts that
> > `#define`s can), but they are recorded as part of DWARF type info, and
> > subsequently get recorded as part of kernel's BTF type info. This allows those
> > constants to be emitted as part of vmlinux.h auto-generated header file and be
> > used from BPF programs. Which is especially convenient for all kinds of BPF
> > helper flags and makes CO-RE BPF programs nicer to write.
> >
> > libbpf's btf_dump logic currently assumes enum values are signed 32-bit
> > values, but that doesn't match a typical case, so switch it to emit unsigned
> > values. Once BTF encoding of BTF_KIND_ENUM is extended to capture signedness
> > properly, this will be made more flexible.
> >
> > As an immediate validation of the approach, runqslower's copy of
> > BPF_F_CURRENT_CPU #define is dropped in favor of its enum variant from
> > vmlinux.h.
> >
> > v2->v3:
> > - convert only constants usable from BPF programs (BPF helper flags, map
> >    create flags, etc) (Alexei);
> >
> > v1->v2:
> > - fix up btf_dump test to use max 32-bit unsigned value instead of negative one.
> >
> >
> > Andrii Nakryiko (3):
> >    bpf: switch BPF UAPI #define constants used from BPF program side to
> >      enums
> >    libbpf: assume unsigned values for BTF_KIND_ENUM
> >    tools/runqslower: drop copy/pasted BPF_F_CURRENT_CPU definiton
> >
> >   include/uapi/linux/bpf.h                      | 175 ++++++++++-------
> >   tools/bpf/runqslower/runqslower.bpf.c         |   3 -
> >   tools/include/uapi/linux/bpf.h                | 177 +++++++++++-------
> >   tools/lib/bpf/btf_dump.c                      |   8 +-
> >   .../bpf/progs/btf_dump_test_case_syntax.c     |   2 +-
> >   5 files changed, 224 insertions(+), 141 deletions(-)
> >
>
> Applied, thanks!

Great, thanks! This is a huge usability boost for BPF programs relying
on vmlinux.h!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ