linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* set_page_dirty vs truncate
@ 2020-12-18 16:05 Matthew Wilcox
  2020-12-18 22:03 ` Matthew Wilcox
  0 siblings, 1 reply; 8+ messages in thread
From: Matthew Wilcox @ 2020-12-18 16:05 UTC (permalink / raw)
  To: linux-fsdevel

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.


There're also some filesystems which always return false from
set_page_dirty() and others which check for PageSwapCache, which surely
can't happen.  I'm also confused by the ones which set PageUptodate.
And several should just use __set_page_dirty_no_writeback().

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

end of thread, other threads:[~2020-12-21 15:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-18 16:05 set_page_dirty vs truncate Matthew Wilcox
2020-12-18 22:03 ` Matthew Wilcox
2020-12-19  5:18   ` Matthew Wilcox
2020-12-19  6:10     ` John Hubbard
2020-12-19  6:50       ` Matthew Wilcox
2020-12-19  7:04         ` John Hubbard
2020-12-21 14:12   ` Jan Kara
2020-12-21 14:58     ` Matthew Wilcox

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).