From: Anton Altaparmakov <aia21@cam.ac.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Hugh Dickins <hughd@google.com>, stable <stable@vger.kernel.org>
Subject: Re: [PATCH] Fix nasty 32-bit overflow bug in buffer i/o code.
Date: Mon, 22 Sep 2014 16:29:56 +0100 [thread overview]
Message-ID: <55E81CB2-AB4B-41E2-88D5-B33F7D8B1DB8@cam.ac.uk> (raw)
In-Reply-To: <CA+55aFyYpe=oyF9yVqF3E6t4ZCpHAdnLj1g36FWUDZydW9mdgQ@mail.gmail.com>
Hi Linus,
On 22 Sep 2014, at 16:18, Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Sun, Sep 21, 2014 at 5:53 PM, Anton Altaparmakov <aia21@cam.ac.uk> wrote:
>>
>> This patch fixes this issue by type casting "index" to sector_t before
>> doing the left shift.
>
> Ugh. Does the simpler patch to just pass in "block" work as well?
That doesn't work because nothing rounds down "block" to the first block in the page and init_page_buffers() requires "block" to be the first block in the page.
The shift right followed by shift left achieves the "rounding down" required.
You could do "block & ~(sector_t)(size - 1)" instead of "(sector_t)index << sizebits" if you prefer but not sure that is an improvement!
Best regards,
Anton
> Linus
> <patch.diff>
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
University of Cambridge Information Services, Roger Needham Building
7 JJ Thomson Avenue, Cambridge, CB3 0RB, UK
next prev parent reply other threads:[~2014-09-22 15:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-22 0:53 [PATCH] Fix nasty 32-bit overflow bug in buffer i/o code Anton Altaparmakov
2014-09-22 4:43 ` Hugh Dickins
2014-09-22 9:30 ` Anton Altaparmakov
2014-09-22 10:36 ` Hugh Dickins
2014-09-22 11:01 ` Anton Altaparmakov
2014-09-22 15:18 ` Linus Torvalds
2014-09-22 15:24 ` Linus Torvalds
2014-09-22 15:29 ` Anton Altaparmakov [this message]
2014-09-22 15:33 ` Linus Torvalds
2014-09-22 15:46 ` Anton Altaparmakov
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=55E81CB2-AB4B-41E2-88D5-B33F7D8B1DB8@cam.ac.uk \
--to=aia21@cam.ac.uk \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.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 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).