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: <ced26fae338bb4bd28a16d44980bbd0517aaec10.camel@perches.com>
Date:   Sat, 17 Nov 2018 00:24:39 -0800
From:   Joe Perches <joe@...ches.com>
To:     Souptick Joarder <jrdr.linux@...il.com>
Cc:     Sabyasachi Gupta <sabyasachi.linux@...il.com>,
        benh@...nel.crashing.org, paulus@...ba.org, mpe@...erman.id.au,
        darren@...vens-zone.net, christophe.leroy@....fr,
        geoff@...radead.org, linuxppc-dev@...ts.ozlabs.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] arch/powerpc: Use dma_zalloc_coherent

On Sat, 2018-11-17 at 12:40 +0530, Souptick Joarder wrote:
> Hi Joe,

Hi back.

> On Fri, Nov 16, 2018 at 12:55 AM Joe Perches <joe@...ches.com> wrote:
> > On Thu, 2018-11-15 at 23:29 +0530, Sabyasachi Gupta wrote:
> > > On Mon, Nov 5, 2018 at 8:58 AM Sabyasachi Gupta
> > > <sabyasachi.linux@...il.com> wrote:
> > > > Replaced dma_alloc_coherent + memset with dma_zalloc_coherent
> > > > 
> > > > Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@...il.com>
> > > 
> > > Any comment on this patch?
> > 
> > It's obviously correct.
> > 
> > You might realign the arguments on the next lines
> > to the open parenthesis.
> > 
> > Perhaps there should be new function calls
> > added for symmetry to the other alloc functions
> > for multiplication overflow protection.
> > 
> > Perhaps:
> > 
> > void *dma_alloc_array_coherent()
> > void *dma_calloc_coherent()
> > 
> > Something like
> > ---
> >  include/linux/dma-mapping.h | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> > 
> > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > index 15bd41447025..95bebf8883b1 100644
> > --- a/include/linux/dma-mapping.h
> > +++ b/include/linux/dma-mapping.h
> > @@ -565,6 +565,25 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
> >                         (gfp & __GFP_NOWARN) ? DMA_ATTR_NO_WARN : 0);
> >  }
> > 
> > +static inline void *dma_alloc_array_coherent(struct device *dev,
> > +                                            size_t n, size_t size,
> > +                                            dma_addr_t *dma_handle, gfp_t gfp)
> > +{
> > +       size_t bytes;
> > +
> > +       if (unlikely(check_mul_overflow(n, size, &bytes)))
> > +               return NULL;
> > +       return dma_alloc_coherent(dev, bytes, dma_handle, gfp);
> > +}
> > +
> > +static inline void *dma_calloc_coherent(struct device *dev,
> > +                                       size_t n, size_t size,
> > +                                       dma_addr_t *dma_handle, gfp_t gfp)
> > +{
> > +       return dma_alloc_array_coherent(dev, n, size, dma_handle,
> > +                                       gfp | __GFP_ZERO);
> > +}
> > +
> 
> If I understood correctly, you are talking about adding these 2 new inline
> functions. We can do that.
> 
> Can you please help to understand the consumers of these 2 new inline ?

Any call to dma_alloc_coherent with a multiply
_might_overflow the multiplication.  The
check_mul_overflow simply avoids the overflow.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ