From: "Paolo 'Blaisorblade' Giarrusso" <blaisorblade@yahoo.it>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Jeff Dike <jdike@addtoit.com>,
linux-kernel@vger.kernel.org,
user-mode-linux-devel@lists.sourceforge.net
Subject: [PATCH 3/5] uml: hostfs - fix possible PAGE_CACHE_SHIFT overflows
Date: Thu, 29 Dec 2005 17:39:57 +0100 [thread overview]
Message-ID: <20051229163956.4985.92278.stgit@zion.home.lan> (raw)
In-Reply-To: <20051229163803.4985.66742.stgit@zion.home.lan>
From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Prevent page->index << PAGE_CACHE_SHIFT from overflowing.
There is a casting there, but was added without care, so it's at the wrong
place. Note the extra parens around the shift - "+" is higher precedence than
"<<", leading to a GCC warning which saved all us.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---
fs/hostfs/hostfs_kern.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 3aac164..b3ad0bd 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -501,11 +501,16 @@ int hostfs_commit_write(struct file *fil
long long start;
int err = 0;
- start = (long long) (page->index << PAGE_CACHE_SHIFT) + from;
+ start = (((long long) page->index) << PAGE_CACHE_SHIFT) + from;
buffer = kmap(page);
err = write_file(FILE_HOSTFS_I(file)->fd, &start, buffer + from,
to - from);
if(err > 0) err = 0;
+
+ /* Actually, if !err, write_file has added to-from to start, so, despite
+ * the appearance, we are comparing i_size against the _last_ written
+ * location, as we should. */
+
if(!err && (start > inode->i_size))
inode->i_size = start;
next prev parent reply other threads:[~2005-12-29 16:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-29 16:38 [PATCH 0/5] UML: last patches for 2.6.15 Paolo 'Blaisorblade' Giarrusso
2005-12-29 16:39 ` [PATCH 1/5] uml: fix random segfaults at bootup Paolo 'Blaisorblade' Giarrusso
2005-12-29 16:39 ` [PATCH 2/5] Hostfs: remove unused var Paolo 'Blaisorblade' Giarrusso
2005-12-29 16:39 ` Paolo 'Blaisorblade' Giarrusso [this message]
2005-12-29 16:39 ` [PATCH 4/5] Hostfs: update for new glibc - add missing symbol exports Paolo 'Blaisorblade' Giarrusso
2005-12-29 16:40 ` [PATCH 5/5] uml: fix compilation with CONFIG_MODE_TT disabled Paolo 'Blaisorblade' Giarrusso
2005-12-29 20:25 ` [uml-devel] [PATCH 0/5] UML: last patches for 2.6.15 Jeff Dike
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=20051229163956.4985.92278.stgit@zion.home.lan \
--to=blaisorblade@yahoo.it \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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
all inboxes | Powered by JetHome®