linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: zhenwei pi <pizhenwei@bytedance.com>
Cc: naoya.horiguchi@nec.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/memory-failure: don't allow to unpoison hw corrupted page
Date: Sat, 4 Jun 2022 11:56:16 -0700	[thread overview]
Message-ID: <20220604115616.b7d5912ac5a37db608f67b78@linux-foundation.org> (raw)
In-Reply-To: <20220604103229.3378591-1-pizhenwei@bytedance.com>

On Sat,  4 Jun 2022 18:32:29 +0800 zhenwei pi <pizhenwei@bytedance.com> wrote:

> Currently unpoison_memory(unsigned long pfn) is designed for soft
> poison(hwpoison-inject) only. Unpoisoning a hardware corrupted page
> puts page back buddy only, this leads BUG during accessing on the
> corrupted KPTE.
> 
> Do not allow to unpoison hardware corrupted page in unpoison_memory()
> to avoid BUG like this:
> 
>  Unpoison: Software-unpoisoned page 0x61234
>  BUG: unable to handle page fault for address: ffff888061234000

Thanks.

> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2090,6 +2090,7 @@ int unpoison_memory(unsigned long pfn)
>  {
>  	struct page *page;
>  	struct page *p;
> +	pte_t *kpte;
>  	int ret = -EBUSY;
>  	int freeit = 0;
>  	static DEFINE_RATELIMIT_STATE(unpoison_rs, DEFAULT_RATELIMIT_INTERVAL,
> @@ -2101,6 +2102,13 @@ int unpoison_memory(unsigned long pfn)
>  	p = pfn_to_page(pfn);
>  	page = compound_head(p);
>  
> +	kpte = virt_to_kpte((unsigned long)page_to_virt(p));
> +	if (kpte && !pte_present(*kpte)) {
> +		unpoison_pr_info("Unpoison: Page was hardware poisoned %#lx\n",
> +				 pfn, &unpoison_rs);
> +		return -EPERM;
> +	}
> +
>  	mutex_lock(&mf_mutex);
>  
>  	if (!PageHWPoison(p)) {

I guess we don't want to let fault injection crash the kernel, so a
cc:stable seems appropriate here.

Can we think up a suitable Fixes: commit?  I'm suspecting this bug has
been there for a long time?



  reply	other threads:[~2022-06-04 18:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-04 10:32 [PATCH] mm/memory-failure: don't allow to unpoison hw corrupted page zhenwei pi
2022-06-04 18:56 ` Andrew Morton [this message]
2022-06-05  4:24   ` zhenwei pi
2022-06-06  4:32     ` HORIGUCHI NAOYA(堀口 直也)
2022-06-06  7:20       ` zhenwei pi
2022-06-06  9:15         ` HORIGUCHI NAOYA(堀口 直也)
2022-06-07 12:36           ` David Hildenbrand
2022-06-07 21:59             ` Andrew Morton
2022-06-07 23:43               ` HORIGUCHI NAOYA(堀口 直也)
2022-06-08  3:06                 ` zhenwei pi
2022-06-08  9:45               ` David Hildenbrand
2022-06-07 11:50 ` 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=20220604115616.b7d5912ac5a37db608f67b78@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@nec.com \
    --cc=pizhenwei@bytedance.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).