linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: mnipxh <mnipxh@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Yanmin Zhang <yanmin_zhang@linux.intel.com>,
	shuox.liu@intel.com
Subject: Re: [PATCH] fs/buffer.c: grow_buffers: fix the uncorrect check
Date: Sat, 31 May 2014 12:39:34 -0700	[thread overview]
Message-ID: <CA+55aFzfrGYCeUgXkeVowfJY+CL6MFPo7LpWSGiZvKhGA_qroQ@mail.gmail.com> (raw)
In-Reply-To: <538A1B75.5030107@gmail.com>

On Sat, May 31, 2014 at 11:12 AM, mnipxh <mnipxh@gmail.com> wrote:
> When pgoff_t index is 32bit, sector_t block is 64bit, need check if block number is too big.
> If block is bigger than (4Gb * PAGE_SIZE), index becomes a wrong value.
> Commit e5657933863f43cc6bb76a54d659303dafaa9e58 wants to do this. But it gives an uncorrect check.
> I think block != index << sizebits is correct. And it can detect such issue above.

I don't understand why you think the current check is incorrect.

It is testing that the calculation hasn't overflowed. It is correct.
It *should* use the same calculation, to (a) make it more obvious that
it's double-checking the earlier calculation in a different type, and
(b) to make it easier for the compiler to optimize it away if sector_t
and pgoff_t are the same size.

So the current code is correct, afaik. Note that "index" is "pgoff_t",
but "block >> sizebits" is "sector_t".

               Linus

      reply	other threads:[~2014-05-31 19:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-31 18:12 [PATCH] fs/buffer.c: grow_buffers: fix the uncorrect check mnipxh
2014-05-31 19:39 ` Linus Torvalds [this message]

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=CA+55aFzfrGYCeUgXkeVowfJY+CL6MFPo7LpWSGiZvKhGA_qroQ@mail.gmail.com \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mnipxh@gmail.com \
    --cc=shuox.liu@intel.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yanmin_zhang@linux.intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).