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: <20210121115141.GA472545@pek-khao-d2.corp.ad.wrs.com>
Date:   Thu, 21 Jan 2021 19:51:41 +0800
From:   Kevin Hao <haokexin@...il.com>
To:     David Laight <David.Laight@...lab.com>
Cc:     "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Subbaraya Sundeep <sbhatta@...vell.com>,
        Sunil Goutham <sgoutham@...vell.com>,
        Geetha sowjanya <gakula@...vell.com>,
        hariprasad <hkelam@...vell.com>
Subject: Re: [PATCH] net: octeontx2: Make sure the buffer is 128 byte aligned

On Thu, Jan 21, 2021 at 09:53:08AM +0000, David Laight wrote:
> From: Kevin Hao
> > Sent: 21 January 2021 07:09
> > 
> > The octeontx2 hardware needs the buffer to be 128 byte aligned.
> > But in the current implementation of napi_alloc_frag(), it can't
> > guarantee the return address is 128 byte aligned even the request size
> > is a multiple of 128 bytes, so we have to request an extra 128 bytes and
> > use the PTR_ALIGN() to make sure that the buffer is aligned correctly.
> > 
> > Fixes: 7a36e4918e30 ("octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers")
> > Reported-by: Subbaraya Sundeep <sbhatta@...vell.com>
> > Signed-off-by: Kevin Hao <haokexin@...il.com>
> > ---
> >  drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > index bdfa2e293531..5ddedc3b754d 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > @@ -488,10 +488,11 @@ dma_addr_t __otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool)
> >  	dma_addr_t iova;
> >  	u8 *buf;
> > 
> > -	buf = napi_alloc_frag(pool->rbsize);
> > +	buf = napi_alloc_frag(pool->rbsize + OTX2_ALIGN);
> >  	if (unlikely(!buf))
> >  		return -ENOMEM;
> > 
> > +	buf = PTR_ALIGN(buf, OTX2_ALIGN);
> >  	iova = dma_map_single_attrs(pfvf->dev, buf, pool->rbsize,
> >  				    DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC);
> >  	if (unlikely(dma_mapping_error(pfvf->dev, iova))) {
> > --
> > 2.29.2
> 
> Doesn't that break the 'free' code ?
> Surely it needs the original pointer.

Why do we care about the original pointer? The free code should work with
the mangling poiner. Did I miss something?

> 
> It isn't obvious that page_frag_free() it correct when the
> allocator is napi_alloc_frag() either.
> I'd have thought it ought to be returned to the pool.

Sorry, I didn't get what you mean. Could you elaborate a bit more?

Thanks,
Kevin

> 
> 	David
> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
> 

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ