From: Miaohe Lin Date: Tue, 22 Mar 2022 21:44:47 +0000 (-0700) Subject: mm/memory-failure.c: avoid calling invalidate_inode_page() with unexpected pages X-Git-Tag: x86-urgent-2022-04-03~14^2~103 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=593396b86ef6f79c71e09c183eae28040ccfeedf;p=users%2Fdwmw2%2Flinux.git mm/memory-failure.c: avoid calling invalidate_inode_page() with unexpected pages Since commit 042c4f32323b ("mm/truncate: Inline invalidate_complete_page() into its one caller"), invalidate_inode_page() can invalidate the pages in the swap cache because the check of page->mapping != mapping is removed. But invalidate_inode_page() is not expected to deal with the pages in swap cache. Also non-lru movable page can reach here too. They're not page cache pages. Skip these pages by checking PageSwapCache and PageLRU. Link: https://lkml.kernel.org/r/20220312074613.4798-3-linmiaohe@huawei.com Signed-off-by: Miaohe Lin Cc: Borislav Petkov Cc: Mike Kravetz Cc: Naoya Horiguchi Cc: Tony Luck Cc: Yang Shi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 7ec855149393b..47be518f075e5 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2184,7 +2184,7 @@ static int __soft_offline_page(struct page *page) return 0; } - if (!PageHuge(page)) + if (!PageHuge(page) && PageLRU(page) && !PageSwapCache(page)) /* * Try to invalidate first. This should work for * non dirty unmapped page cache pages.