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: <CANn89iJNbZq+HWGnWrKBc8ULE=HVK04VUs2TrvWYu5Ef1vy+yQ@mail.gmail.com>
Date: Wed, 20 Sep 2023 23:32:24 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: Jamal Hadi Salim <jhs@...atatu.com>
Cc: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>, 
	Paolo Abeni <pabeni@...hat.com>, Willem de Bruijn <willemb@...gle.com>, 
	Soheil Hassas Yeganeh <soheil@...gle.com>, Neal Cardwell <ncardwell@...gle.com>, 
	Cong Wang <xiyou.wangcong@...il.com>, Jiri Pirko <jiri@...nulli.us>, netdev@...r.kernel.org, 
	eric.dumazet@...il.com
Subject: Re: [PATCH v2 net-next 1/5] net_sched: constify qdisc_priv()

On Wed, Sep 20, 2023 at 10:45 PM Jamal Hadi Salim <jhs@...atatu.com> wrote:
>
> On Wed, Sep 20, 2023 at 4:17 PM Eric Dumazet <edumazet@...gle.com> wrote:
> >
> > In order to propagate const qualifiers, we change qdisc_priv()
> > to accept a possibly const argument.
> >
> > Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> > ---
> >  include/net/pkt_sched.h | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
> > index 15960564e0c364ef430f1e3fcdd0e835c2f94a77..9fa1d0794dfa5241705f9a39c896ed44519a9f13 100644
> > --- a/include/net/pkt_sched.h
> > +++ b/include/net/pkt_sched.h
> > @@ -20,10 +20,10 @@ struct qdisc_walker {
> >         int     (*fn)(struct Qdisc *, unsigned long cl, struct qdisc_walker *);
> >  };
> >
> > -static inline void *qdisc_priv(struct Qdisc *q)
> > -{
> > -       return &q->privdata;
> > -}
> > +#define qdisc_priv(q)                                                  \
> > +       _Generic(q,                                                     \
> > +                const struct Qdisc * : (const void *)&q->privdata,     \
> > +                struct Qdisc * : (void *)&q->privdata)
>
> Didnt know you could do this - C11? Would old compilers work here or
> do we have some standardization version around compiler versions?

We already use this in the tree, I would not worry for more instances
of _Generic()

commit 6ec4476ac82512f09c94aff5972654b70f3772b2
Author: Linus Torvalds <torvalds@...ux-foundation.org>
Date:   Wed Jul 8 10:48:35 2020 -0700

    Raise gcc version requirement to 4.9

    I realize that we fairly recently raised it to 4.8, but the fact is, 4.9
    is a much better minimum version to target.

    We have a number of workarounds for actual bugs in pre-4.9 gcc versions
    (including things like internal compiler errors on ARM), but we also
    have some syntactic workarounds for lacking features.

    In particular, raising the minimum to 4.9 means that we can now just
    assume _Generic() exists, which is likely the much better replacement
    for a lot of very convoluted built-time magic with conditionals on
    sizeof and/or __builtin_choose_expr() with same_type() etc.

    Using _Generic also means that you will need to have a very recent
    version of 'sparse', but thats easy to build yourself, and much less of
    a hassle than some old gcc version can be.

    The latest (in a long string) of reasons for minimum compiler version
    upgrades was commit 5435f73d5c4a ("efi/x86: Fix build with gcc 4").

    Ard points out that RHEL 7 uses gcc-4.8, but the people who stay back on
    old RHEL versions persumably also don't build their own kernels anyway.
    And maybe they should cross-built or just have a little side affair with
    a newer compiler?

    Acked-by: Ard Biesheuvel <ardb@...nel.org>
    Acked-by: Peter Zijlstra <peterz@...radead.org>
    Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ