Skip to content

Commit 9dfb3b8

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
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: da08e9b ("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]>
1 parent ab74ef7 commit 9dfb3b8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/shmem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
17821782

17831783
if (shmem_should_replace_folio(folio, gfp)) {
17841784
error = shmem_replace_page(&page, gfp, info, index);
1785+
folio = page_folio(page);
17851786
if (error)
17861787
goto failed;
17871788
}

0 commit comments

Comments
 (0)