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-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  2 Feb 2023 20:44:23 +0000
From:   "Matthew Wilcox (Oracle)" <>
Cc:     "Matthew Wilcox (Oracle)" <>,,,,,
        Hugh Dickins <>,,
Subject: [PATCH 1/5] truncate: 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.
This fixes the problem for the filesystems which simply call
truncate_setsize().  More complex filesystems will need their own

Signed-off-by: Matthew Wilcox (Oracle) <>
 mm/truncate.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mm/truncate.c b/mm/truncate.c
index 7b4ea4c4a46b..cebfc5415e9a 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -763,9 +763,12 @@ void truncate_setsize(struct inode *inode, loff_t newsize)
 	loff_t oldsize = inode->i_size;
 	i_size_write(inode, newsize);
-	if (newsize > oldsize)
+	if (newsize > oldsize) {
 		pagecache_isize_extended(inode, oldsize, newsize);
-	truncate_pagecache(inode, newsize);
+		truncate_pagecache(inode, oldsize);
+	} else {
+		truncate_pagecache(inode, newsize);
+	}

Powered by blists - more mailing lists