提交 41c46e00 编写于 作者: Z zhongjiang 提交者: Xie XiuQi

mm: hwpoison: fix thp split handing in soft_offline_in_use_page()

mainline inclusion
from mainline-5.x
commit: <not-yet-available>
category: bugfix
bugzilla: 10883
CVE: NA

------------------------------------------------

When soft_offline_in_use_page() runs on a thp tail page after pmd is split,
we trigger the following VM_BUG_ON_PAGE():

Memory failure: 0x3755ff: non anonymous thp
__get_any_page: 0x3755ff: unknown zero refcount page type 2fffff80000000
Soft offlining pfn 0x34d805 at process virtual address 0x20fff000
page:ffffea000d360140 count:0 mapcount:0 mapping:0000000000000000 index:0x1
flags: 0x2fffff80000000()
raw: 002fffff80000000 ffffea000d360108 ffffea000d360188 0000000000000000
raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: VM_BUG_ON_PAGE(page_ref_count(page) == 0)
------------[ cut here ]------------
kernel BUG at ./include/linux/mm.h:519!

soft_offline_in_use_page() passed refcount and page lock from tail page to
head page, which is not needed because we can pass any subpage to
split_huge_page().

Naoya had fixed the similar issue in the commit c3901e72 ("
mm: hwpoison: fix thp split handling in memory_failure()"). But he missed
fixing soft offline.

Fixes: 61f5d698 ("mm: re-enable THP")
Cc: <stable@vger.kernel.org>        [4.5+]
Acked-by: NNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Nzhongjiang <zhongjiang@huawei.com>
Reviewed-by: NMiao Xie <miaoxie@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 bd575e60
...@@ -1823,19 +1823,17 @@ static int soft_offline_in_use_page(struct page *page, int flags) ...@@ -1823,19 +1823,17 @@ static int soft_offline_in_use_page(struct page *page, int flags)
struct page *hpage = compound_head(page); struct page *hpage = compound_head(page);
if (!PageHuge(page) && PageTransHuge(hpage)) { if (!PageHuge(page) && PageTransHuge(hpage)) {
lock_page(hpage); lock_page(page);
if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) { if (!PageAnon(page) || unlikely(split_huge_page(page))) {
unlock_page(hpage); unlock_page(page);
if (!PageAnon(hpage)) if (!PageAnon(page))
pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page)); pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page));
else else
pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page)); pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page));
put_hwpoison_page(hpage); put_hwpoison_page(page);
return -EBUSY; return -EBUSY;
} }
unlock_page(hpage); unlock_page(page);
get_hwpoison_page(page);
put_hwpoison_page(hpage);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册