Skip to content

Commit

Permalink
mm: fix madivse_pageout mishandling on non-LRU page
Browse files Browse the repository at this point in the history
MADV_PAGEOUT tries to isolate non-LRU pages and gets a warning from
isolate_lru_page below.

Fix it by checking PageLRU in advance.

------------[ cut here ]------------
trying to isolate tail page
WARNING: CPU: 0 PID: 6175 at mm/folio-compat.c:158 isolate_lru_page+0x130/0x140
Modules linked in:
CPU: 0 PID: 6175 Comm: syz-executor.0 Not tainted 5.18.12 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
RIP: 0010:isolate_lru_page+0x130/0x140

Link: https://lore.kernel.org/linux-mm/[email protected]/
Link: https://lkml.kernel.org/r/[email protected]
Fixes: 1a4e58c ("mm: introduce MADV_PAGEOUT")
Signed-off-by: Minchan Kim <[email protected]>
Reported-by: 韩天ç`� <[email protected]>
Suggested-by: Yang Shi <[email protected]>
Acked-by: Yang Shi <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
minchank authored and akpm00 committed Sep 26, 2022
1 parent bedf034 commit 58d426a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,11 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
continue;
}

/* Do not interfere with other mappings of this page */
if (page_mapcount(page) != 1)
/*
* Do not interfere with other mappings of this page and
* non-LRU page.
*/
if (!PageLRU(page) || page_mapcount(page) != 1)
continue;

VM_BUG_ON_PAGE(PageTransCompound(page), page);
Expand Down

0 comments on commit 58d426a

Please sign in to comment.