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: <202205100851.663310B@keescook>
Date:   Tue, 10 May 2022 08:51:34 -0700
From:   Kees Cook <keescook@...omium.org>
To:     Andreas Gruenbacher <agruenba@...hat.com>
Cc:     Christoph Hellwig <hch@...radead.org>,
        Bob Peterson <rpeterso@...hat.com>,
        kernel test robot <lkp@...el.com>,
        Bill Wendling <morbo@...gle.com>,
        cluster-devel <cluster-devel@...hat.com>,
        Nathan Chancellor <nathan@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Tom Rix <trix@...hat.com>,
        Steven Whitehouse <swhiteho@...hat.com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gfs2: Use container_of() for gfs2_glock(aspace)

On Tue, May 10, 2022 at 01:13:31PM +0200, Andreas Gruenbacher wrote:
> Kees and Christoph,
> 
> thanks for the patch and review.
> 
> On Tue, May 10, 2022 at 9:29 AM Christoph Hellwig <hch@...radead.org> wrote:
> > > +/* gfs2_glock_get(), "glock" must be first. */
> > > +struct glock_aspace {
> > > +     struct gfs2_glock       glock;
> > > +     struct address_space    mapping;
> > > +};
> >
> > Why does glock need to be first?  The whole point of using container_of
> > is that we don't have to make that assumption.
> 
> Just needs to be cleaned up in gfs2_glock_get() and
> gfs2_glock_dealloc() as well. I'll do that when applying the patch.
> 
> > >  static inline struct address_space *gfs2_glock2aspace(struct gfs2_glock *gl)
> > >  {
> > >       if (gl->gl_ops->go_flags & GLOF_ASPACE)
> > > -             return (struct address_space *)(gl + 1);
> > > +             return &(container_of(gl, struct glock_aspace, glock)->mapping);
> >
> > Do we even need the braces here?
> 
> Will use a local variable here, as suggested below.
> 
> > >       struct inode *inode = mapping->host;
> > >       if (mapping->a_ops == &gfs2_meta_aops)
> > > -             return (((struct gfs2_glock *)mapping) - 1)->gl_name.ln_sbd;
> > > +             return container_of(mapping, struct glock_aspace, mapping)->glock.gl_name.ln_sbd;
> >
> > A local variable would be really nice for the reader here to decompose
> > this a bit:
> >
> >                 struct glock_aspace *a =
> >                         container_of(mapping, struct glock_aspace, mapping);
> >
> >                 return a->glock.gl_name.ln_sbd;
> 
> Yes.

Thanks! So I should leave this with you to arrange, or should I send an
updated patch?

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ