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: <1311004772-14675-1-git-send-email-josef@redhat.com>
Date:	Mon, 18 Jul 2011 11:59:32 -0400
From:	Josef Bacik <josef@...hat.com>
To:	linux-ext4@...r.kernel.org, tytso@....edu
Subject: [PATCH] ext4: hold page lock when checking mapping in ext4_page_mkwrite

Pages can be evicted from cache outside of truncate, for example when
invalidating pages after writing with O_DIRECT.  The only proper way to check
page->mapping is under the page lock, so fix ext4_page_mkwrite to do this.
Thanks,

Signed-off-by: Josef Bacik <josef@...hat.com>
---
 fs/ext4/inode.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e3126c0..1ad7d10 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5855,14 +5855,15 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	 */
 	down_read(&inode->i_alloc_sem);
 	size = i_size_read(inode);
+	lock_page(page);
 	if (page->mapping != mapping || size <= page_offset(page)
 	    || !PageUptodate(page)) {
+		unlock_page(page);
 		/* page got truncated from under us? */
 		goto out_unlock;
 	}
 	ret = 0;
 
-	lock_page(page);
 	wait_on_page_writeback(page);
 	if (PageMappedToDisk(page)) {
 		up_read(&inode->i_alloc_sem);
-- 
1.7.5.2

--
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