linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] iomap: Do not unshare exents beyond EOF
@ 2024-09-05 10:24 Julian Sun
  2024-09-06 19:11 ` Brian Foster
  2024-09-10  0:44 ` Dave Chinner
  0 siblings, 2 replies; 13+ messages in thread
From: Julian Sun @ 2024-09-05 10:24 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: jack, brauner, viro, djwong, david, hch, Julian Sun,
	syzbot+296b1c84b9cbf306e5a0

Attempting to unshare extents beyond EOF will trigger
the need zeroing case, which in turn triggers a warning.
Therefore, let's skip the unshare process if extents are
beyond EOF.

Reported-and-tested-by: syzbot+296b1c84b9cbf306e5a0@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=296b1c84b9cbf306e5a0
Fixes: 32a38a499104 ("iomap: use write_begin to read pages to unshare")
Inspired-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
---
 fs/iomap/buffered-io.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index f420c53d86ac..8898d5ec606f 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1340,6 +1340,9 @@ static loff_t iomap_unshare_iter(struct iomap_iter *iter)
 	/* don't bother with holes or unwritten extents */
 	if (srcmap->type == IOMAP_HOLE || srcmap->type == IOMAP_UNWRITTEN)
 		return length;
+	/* don't try to unshare any extents beyond EOF. */
+	if (pos > i_size_read(iter->inode))
+		return length;
 
 	do {
 		struct folio *folio;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-09-17 20:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-05 10:24 [PATCH 1/2] iomap: Do not unshare exents beyond EOF Julian Sun
2024-09-06 19:11 ` Brian Foster
2024-09-09 12:15   ` Julian Sun
2024-09-09 13:28     ` Brian Foster
2024-09-09 17:40       ` Julian Sun
2024-09-09 19:29         ` Brian Foster
2024-09-10  7:03           ` Julian Sun
2024-09-10 12:30             ` Brian Foster
2024-09-10 13:25               ` Julian Sun
2024-09-10 13:56                 ` Brian Foster
2024-09-11  4:01                   ` Julian Sun
2024-09-17 20:39                     ` Darrick J. Wong
2024-09-10  0:44 ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).