[PATCH 3/5] mm: soft-offline: exit with failure for non anonymous thp
Andrea Righi
andrea.righi at canonical.com
Tue Apr 2 14:53:00 UTC 2019
From: Naoya Horiguchi <n-horiguchi at ah.jp.nec.com>
Currently memory_failure() doesn't handle non anonymous thp case,
because we can hardly expect the error handling to be successful, and it
can just hit some corner case which results in BUG_ON or something
severe like that. This is also the case for soft offline code, so let's
make it in the same way.
Orignal code has a MF_COUNT_INCREASED check before put_hwpoison_page(),
but it's unnecessary because get_any_page() is already called when
running on this code, which takes a refcount of the target page
regardress of the flag. So this patch also removes it.
[akpm at linux-foundation.org: fix build]
Signed-off-by: Naoya Horiguchi <n-horiguchi at ah.jp.nec.com>
Cc: Andi Kleen <andi at firstfloor.org>
Cc: "Kirill A. Shutemov" <kirill at shutemov.name>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
CVE-2019-10124
(backported from commit 98fd1ef4241ce0c700a174dd3e33c643b4774690)
Signed-off-by: Andrea Righi <andrea.righi at canonical.com>
---
mm/memory-failure.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 25c4dc2035c9..3730845e349a 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1732,16 +1732,16 @@ static int soft_offline_in_use_page(struct page *page, int flags)
if (!PageHuge(page) && PageTransHuge(hpage)) {
lock_page(hpage);
- ret = split_huge_page(hpage);
- unlock_page(hpage);
- if (unlikely(ret || PageTransCompound(page) ||
- !PageAnon(page))) {
- pr_info("soft offline: %#lx: failed to split THP\n",
- page_to_pfn(page));
- if (flags & MF_COUNT_INCREASED)
- put_hwpoison_page(hpage);
+ if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
+ unlock_page(hpage);
+ if (!PageAnon(hpage))
+ pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page));
+ else
+ pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page));
+ put_hwpoison_page(hpage);
return -EBUSY;
}
+ unlock_page(hpage);
get_hwpoison_page(page);
put_hwpoison_page(hpage);
}
--
2.19.1
More information about the kernel-team
mailing list