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: <1432049337-3520-1-git-send-email-jbacik@fb.com>
Date:	Tue, 19 May 2015 11:28:57 -0400
From:	Josef Bacik <jbacik@...com>
To:	<tytso@....edu>, <linux-ext4@...r.kernel.org>
Subject: [PATCH] ext4: only call ext4_truncate when size <= isize

At LSF we decided that if we truncate up from isize we shouldn't trim fallocated
blocks that were fallocated with KEEP_SIZE and are past the new i_size.  This
patch fixes ext4 to do this.  Thanks,

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

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0554b0b..92174dd 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4640,6 +4640,7 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
 int ext4_setattr(struct dentry *dentry, struct iattr *attr)
 {
 	struct inode *inode = d_inode(dentry);
+	loff_t oldsize = inode->i_size;
 	int error, rc = 0;
 	int orphan = 0;
 	const unsigned int ia_valid = attr->ia_valid;
@@ -4727,8 +4728,6 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
 				goto err_out;
 			}
 		} else {
-			loff_t oldsize = inode->i_size;
-
 			i_size_write(inode, attr->ia_size);
 			pagecache_isize_extended(inode, oldsize, inode->i_size);
 		}
@@ -4756,7 +4755,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
 	 * We want to call ext4_truncate() even if attr->ia_size ==
 	 * inode->i_size for cases like truncation of fallocated space
 	 */
-	if (attr->ia_valid & ATTR_SIZE)
+	if (attr->ia_valid & ATTR_SIZE && attr->ia_size <= oldsize)
 		ext4_truncate(inode);
 
 	if (!rc) {
-- 
1.8.3.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