]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mm/memory-failure: fix race with compound page split/merge
authorKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Thu, 28 Apr 2016 23:19:03 +0000 (16:19 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 29 Apr 2016 02:34:04 +0000 (19:34 -0700)
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>
mm/memory-failure.c

index 78f5f2641b91ddc7217735667e59a5753db3c63b..ca5acee53b7a3b402e24fac99e358323e913e225 100644 (file)
@@ -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);