[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 2 Feb 2023 20:44:24 +0000
From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
To: linux-fsdevel@...r.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
linux-afs@...ts.infradead.org, linux-btrfs@...r.kernel.org,
linux-ext4@...r.kernel.org, linux-mm@...ck.org,
Hugh Dickins <hughd@...gle.com>, linux-kernel@...r.kernel.org,
fstests@...r.kernel.org
Subject: [PATCH 2/5] ext4: Zero bytes after 'oldsize' if we're expanding the file
POSIX requires that "If the file size is increased, the extended area
shall appear as if it were zero-filled". It is possible to use mmap to
write past EOF and that data will become visible instead of zeroes.
Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
---
fs/ext4/inode.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 9d9f414f99fe..14e3fa99f733 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5604,6 +5604,7 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
if (!shrink) {
pagecache_isize_extended(inode, oldsize,
inode->i_size);
+ truncate_pagecache(inode, oldsize);
} else if (ext4_should_journal_data(inode)) {
ext4_wait_for_tail_page_commit(inode);
}
--
2.35.1
Powered by blists - more mailing lists