diff options
author | Matthew Wilcox (Oracle) <[email protected]> | 2022-07-30 05:25:18 +0100 |
---|---|---|
committer | Andrew Morton <[email protected]> | 2022-08-28 14:02:43 -0700 |
commit | 9dfb3b8d655022760ca68af11821f1c63aa547c3 (patch) | |
tree | 70a926c1eb27480f540a86768dda9eaa46bedce8 | |
parent | ab74ef708dc51df7cf2b8a890b9c6990fac5c0c6 (diff) |
shmem: update folio if shmem_replace_page() updates the page
If we allocate a new page, we need to make sure that our folio matches
that new page.
If we do end up in this code path, we store the wrong page in the shmem
inode's page cache, and I would rather imagine that data corruption
ensues.
This will be solved by changing shmem_replace_page() to
shmem_replace_folio(), but this is the minimal fix.
Link: https://lkml.kernel.org/r/[email protected]
Fixes: da08e9b79323 ("mm/shmem: convert shmem_swapin_page() to shmem_swapin_folio()")
Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Reviewed-by: William Kucharski <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r-- | mm/shmem.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index d075dd2dcc48..42e5888bf84d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1782,6 +1782,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, if (shmem_should_replace_folio(folio, gfp)) { error = shmem_replace_page(&page, gfp, info, index); + folio = page_folio(page); if (error) goto failed; } |