From: Matthew Wilcox <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: linux-ext4@vger.kernel.org, Jan Kara <jack@suse.com>,
Theodore Ts'o <tytso@mit.edu>,
Andreas Dilger <adilger.kernel@dilger.ca>
Subject: Re: set_page_dirty vs truncate
Date: Fri, 18 Dec 2020 22:03:16 +0000 [thread overview]
Message-ID: <20201218220316.GO15600@casper.infradead.org> (raw)
In-Reply-To: <20201218160531.GL15600@casper.infradead.org>
On Fri, Dec 18, 2020 at 04:05:31PM +0000, Matthew Wilcox wrote:
> A number of implementations of ->set_page_dirty check whether the page
> has been truncated (ie page->mapping has become NULL since entering
> set_page_dirty()). Several other implementations assume that they can do
> page->mapping->host to get to the inode. So either some implementations
> are doing unnecessary checks or others are vulnerable to a NULL pointer
> dereference if truncate() races with set_page_dirty().
>
> I'm touching ->set_page_dirty() anyway as part of the page folio
> conversion. I'm thinking about passing in the mapping so there's no
> need to look at page->mapping.
>
> The comments on set_page_dirty() and set_page_dirty_lock() suggests
> there's no consistency in whether truncation is blocked or not; we're
> only guaranteed that the inode itself won't go away. But maybe the
> comments are stale.
The comments are, I believe, not stale. Here's some syzbot
reports which indicate that ext4 is seeing races between set_page_dirty()
and truncate():
https://groups.google.com/g/syzkaller-lts-bugs/c/s9fHu162zhQ/m/Phnf6ucaAwAJ
The reproducer includes calls to ftruncate(), so that would suggest
that's what's going on.
I would suggest just deleting this line:
WARN_ON_ONCE(!page_has_buffers(page));
I'm not sure what value the other WARN_ON_ONCE adds. Maybe just replace
ext4_set_page_dirty with __set_page_dirty_buffers in the aops? I'd defer
to an ext4 expert on this ...
next parent reply other threads:[~2020-12-18 22:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20201218160531.GL15600@casper.infradead.org>
2020-12-18 22:03 ` Matthew Wilcox [this message]
2020-12-21 14:12 ` set_page_dirty vs truncate Jan Kara
2020-12-21 14:58 ` Matthew Wilcox
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=20201218220316.GO15600@casper.infradead.org \
--to=willy@infradead.org \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
/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).