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, 8 Jun 2022 07:04:28 -0600
From:   James Hilliard <james.hilliard1@...il.com>
To:     Daniel Borkmann <daniel@...earbox.net>
Cc:     bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Björn Töpel <bjorn@...nel.org>,
        Magnus Karlsson <magnus.karlsson@...el.com>,
        Maciej Fijalkowski <maciej.fijalkowski@...el.com>,
        Jonathan Lemon <jonathan.lemon@...il.com>,
        "open list:BPF (Safe dynamic programs and tools)" 
        <netdev@...r.kernel.org>, open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/1] libbpf: replace typeof with __typeof__

On Wed, Jun 8, 2022 at 6:50 AM Daniel Borkmann <daniel@...earbox.net> wrote:
>
> Hi James,
>
> On 6/8/22 8:40 AM, James Hilliard wrote:
> > It seems the gcc preprocessor breaks when typeof is used with
> > macros.
> >
> > Fixes errors like:
> > error: expected identifier or '(' before '#pragma'
> >    106 | SEC("cgroup/bind6")
> >        | ^~~
> >
> > error: expected '=', ',', ';', 'asm' or '__attribute__' before '#pragma'
> >    114 | char _license[] SEC("license") = "GPL";
> >        | ^~~
> >
> > Signed-off-by: James Hilliard <james.hilliard1@...il.com>
> > ---
> > Changes v1 -> v2:
> >    - replace typeof with __typeof__ instead of changing pragma macros
> > ---
> >   tools/lib/bpf/bpf_core_read.h   | 16 ++++++++--------
> >   tools/lib/bpf/bpf_helpers.h     |  4 ++--
> >   tools/lib/bpf/bpf_tracing.h     | 24 ++++++++++++------------
> >   tools/lib/bpf/btf.h             |  4 ++--
> >   tools/lib/bpf/libbpf_internal.h |  6 +++---
> >   tools/lib/bpf/usdt.bpf.h        |  6 +++---
> >   tools/lib/bpf/xsk.h             | 12 ++++++------
> >   7 files changed, 36 insertions(+), 36 deletions(-)
> >
> > diff --git a/tools/lib/bpf/bpf_core_read.h b/tools/lib/bpf/bpf_core_read.h
> > index fd48b1ff59ca..d3a88721c9e7 100644
> > --- a/tools/lib/bpf/bpf_core_read.h
> > +++ b/tools/lib/bpf/bpf_core_read.h
> > @@ -111,7 +111,7 @@ enum bpf_enum_value_kind {
> >   })
> >
> >   #define ___bpf_field_ref1(field)    (field)
> > -#define ___bpf_field_ref2(type, field)       (((typeof(type) *)0)->field)
> > +#define ___bpf_field_ref2(type, field)       (((__typeof__(type) *)0)->field)
> >   #define ___bpf_field_ref(args...)                                       \
> >       ___bpf_apply(___bpf_field_ref, ___bpf_narg(args))(args)
> >
>
> Can't we just add the below?
>
> #ifndef typeof
> # define typeof __typeof__
> #endif

>From what I can tell it's not actually missing, but rather is
preprocessed differently
as the errors seem to be macro related.

I did also find this change which seems related:
https://github.com/torvalds/linux/commit/8faf7fc597d59b142af41ddd4a2d59485f75f88a

>
> Thanks,
> Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ