LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: <akpm@linux-foundation.org>, <naoya.horiguchi@nec.com>
Cc: <sfr@canb.auug.org.au>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, <linmiaohe@huawei.com>
Subject: [PATCH 2/4] mm/hwpoison: fix potential pte_unmap_unlock pte error
Date: Sat, 14 Aug 2021 18:51:29 +0800 [thread overview]
Message-ID: <20210814105131.48814-3-linmiaohe@huawei.com> (raw)
In-Reply-To: <20210814105131.48814-1-linmiaohe@huawei.com>
If the first pte is equal to poisoned_pfn, i.e. check_hwpoisoned_entry()
return 1, the wrong ptep - 1 would be passed to pte_unmap_unlock().
Fixes: ad9c59c24095 ("mm,hwpoison: send SIGBUS with error virutal address")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/memory-failure.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 052ec9ee7cf6..54f61133bf60 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -632,7 +632,7 @@ static int hwpoison_pte_range(pmd_t *pmdp, unsigned long addr,
{
struct hwp_walk *hwp = (struct hwp_walk *)walk->private;
int ret = 0;
- pte_t *ptep;
+ pte_t *ptep, *mapped_pte;
spinlock_t *ptl;
ptl = pmd_trans_huge_lock(pmdp, walk->vma);
@@ -645,14 +645,15 @@ static int hwpoison_pte_range(pmd_t *pmdp, unsigned long addr,
if (pmd_trans_unstable(pmdp))
goto out;
- ptep = pte_offset_map_lock(walk->vma->vm_mm, pmdp, addr, &ptl);
+ mapped_pte = ptep = pte_offset_map_lock(walk->vma->vm_mm, pmdp,
+ addr, &ptl);
for (; addr != end; ptep++, addr += PAGE_SIZE) {
ret = check_hwpoisoned_entry(*ptep, addr, PAGE_SHIFT,
hwp->pfn, &hwp->tk);
if (ret == 1)
break;
}
- pte_unmap_unlock(ptep - 1, ptl);
+ pte_unmap_unlock(mapped_pte, ptl);
out:
cond_resched();
return ret;
--
2.23.0
next prev parent reply other threads:[~2021-08-14 10:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-14 10:51 [PATCH 0/4] Cleanups and fixup for memcontrol Miaohe Lin
2021-08-14 10:51 ` [PATCH 1/4] mm/hwpoison: remove unneeded variable unmap_success Miaohe Lin
2021-08-17 7:28 ` HORIGUCHI NAOYA(堀口 直也)
2021-08-14 10:51 ` Miaohe Lin [this message]
2021-08-17 7:29 ` [PATCH 2/4] mm/hwpoison: fix potential pte_unmap_unlock pte error HORIGUCHI NAOYA(堀口 直也)
2021-08-17 8:24 ` Miaohe Lin
2021-08-17 23:37 ` HORIGUCHI NAOYA(堀口 直也)
2021-08-14 10:51 ` [PATCH 3/4] mm/hwpoison: change argument struct page **hpagep to *hpage Miaohe Lin
2021-08-17 7:28 ` HORIGUCHI NAOYA(堀口 直也)
2021-08-14 10:51 ` [PATCH 4/4] mm/hwpoison: fix some obsolete comments Miaohe Lin
2021-08-17 7:28 ` HORIGUCHI NAOYA(堀口 直也)
2021-08-14 11:00 ` [PATCH 0/4] Cleanups and fixup for memcontrol Miaohe Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210814105131.48814-3-linmiaohe@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
--cc=sfr@canb.auug.org.au \
--subject='Re: [PATCH 2/4] mm/hwpoison: fix potential pte_unmap_unlock pte error' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).