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]
Date:   Mon, 25 Jun 2018 21:07:05 +0000
From:   Long Li <longli@...rosoft.com>
To:     Tom Talpey <tom@...pey.com>, Steve French <sfrench@...ba.org>,
        "linux-cifs@...r.kernel.org" <linux-cifs@...r.kernel.org>,
        "samba-technical@...ts.samba.org" <samba-technical@...ts.samba.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>
Subject: RE: [Patch v2 05/15] CIFS: Calculate the correct request length based
 on page offset and tail size

> Subject: Re: [Patch v2 05/15] CIFS: Calculate the correct request length based
> on page offset and tail size
> 
> On 5/30/2018 3:47 PM, Long Li wrote:
> > From: Long Li <longli@...rosoft.com>
> >
> > It's possible that the page offset is non-zero in the pages in a
> > request, change the function to calculate the correct data buffer length.
> >
> > Signed-off-by: Long Li <longli@...rosoft.com>
> > ---
> >   fs/cifs/transport.c | 20 +++++++++++++++++---
> >   1 file changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index
> > 927226a..d6b5523 100644
> > --- a/fs/cifs/transport.c
> > +++ b/fs/cifs/transport.c
> > @@ -212,10 +212,24 @@ rqst_len(struct smb_rqst *rqst)
> >   	for (i = 0; i < rqst->rq_nvec; i++)
> >   		buflen += iov[i].iov_len;
> >
> > -	/* add in the page array if there is one */
> > +	/*
> > +	 * Add in the page array if there is one. The caller needs to make
> > +	 * sure rq_offset and rq_tailsz are set correctly. If a buffer of
> > +	 * multiple pages ends at page boundary, rq_tailsz needs to be set to
> > +	 * PAGE_SIZE.
> > +	 */
> >   	if (rqst->rq_npages) {
> > -		buflen += rqst->rq_pagesz * (rqst->rq_npages - 1);
> > -		buflen += rqst->rq_tailsz;
> > +		if (rqst->rq_npages == 1)
> > +			buflen += rqst->rq_tailsz;
> > +		else {
> > +			/*
> > +			 * If there is more than one page, calculate the
> > +			 * buffer length based on rq_offset and rq_tailsz
> > +			 */
> > +			buflen += rqst->rq_pagesz * (rqst->rq_npages - 1) -
> > +					rqst->rq_offset;
> > +			buflen += rqst->rq_tailsz;
> > +		}
> 
> Wouldn't it be simpler to keep the original code, but then just subtract the
> rq_offset?
> 
> 	buflen += rqst->rq_pagesz * (rqst->rq_npages - 1);
> 	buflen += rqst->rq_tailsz;
> 	buflen -= rqst->rq_offset;
> 
> It's kind of confusing as written. Also, what if it's just one page, but has a
> non-zero offset? Is that somehow not possible? My suggested code would
> take that into account, yours doesn't.

I think It can be changed to this:

	buflen += rqst->rq_pagesz * (rqst->rq_npages - 1);
 	buflen += rqst->rq_tailsz;
	if (rqst->rq_npages > 1)
 		buflen -= rqst->rq_offset;

This looks cleaner than before.

When there is only one page with a non-zero offset, rq_tailsz is the actual data length.

> 
> Tom.
> 
> >   	}
> >
> >   	return buflen;
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ