Skip to content

Commit 48db54e

Browse files
Minchan Kimtorvalds
authored andcommitted
mm/migration: fix page corruption during hugepage migration
If migrate_huge_page by memory-failure fails , it calls put_page in itself to decrease page reference and caller of migrate_huge_page also calls putback_lru_pages. It can do double free of page so it can make page corruption on page holder. In addtion, clean of pages on caller is consistent behavior with migrate_pages by cf608ac ("mm: compaction: fix COMPACTPAGEFAILED counting"). Signed-off-by: Minchan Kim <minchan.kim@gmail.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Christoph Lameter <cl@linux.com> Cc: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 57fc4a5 commit 48db54e

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎mm/memory-failure.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,10 @@ static int soft_offline_huge_page(struct page *page, int flags)
12951295
ret = migrate_huge_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL, 0,
12961296
true);
12971297
if (ret) {
1298-
putback_lru_pages(&pagelist);
1298+
struct page *page1, *page2;
1299+
list_for_each_entry_safe(page1, page2, &pagelist, lru)
1300+
put_page(page1);
1301+
12991302
pr_debug("soft offline: %#lx: migration failed %d, type %lx\n",
13001303
pfn, ret, page->flags);
13011304
if (ret > 0)

‎mm/migrate.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -980,10 +980,6 @@ int migrate_huge_pages(struct list_head *from,
980980
}
981981
rc = 0;
982982
out:
983-
984-
list_for_each_entry_safe(page, page2, from, lru)
985-
put_page(page);
986-
987983
if (rc)
988984
return rc;
989985

0 commit comments

Comments
 (0)