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: <CAEf4BzaO_m-OQVAuOkMsRC=ePWa95-V8ZpT1C9kWRzrnWZugJQ@mail.gmail.com>
Date:   Thu, 9 Apr 2020 11:12:06 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Yoshiki Komachi <komachi.yoshiki@...il.com>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        Andrii Nakryiko <andriin@...com>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH] libbpf: Make bpf/bpf_helpers.h self-contained

On Wed, Apr 8, 2020 at 10:31 PM Yoshiki Komachi
<komachi.yoshiki@...il.com> wrote:
>
> 2020年4月7日(火) 15:52 Andrii Nakryiko <andrii.nakryiko@...il.com>:
> >
> > On Mon, Apr 6, 2020 at 11:29 PM Yoshiki Komachi
> > <komachi.yoshiki@...il.com> wrote:
> > >
> > > I tried to compile a bpf program including bpf_helpers.h, however it
> > > resulted in failure as below:
> > >
> > >   # clang -I./linux/tools/lib/ -I/lib/modules/$(uname -r)/build/include/ \
> > >     -O2 -Wall -target bpf -emit-llvm -c bpf_prog.c -o bpf_prog.bc
> > >   ...
> > >   In file included from linux/tools/lib/bpf/bpf_helpers.h:5:
> > >   linux/tools/lib/bpf/bpf_helper_defs.h:56:82: error: unknown type name '__u64'
> > >   ...
> > >
> > > This is because bpf_helpers.h depends on linux/types.h and it is not
> > > self-contained. This has been like this long time, but since bpf_helpers.h
> > > was moved from selftests private file to libbpf header file, IMO it
> > > should include linux/types.h by itself.
> > >
> > > Fixes: e01a75c15969 ("libbpf: Move bpf_{helpers, helper_defs, endian, tracing}.h into libbpf")
> > > Signed-off-by: Yoshiki Komachi <komachi.yoshiki@...il.com>
> > > ---
> > >  tools/lib/bpf/bpf_helpers.h | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h
> > > index f69cc208778a..d9288e695eb1 100644
> > > --- a/tools/lib/bpf/bpf_helpers.h
> > > +++ b/tools/lib/bpf/bpf_helpers.h
> > > @@ -2,6 +2,7 @@
> > >  #ifndef __BPF_HELPERS__
> > >  #define __BPF_HELPERS__
> > >
> > > +#include <linux/types.h>
> > >  #include "bpf_helper_defs.h"
> >
> > It's actually intentional, so that bpf_helpers.h can be used together
> > with auto-generated (from BTF) vmlinux.h (which will have all the
> > __u64 and other typedefs).
>
> Thanks for kind comments, and I found out that it’s not wrong but intentional.
>
> However users (like me) may not be aware of it at this point, because
> there is no related statement as far as I know. Instead of my previous
> proposal, we should add some comments (e.g., this header needs to
> include either auto-generated (from BTF) vmlinux.h or linux/types.h
> before using) to bpf_helpers.h header, IMO.

Right, documenting various things like this is a sore point with BPF
usage right now. Feel free to send a patch with such comment. Thanks!

>
> > >
> > >  #define __uint(name, val) int (*name)[val]
> > > --
> > > 2.24.1
> > >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ