From: Daniel McNeil <daniel@osdl.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org, "linux-aio@kvack.org" <linux-aio@kvack.org>
Subject: [PATCH 2.6.3-rc2-mm1]
Date: 13 Feb 2004 13:04:03 -0800 [thread overview]
Message-ID: <1076706243.1956.26.camel@ibm-c.pdx.osdl.net> (raw)
In-Reply-To: <20040212015710.3b0dee67.akpm@osdl.org>
[-- Attachment #1: Type: text/plain, Size: 177 bytes --]
This patch samples i_size before dropping the i_sem.
The i_size could change by a racing write and we could
return uninitialized data.
re-diffed against 2.6.3-rc2-mm1.
Daniel
[-- Attachment #2: dio_size.2.6.3-rc2-mm1.patch --]
[-- Type: text/plain, Size: 1046 bytes --]
--- linux-2.6.3-rc2-mm1.orig/fs/direct-io.c 2004-02-12 11:35:41.613567579 -0800
+++ linux-2.6.3-rc2-mm1/fs/direct-io.c 2004-02-12 11:35:52.135706887 -0800
@@ -909,6 +909,7 @@ direct_io_worker(int rw, struct kiocb *i
int ret = 0;
int ret2;
size_t bytes;
+ loff_t i_size;
dio->bio = NULL;
dio->inode = inode;
@@ -1017,7 +1018,12 @@ direct_io_worker(int rw, struct kiocb *i
* All block lookups have been performed. For READ requests
* we can let i_sem go now that its achieved its purpose
* of protecting us from looking up uninitialized blocks.
+ *
+ * We also need sample i_size before we release i_sem to prevent
+ * a racing write from changing i_size causing us to return
+ * uninitialized data.
*/
+ i_size = i_size_read(inode);
if ((rw == READ) && dio->needs_locking)
up(&dio->inode->i_sem);
@@ -1064,7 +1070,6 @@ direct_io_worker(int rw, struct kiocb *i
if (ret == 0)
ret = dio->page_errors;
if (ret == 0 && dio->result) {
- loff_t i_size = i_size_read(inode);
ret = dio->result;
/*
next prev parent reply other threads:[~2004-02-13 21:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-12 9:57 2.6.3-rc2-mm1 Andrew Morton
2004-02-12 11:13 ` 2.6.3-rc2-mm1 Andrew Morton
2004-02-12 11:57 ` 2.6.3-rc2-mm1 Anton Blanchard
2004-02-12 12:09 ` 2.6.3-rc2-mm1 Andrew Morton
2004-02-12 14:40 ` 2.6.3-rc2-mm1 Zwane Mwaikambo
2004-02-12 14:46 ` 2.6.3-rc2-mm1 Anton Blanchard
2004-02-12 14:47 ` 2.6.3-rc2-mm1 Anton Blanchard
2004-02-12 11:24 ` 2.6.3-rc2-mm1 Nick Piggin
2004-02-12 14:46 ` 2.6.3-rc2-mm1 Zwane Mwaikambo
2004-02-12 15:40 ` 2.6.3-rc2-mm1 Mark Haverkamp
2004-02-12 21:38 ` 2.6.3-rc2-mm1 Andrew Morton
2004-02-12 22:33 ` 2.6.3-rc2-mm1 Nick Piggin
2004-02-12 17:06 ` 2.6.3-rc2-mm1 (compile stats) John Cherry
2004-02-12 18:43 ` 2.6.3-rc2-mm1 Alistair John Strachan
2004-02-13 0:04 ` 2.6.3-rc2-mm1 Torrey Hoffman
2004-02-14 10:36 ` 2.6.3-rc2-mm1 Terje Kvernes
2004-02-13 21:04 ` Daniel McNeil [this message]
2004-02-14 5:27 ` 2.6.3-rc2-mm1 Glenn Johnson
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=1076706243.1956.26.camel@ibm-c.pdx.osdl.net \
--to=daniel@osdl.org \
--cc=akpm@osdl.org \
--cc=linux-aio@kvack.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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