Skip to content

Commit

Permalink
mm/memory-failure: fix race with compound page split/merge
Browse files Browse the repository at this point in the history
get_hwpoison_page() must recheck relation between head and tail pages.

n-horiguchi said: without this recheck, the race causes kernel to pin an
irrelevant page, and finally makes kernel crash for refcount mismatch.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Konstantin Khlebnikov authored and Linus Torvalds committed Apr 29, 2016
1 parent b734136 commit c2e7e00
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,15 @@ int get_hwpoison_page(struct page *page)
}
}

return get_page_unless_zero(head);
if (get_page_unless_zero(head)) {
if (head == compound_head(page))
return 1;

pr_info("MCE: %#lx cannot catch tail\n", page_to_pfn(page));
put_page(head);
}

return 0;
}
EXPORT_SYMBOL_GPL(get_hwpoison_page);

Expand Down

0 comments on commit c2e7e00

Please sign in to comment.