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] [day] [month] [year] [list]
Message-ID: <CAMZfGtVdCzaALfW=SSgKCV5-_+HU-7sf7RWJQuO=77STWOwjUA@mail.gmail.com>
Date:   Tue, 18 May 2021 16:43:11 +0800
From:   Muchun Song <songmuchun@...edance.com>
To:     wenhuizhang <wenhui@...ail.gwu.edu>
Cc:     Michal Hocko <mhocko@...e.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Shakeel Butt <shakeelb@...gle.com>,
        Johannes Weiner <hannes@...xchg.org>,
        Roman Gushchin <guro@...com>, Yang Shi <shy828301@...il.com>,
        Alex Shi <alexs@...nel.org>,
        Wei Yang <richard.weiyang@...il.com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [External] Re: [PATCH] memcontrol: use flexible-array member

On Tue, May 18, 2021 at 4:08 PM Michal Hocko <mhocko@...e.com> wrote:
>
> On Tue 18-05-21 01:20:36, wenhuizhang wrote:
> >
> > Change depracated zero-length-and-one-element-arrays into flexible
> > array member.
> > Zero-length and one-element arrays detected by Lukas's CodeChecker.
> > Zero/one element arrays causes undefined behaviours if sizeof() used.
> >
> > https://www.kernel.org/doc/html/latest/processd/deprecated.html
>
> I do understand why zero-length structures are discouraged for trail
> space but does the same concern apply to internal padding inside
> structures to enforce alignment to different cache lines? AFAIK this is
> a trick we use at other places and I do not remember having heard about
> any problems.
>
> nodeinfo is a different case where flexible arrays seems reasonable to
> me.

I do agree with Michal's suggestion. If you only change nodeinfo
to a flexible array in the next version. Please also remove the
comment below it.

>
> > Signed-off-by: wenhuizhang<wenhui@...ail.gwu.edu>
> > ---
> >  include/linux/memcontrol.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> > index 0ce97eff79e2..f879efb1bc6e 100644
> > --- a/include/linux/memcontrol.h
> > +++ b/include/linux/memcontrol.h
> > @@ -190,7 +190,7 @@ enum memcg_kmem_state {
> >
> >  #if defined(CONFIG_SMP)
> >  struct memcg_padding {
> > -     char x[0];
> > +     char x[];
> >  } ____cacheline_internodealigned_in_smp;
> >  #define MEMCG_PADDING(name)      struct memcg_padding name;
> >  #else
> > @@ -349,7 +349,7 @@ struct mem_cgroup {
> >       struct deferred_split deferred_split_queue;
> >  #endif
> >
> > -     struct mem_cgroup_per_node *nodeinfo[0];
> > +     struct mem_cgroup_per_node *nodeinfo[];
> >       /* WARNING: nodeinfo must be the last member here */

I mean this comment. Because the compiler will help us to
check this if we convert it to a flexible array.

Thanks.

> >  };
> >
> > --
> > 2.17.1
>
> --
> Michal Hocko
> SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ