From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D460A3822A6 for ; Sat, 17 Oct 2026 01:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792202313; cv=none; b=b+znP6d/Vs0AKJ/+6AdQn7FGxD1WriPqeTZ2TF0R59QsG+kI+mwRkPL+cBKA5thjqD+KighD0uUajoyNNc46Y2dgQpL/yxiyI/Fl+2UYqJo4MSIrmYYgdQ08u7Jn+aUfGgWy5pLgrSJr7YNvxLpWGcqzcrP4FpWGNS0Y8WKmPCQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792202313; c=relaxed/simple; bh=duUlxkHDYDE+7B+xaHNZff4qc2YIaxhSJAlFuVjJjJA=; h=Date:To:From:Subject:Message-Id; b=cUeSRnFC1tGHtcRMx397QDwliz/SHOJjVjBactEbZ8Sja7Zu0BfF+Jty0XbEqpMpeoBiilZecsalmrlJQPFtTR6sEwQqQPjFmBP0egRrk7LK7iDwTZmyqK53eMok8gDItVtp4jBE3Od6XNgd6DwP+LE2j9/AsaITFiCvZ4RYvzc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=0GeUzXCf; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="0GeUzXCf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B8A91F000C4; Sat, 17 Oct 2026 01:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1792202311; bh=tADIhVDY67mhnRWyRMjYsrqytnlKPLNtvt8ucxTNH38=; h=Date:To:From:Subject; b=0GeUzXCfQiSE6N/KwaGQSV9pzbzujKKSiBnNYXQnTJxVuH9wwSaqf2KTVzstnb56R Ix7hef4cxX6ygaRGWR8rL4/aj3c7a0nf6Hf5EW/Uj3gsiBsyCe6cOJeZETaCLe5NPQ P6/wFsRf2JUO53gz78WBeCylJpUirmThLsCxuxfM= Date: Fri, 16 Oct 2026 18:58:30 -0700 To: mm-commits@vger.kernel.org,willy@infradead.org,tytso@mit.edu,jack@suse.cz,bfoster@redhat.com,nickolai@csail.mit.edu,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-truncate-fix-the-zeroing-end-of-pagecache_isize_extended.patch added to mm-unstable branch Message-Id: <20261017015831.4B8A91F000C4@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm/truncate: fix the zeroing end of pagecache_isize_extended() has been added to the -mm mm-unstable branch. Its filename is mm-truncate-fix-the-zeroing-end-of-pagecache_isize_extended.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-truncate-fix-the-zeroing-end-of-pagecache_isize_extended.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Nickolai Zeldovich Subject: mm/truncate: fix the zeroing end of pagecache_isize_extended() Date: Fri, 16 Oct 2026 18:27:21 -0400 A process that extends a file by 4 GiB or more past a dirty folio, on a file system whose block size is smaller than the page size (ext4 with 1k blocks), reads back the bytes it wrote through a shared mapping beyond the old end of file instead of zeroes, and a later write into that block carries them to the disk. With the example of commit 52aecaee1c26 ("mm: zero range of eof folio exposed by inode size extension") and the truncate taken 4 GiB further (pwrite 2k at 0, mmap the first page and write 'X' over [2k, 4k), truncate(2) to 4 GiB + 2k), the read of [2k, 4k) returns the 2048 'X' bytes, and a pwrite of 16 bytes at 3k followed by fsync() and a remount leaves 1008 'X' bytes on the disk in [3k+16, 4k). No privilege is needed, and every size extension of 4 GiB or more reaches it: truncate(2)/ftruncate(2) through truncate_setsize(), writes beyond the end of file through generic_write_end(), ext4, iomap, btrfs, exfat, ntfs, afs and orangefs. Affected since v6.13. pagecache_isize_extended() zeroes the part of the dirty folio straddling the old end of file that the size extension exposes, from the old size to the new size or the end of the folio, whichever comes first: end = min_t(unsigned int, to - folio_pos(folio), folio_size(folio)); min_t() converts both operands to unsigned int before comparing, so the loff_t difference to - folio_pos(folio) is reduced modulo 2^32 first. When the file grows by 4 GiB or more past the folio, end is that residue instead of folio_size(folio): below offset nothing is zeroed, above it only [offset, end) is. The bytes beyond the old end of file stay in the dirty folio and, now inside i_size, are file data. Compare in loff_t; the result is at most folio_size(folio) and fits end. Found while formally verifying pagecache_isize_extended() against the kernel binary. Link: https://lore.kernel.org/20261016222721.791785-1-nickolai@csail.mit.edu Fixes: 52aecaee1c26 ("mm: zero range of eof folio exposed by inode size extension") Signed-off-by: Nickolai Zeldovich Signed-off-by: Andrew Morton Assisted-by: LLM Cc: Matthew Wilcox (Oracle) Cc: Jan Kara Cc: Brian Foster Cc: Theodore Ts'o --- mm/truncate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/mm/truncate.c~mm-truncate-fix-the-zeroing-end-of-pagecache_isize_extended +++ a/mm/truncate.c @@ -919,8 +919,7 @@ void pagecache_isize_extended(struct ino unsigned int offset, end; offset = from - folio_pos(folio); - end = min_t(unsigned int, to - folio_pos(folio), - folio_size(folio)); + end = min_t(loff_t, to - folio_pos(folio), folio_size(folio)); folio_zero_segment(folio, offset, end); } _ Patches currently in -mm which might be from nickolai@csail.mit.edu are mm-mlock-use-a-long-for-the-page-count-in-mlock_fixup.patch mm-truncate-fix-the-zeroing-end-of-pagecache_isize_extended.patch