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: <CAP01T753gZgg2501YR9rhCTCiHAf-zUe3USPqptAV43RWzJCVg@mail.gmail.com>
Date:   Wed, 20 Jul 2022 20:42:54 +0200
From:   Kumar Kartikeya Dwivedi <memxor@...il.com>
To:     Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc:     bpf@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
        Andrii Nakryiko <andrii@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Pablo Neira Ayuso <pablo@...filter.org>,
        Florian Westphal <fw@...len.de>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        Lorenzo Bianconi <lorenzo@...nel.org>, netdev@...r.kernel.org,
        netfilter-devel@...r.kernel.org
Subject: Re: [PATCH bpf-next v6 01/13] bpf: Introduce BTF ID flags and 8-byte
 BTF set

On Tue, 19 Jul 2022 at 20:37, Alexei Starovoitov
<alexei.starovoitov@...il.com> wrote:
>
> On Tue, Jul 19, 2022 at 03:24:18PM +0200, Kumar Kartikeya Dwivedi wrote:
> >
> > +#define ____BTF_ID_FLAGS_LIST(_0, _1, _2, _3, _4, _5, N, ...) _1##_##_2##_##_3##_##_4##_##_5##__
> > +#define __BTF_ID_FLAGS_LIST(...) ____BTF_ID_FLAGS_LIST(0x0, ##__VA_ARGS__, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
> > +
> > +#define __FLAGS(prefix, ...) \
> > +     __PASTE(prefix, __BTF_ID_FLAGS_LIST(__VA_ARGS__))
> > +
> > +#define BTF_ID_FLAGS(prefix, name, ...) \
> > +     BTF_ID(prefix, name)            \
> > +     __BTF_ID(__ID(__FLAGS(__BTF_ID__flags__, ##__VA_ARGS__)))
> > +
> >  /*
> >   * The BTF_ID_LIST macro defines pure (unsorted) list
> >   * of BTF IDs, with following layout:
> > @@ -145,10 +164,53 @@ asm(                                                    \
> >  ".popsection;                                 \n");  \
> >  extern struct btf_id_set name;
> >
> > +/*
> > + * The BTF_SET8_START/END macros pair defines sorted list of
> > + * BTF IDs and their flags plus its members count, with the
> > + * following layout:
> > + *
> > + * BTF_SET8_START(list)
> > + * BTF_ID_FLAGS(type1, name1, flags...)
> > + * BTF_ID_FLAGS(type2, name2, flags...)
> > + * BTF_SET8_END(list)
> > + *
> > + * __BTF_ID__set8__list:
> > + * .zero 8
> > + * list:
> > + * __BTF_ID__type1__name1__3:
> > + * .zero 4
> > + * __BTF_ID__flags__0x0_0x0_0x0_0x0_0x0__4:
> > + * .zero 4
>
> Overall looks great,
> but why encode flags into a name?
> Why reuse ____BTF_ID for flags and complicate resolve_btfid?
> Instead of .zero 4 insert the actual flags as .word ?
>
> The usage will be slightly different.
> Instead of:
> BTF_ID_FLAGS(func, bpf_get_task_pid, KF_ACQUIRE, KF_RET_NULL)
> it will be
> BTF_ID_FLAGS(func, bpf_get_task_pid, KF_ACQUIRE | KF_RET_NULL)

Nice, I didn't know you could do complex expressions like this for asm
directives like .word, but it makes sense now. TIL. I'm not very well
versed with GNU as. I will rework this and drop the resolve_btfids
changes for flags. Thanks a lot!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ