]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mm/hwpoison: fix PageHWPoison test/set race
authorWanpeng Li <wanpeng.li@hotmail.com>
Tue, 8 Sep 2015 22:03:13 +0000 (15:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 8 Sep 2015 22:35:28 +0000 (15:35 -0700)
There is a race between madvise_hwpoison path and memory_failure:

 CPU0 CPU1

madvise_hwpoison
get_user_pages_fast
PageHWPoison check (false)
memory_failure
TestSetPageHWPoison
soft_offline_page
PageHWPoison check (true)
return -EBUSY (without put_page)

Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Suggested-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 8ad923a93539b4ac99e65cf507cab377388b618c..863544d84a0996fa5f79c777e11eee18e2d116cc 100644 (file)
@@ -1719,6 +1719,8 @@ int soft_offline_page(struct page *page, int flags)
 
        if (PageHWPoison(page)) {
                pr_info("soft offline: %#lx page already poisoned\n", pfn);
+               if (flags & MF_COUNT_INCREASED)
+                       put_page(page);
                return -EBUSY;
        }
        if (!PageHuge(page) && PageTransHuge(hpage)) {