linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] mm/memory-failure.c: fix race with changing page compound again
Date: Tue, 8 Mar 2022 06:56:59 +0000	[thread overview]
Message-ID: <20220308065658.GA610534@hori.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <89af9b3f-1ab9-15db-d476-574271ce8292@oracle.com>

On Mon, Mar 07, 2022 at 11:07:32AM -0800, Mike Kravetz wrote:
...
> > 
> >> +
> >> +       /**
> >> +        * The page could have changed compound pages due to race window.
> >> +        * If this happens just bail out.
> >> +        */
> >> +       if (!PageHuge(p) || compound_head(p) != head) {
> >> +               action_result(pfn, MF_MSG_DIFFERENT_COMPOUND, MF_IGNORED);
> >> +               res = -EBUSY;
> >> +               goto out;
> >> +       }
> > 
> > Let me have one comment on the diff. The result code MF_MSG_DIFFERENT_COMPOUND
> > might not fit when PageHuge is false in the check (because it's no longer a
> > compound page).  Maybe you may invent another result code, or changes
> > MF_MSG_DIFFERENT_COMPOUND (for example) to MF_MSG_DIFFERENT_PAGE_SIZE?
> > 
> 
> Suppose we do encounter this race.  Also, suppose p != head.
> At the beginning of memory_failure_hugetlb, we do:
> 
> struct page *head = compound_head(p);
> ...
> if (TestSetPageHWPoison(head))
> 
> So, it could be that we set Poison in the 'head' page but the error was really
> in another page.  Is that correct?
> 
> Now with the race, head is not a huge page and the pages could even be on
> buddy.  Does this mean we could have poison set on the wrong page in buddy?

Correct, the race might be rare, but this needs a fix.
I think that setting PageHWPoison first (before taking refcount and page lock)
is the root of all related problems.  This behavior came from the original
concept in hwpoison that preventing consumption of corrupted data is the first
priority.  But now I think that this makes no sense if we have this kind of bugs.

I'll try to write a patch for this (I only fix memory_failure_hugetlb() first,
but generic path should be fixed later).
Thank you for pointing out.

- Naoya Horiguchi

  reply	other threads:[~2022-03-08  6:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28 14:02 [PATCH 0/4] A few fixup patches for memory failure Miaohe Lin
2022-02-28 14:02 ` [PATCH 1/4] mm/memory-failure.c: fix race with changing page compound again Miaohe Lin
2022-03-04  8:26   ` HORIGUCHI NAOYA(堀口 直也)
2022-03-04 19:32     ` Mike Kravetz
2022-03-07  3:44       ` Miaohe Lin
2022-03-07  7:01         ` HORIGUCHI NAOYA(堀口 直也)
2022-03-07 19:07           ` Mike Kravetz
2022-03-08  6:56             ` HORIGUCHI NAOYA(堀口 直也) [this message]
2022-03-08 11:28               ` Miaohe Lin
2022-02-28 14:02 ` [PATCH 2/4] mm/memory-failure.c: fix wrong user reference report Miaohe Lin
2022-03-04  8:27   ` HORIGUCHI NAOYA(堀口 直也)
2022-03-07 11:26     ` Miaohe Lin
2022-03-07 20:14       ` Yang Shi
2022-03-08 13:11         ` Miaohe Lin
2022-03-08 18:51           ` Yang Shi
2022-03-09  8:30             ` Miaohe Lin
2022-02-28 14:02 ` [PATCH 3/4] mm/memory-failure.c: avoid calling invalidate_inode_page() with unexpected pages Miaohe Lin
2022-02-28 14:02 ` [PATCH 4/4] mm/memory-failure.c: fix potential VM_BUG_ON_PAGE in split_huge_page_to_list Miaohe Lin
2022-03-04  8:28   ` HORIGUCHI NAOYA(堀口 直也)
2022-03-07  7:07     ` Miaohe Lin
2022-03-07 19:53       ` Yang Shi
2022-03-08 12:36         ` Miaohe Lin
2022-03-08 18:47           ` Yang Shi
2022-03-09  8:45             ` Miaohe Lin
2022-03-10 11:46             ` Miaohe Lin
2022-03-10 19:32               ` Yang Shi
2022-03-11  1:54                 ` 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=20220308065658.GA610534@hori.linux.bs1.fc.nec.co.jp \
    --to=naoya.horiguchi@nec.com \
    --cc=akpm@linux-foundation.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.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).