lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1365438463-23025-1-git-send-email-jack@suse.cz>
Date:	Mon,  8 Apr 2013 18:27:43 +0200
From:	Jan Kara <jack@...e.cz>
To:	Ted Tso <tytso@....edu>
Cc:	linux-ext4@...r.kernel.org, Jan Kara <jack@...e.cz>
Subject: [PATCH] ext4: Fix data corruption with direct IO read in dioread_nolock mode

When ext4 is mounted in dioread_nolock mode, it calls
__blockdev_direct_IO() without DIO_LOCKING flag which also means mapping
is not synced before direct IO starts. As a result consistency between
buffered writes and following direct IO reads is broken. More
importantly, if the file is truncated, and extented back, zeroing of the
tail page is not visible to the following direct IO read which will return
stale data.

Fix the problem by flushing dirty pages before issuing direct IO read.

Signed-off-by: Jan Kara <jack@...e.cz>
---
 fs/ext4/indirect.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index b505a14..c18bf1c 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -809,6 +809,10 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
 
 retry:
 	if (rw == READ && ext4_should_dioread_nolock(inode)) {
+		ret = filemap_write_and_wait_range(inode->i_mapping, offset,
+						   offset + count - 1);
+		if (ret)
+			goto out;
 		if (unlikely(atomic_read(&EXT4_I(inode)->i_unwritten))) {
 			mutex_lock(&inode->i_mutex);
 			ext4_flush_unwritten_io(inode);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ