All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liu Bo <bo.li.liu@oracle.com>
To: David Sterba <dsterba@suse.cz>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: fix off-by-one in lseek
Date: Tue, 8 Jan 2013 10:46:38 +0800	[thread overview]
Message-ID: <20130108024637.GA1916@liubo> (raw)
In-Reply-To: <20130107162050.GJ20089@twin.jikos.cz>

On Mon, Jan 07, 2013 at 05:20:50PM +0100, David Sterba wrote:
> On Mon, Jan 07, 2013 at 11:53:08AM +0800, Liu Bo wrote:
> > Lock end is inclusive.
> > 
> > Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> > ---
> >  fs/btrfs/file.c |    1 +
> >  1 files changed, 1 insertions(+), 0 deletions(-)
> > 
> > diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> > index 77061bf..1e16b6d 100644
> > --- a/fs/btrfs/file.c
> > +++ b/fs/btrfs/file.c
> > @@ -2241,6 +2241,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int whence)
> >  	if (lockend <= lockstart)
> >  		lockend = lockstart + root->sectorsize;
> >  
> > +	lockend--;
> >  	len = lockend - lockstart + 1;
> >  
> >  	len = max_t(u64, len, root->sectorsize);
> 
> Fix looks ok. I think this should be caught at runtime as well, the
> number of ways how the lock start and end are passed is not small and it
> need not be always possible to catch it from reading sources. The range
> is inclusive, so it's 'lock end % 2 == 1' right? (in the bit
> manipulating primitives).

Hmm, not always here, lockend = inode->i_size - 1, so lockend % 2 == 1 may not
be true.

But this check can worked in those places where we've rounded the range up to
PAGE_SIZE :)

thanks,
liubo

  reply	other threads:[~2013-01-08  2:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-07  3:53 [PATCH] Btrfs: fix off-by-one in lseek Liu Bo
2013-01-07 16:20 ` David Sterba
2013-01-08  2:46   ` Liu Bo [this message]
2013-01-08  8:30     ` David Sterba
2013-01-08 17:26       ` David Sterba
2013-01-09  4:34         ` Liu Bo
2013-01-09 11:50           ` David Sterba
2013-01-09 12:49             ` David Sterba
2013-01-10  2:17             ` Liu Bo
2013-01-10 11:04               ` David Sterba
2013-01-10 13:34                 ` Liu Bo
2013-01-11 15:25                   ` David Sterba
2013-01-11 17:49                     ` David Sterba
2013-04-30 14:28           ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130108024637.GA1916@liubo \
    --to=bo.li.liu@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.