lkml.org 
[lkml]   [2006]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 5/5] direct-io: fix double completion on partially valid async requests
Date
From
If a request which is valid in the first half but has the second half
unmapped, the current code issues the first half and returns issue
error. This causes both the caller and completion callback complete
the aio request thus either causing oops immediately or memory
corruption.

This path makes direct_io_worker() wait completion for such request
and return error without aio_complete()'ing it.

This bug has been spotted by Chul-Woong Yang.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Chul-Woong Yang <cwyang@aratech.co.kr>
---
fs/direct-io.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index c558aa6..316598b 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -956,19 +956,17 @@ direct_io_worker(int rw, struct kiocb *i
* If this request can be completed asynchronously, drop the
* extra reference and return.
*/
- if (!is_sync_kiocb(iocb) &&
+ if (!is_sync_kiocb(iocb) && ret == 0 &&
((rw == READ) || (dio->result == dio->size &&
offset + dio->size <= dio->i_size))) {
- if (ret == 0)
- ret = dio->result;
finished_one_bio(dio); /* This can free the dio */
- return ret;
+ return dio->result;
}

/*
* We need to wait for the request to complete if the request
- * is synchronous or an async write which writes to hole or
- * extends the file.
+ * is synchronous, failed to issue in the middle or is an
+ * async write which writes to hole or extends the file.
*
* For file extending writes updating i_size before data
* writeouts complete can expose uninitialized blocks. So even
--
1.4.3.3

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-11-09 02:21    [W:0.031 / U:1.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site