From: Matthew Wilcox <willy@infradead.org>
To: Jan Kara <jack@suse.cz>, Andrew Morton <akpm@linux-foundation.org>
Cc: syzbot <syzbot+707bba7f823c7b02fa43@syzkaller.appspotmail.com>,
almaz.alexandrovich@paragon-software.com, brauner@kernel.org,
dchinner@redhat.com, hirofumi@mail.parknet.co.jp, jack@suse.com,
jfs-discussion@lists.sourceforge.net, linkinjeon@kernel.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
ntfs3@lists.linux.dev, shaggy@kernel.org, sj1557.seo@samsung.com,
syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [hfsplus?] [udf?] [fat?] [jfs?] [vfs?] [hfs?] [exfat?] [ntfs3?] WARNING in __mpage_writepage
Date: Tue, 31 Jan 2023 15:06:16 +0000 [thread overview]
Message-ID: <Y9kuaBgXf9lKJ8b0@casper.infradead.org> (raw)
In-Reply-To: <20230131121423.pqfogvntzouymzmv@quack3>
On Tue, Jan 31, 2023 at 01:14:23PM +0100, Jan Kara wrote:
> This is the warning Willy has added as part of "mpage: convert
> __mpage_writepage() to use a folio more fully" and that warning can indeed
> easily trigger. There's nothing that serializes writeback against racing
> truncate setting new i_size so it is perfectly normal to see pages beyond
> EOF in this place. And the traditional response to such pages is "silently
> do nothing" since they will be soon discarded by truncate_inode_pages().
Absolutely right. Not sure what I was thinking; I may have been
confused by the label being called "confused". How about this for
Andrew to squash into that commit?
diff --git a/fs/mpage.c b/fs/mpage.c
index 2efa393f0db7..89bcefb4553a 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -559,6 +559,9 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc,
first_unmapped = page_block;
page_is_mapped:
+ /* Don't bother writing beyond EOF, truncate will discard the folio */
+ if (folio_pos(folio) >= i_size)
+ goto confused;
length = folio_size(folio);
if (folio_pos(folio) + length > i_size) {
/*
@@ -570,8 +573,6 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc,
* written out to the file."
*/
length = i_size - folio_pos(folio);
- if (WARN_ON_ONCE(folio_pos(folio) >= i_size))
- goto confused;
folio_zero_segment(folio, length, folio_size(folio));
}
prev parent reply other threads:[~2023-01-31 15:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-31 10:05 [syzbot] [hfsplus?] [udf?] [fat?] [jfs?] [vfs?] [hfs?] [exfat?] [ntfs3?] WARNING in __mpage_writepage syzbot
2023-01-31 12:14 ` Jan Kara
2023-01-31 15:06 ` Matthew Wilcox [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=Y9kuaBgXf9lKJ8b0@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=brauner@kernel.org \
--cc=dchinner@redhat.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=jack@suse.com \
--cc=jack@suse.cz \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
--cc=shaggy@kernel.org \
--cc=sj1557.seo@samsung.com \
--cc=syzbot+707bba7f823c7b02fa43@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/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 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).