All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,willy@infradead.org,stable@vger.kernel.org,
	pfalcato@suse.de,kas@kernel.org,jack@suse.cz,dave.hansen@linux.intel.com,
	dennylin0707@gmail.com,akpm@linux-foundation.org
Subject: [merged mm-hotfixes-stable] filemap-prefault-writes-starting-beyond-eof.patch removed from -mm tree
Date: Sun, 22 Nov 2026 22:24:45 -0800	[thread overview]
Message-ID: <20261123062446.310EB1F000C0@smtp.kernel.org> (raw)
In-Reply-To: <20261104071002.49693-1-dennylin0707@gmail.com>


The quilt patch titled
     Subject: filemap: prefault writes starting beyond EOF
has been removed from the -mm tree.  Its filename was
     filemap-prefault-writes-starting-beyond-eof.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Hungyu Lin <dennylin0707@gmail.com>
Subject: filemap: prefault writes starting beyond EOF
Date: Wed, 04 Nov 2026 07:10:02 +0000

Since prefaulting moved to the slow write path, a buffered write can reach
->write_begin() and ->write_end() before discovering that its source
buffer is unreadable.  Several filesystems can extend i_size in these
callbacks even when no data was copied.  For example, a one-byte pwrite()
at offset 4096 into an empty file can fail with EFAULT but leave a
4096-byte file.

Prefault the source before ->write_begin() when the write position is
beyond EOF, and return EFAULT if no source bytes can be made readable. 
Overwrites and appends continue to skip this prefault.  Keep the existing
slow-path faulting for forward progress after a failed atomic copy.

This also leaves intentional zero-length ->write_end() calls used by
generic_cont_expand_simple() unchanged.  As with the previous prefaulting
behavior, a concurrent userspace unmap can still race with the later copy.

Link: https://patch.msgid.link/20261104071002.49693-1-dennylin0707@gmail.com
Fixes: 665575cff098 ("filemap: move prefaulting out of hot write path")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Kiryl Shutsemau <kas@kernel.org>
Link: https://lore.kernel.org/all/at-XtWBQg3jv3H8Z@thinkstation/
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: <stable@vger.kernel.org>

 mm/filemap.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/mm/filemap.c~filemap-prefault-writes-starting-beyond-eof
+++ a/mm/filemap.c
@@ -4404,6 +4404,16 @@ retry:
 			break;
 		}
 
+		/*
+		 * Some filesystems can extend i_size even when nothing was copied.
+		 * Prefault writes beyond EOF to catch unreadable source buffers.
+		 */
+		if (unlikely(pos > i_size_read(mapping->host)) &&
+		    fault_in_iov_iter_readable(i, bytes) == bytes) {
+			status = -EFAULT;
+			break;
+		}
+
 		status = a_ops->write_begin(iocb, mapping, pos, bytes,
 						&folio, &fsdata);
 		if (unlikely(status < 0))
_

Patches currently in -mm which might be from dennylin0707@gmail.com are

mm-page-writeback-avoid-overflow-when-reporting-bdi-byte-limits.patch
mm-skip-empty-finite-ranges-in-truncate_pagecache_range.patch
hugetlbfs-report-inode-limits-without-a-memory-subpool.patch
delayacct-preserve-delay-extrema-when-aggregating-taskstats.patch
shmem-clamp-negative-used-block-samples-in-statfs.patch


      parent reply	other threads:[~2026-11-23  6:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  7:10 [PATCH] filemap: prefault writes starting beyond EOF Hungyu Lin
2026-11-05 12:12 ` Kiryl Shutsemau
2026-11-05 12:33 ` Pedro Falcato
2026-11-05 12:49   ` Kiryl Shutsemau
2026-11-09 10:55 ` Jan Kara
2026-11-23  6:24 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123062446.310EB1F000C0@smtp.kernel.org \
    --to=akpm@linux-foundation.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=dennylin0707@gmail.com \
    --cc=jack@suse.cz \
    --cc=kas@kernel.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=pfalcato@suse.de \
    --cc=stable@vger.kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.