From: Wanpeng Li Date: Tue, 8 Sep 2015 22:03:13 +0000 (-0700) Subject: mm/hwpoison: fix PageHWPoison test/set race X-Git-Tag: v5.15~15107^2~41 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=1e0e635be82132167a134b5a9c884e70e61f8373;p=mirror_ubuntu-kernels.git mm/hwpoison: fix PageHWPoison test/set race 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 Suggested-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 8ad923a93539..863544d84a09 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -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)) {