diff options
author | Wanpeng Li <wanpeng.li@hotmail.com> | 2015-09-08 15:03:13 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-08 15:35:28 -0700 |
commit | 1e0e635be82132167a134b5a9c884e70e61f8373 (patch) | |
tree | be7f964bee75f72d71df0bde9b6844b9fa4286d6 /mm/memory-failure.c | |
parent | 7d1900c744b2e4687b3e467edf58373c02bcf22d (diff) | |
download | linux-1e0e635be82132167a134b5a9c884e70e61f8373.tar.gz linux-1e0e635be82132167a134b5a9c884e70e61f8373.tar.bz2 linux-1e0e635be82132167a134b5a9c884e70e61f8373.zip |
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 <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>
Diffstat (limited to 'mm/memory-failure.c')
-rw-r--r-- | mm/memory-failure.c | 2 |
1 files changed, 2 insertions, 0 deletions
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)) { |