Skip to content

Commit b3b3a99

Browse files
Naoya Horiguchitorvalds
authored andcommitted
mm/migrate: check-before-clear PageSwapCache
With the page flag sanitization patchset, an invalid usage of ClearPageSwapCache() is detected in migration_page_copy(). migrate_page_copy() is shared by both normal and hugepage (both thp and hugetlb) code path, so let's check PageSwapCache() and clear it if it's set to avoid misuse of the invalid clear operation. Signed-off-by: Naoya Horiguchi <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8d63d99 commit b3b3a99

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mm/migrate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ void migrate_page_copy(struct page *newpage, struct page *page)
537537
* Please do not reorder this without considering how mm/ksm.c's
538538
* get_ksm_page() depends upon ksm_migrate_page() and PageSwapCache().
539539
*/
540-
ClearPageSwapCache(page);
540+
if (PageSwapCache(page))
541+
ClearPageSwapCache(page);
541542
ClearPagePrivate(page);
542543
set_page_private(page, 0);
543544

0 commit comments

Comments
 (0)