From: Konstantin Khlebnikov Date: Thu, 28 Apr 2016 23:19:03 +0000 (-0700) Subject: mm/memory-failure: fix race with compound page split/merge X-Git-Tag: v4.6-rc6~8^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2e7e00b715d3c65f301bec8559d6af4ef8098ab;p=platform%2Fkernel%2Flinux-exynos.git mm/memory-failure: fix race with compound page split/merge 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 Acked-by: Naoya Horiguchi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 78f5f26..ca5acee 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -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);