From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Dan Williams <dan.j.williams@intel.com>,
Justin He <Justin.He@arm.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Jeff Moyer <jmoyer@redhat.com>
Subject: Re: [PATCH] mm: Avoid data corruption on CoW fault into PFN-mapped VMA
Date: Thu, 20 Feb 2020 15:06:21 +0300 [thread overview]
Message-ID: <20200220120621.m2mmgih6bdzoqbck@box> (raw)
In-Reply-To: <20200219132239.92a22479e4bff7ec73ae6bdb@linux-foundation.org>
On Wed, Feb 19, 2020 at 01:22:39PM -0800, Andrew Morton wrote:
> On Tue, 18 Feb 2020 18:41:51 +0300 "Kirill A. Shutemov" <kirill@shutemov.name> wrote:
>
> > Jeff Moyer has reported that one of xfstests triggers a warning when run
> > on DAX-enabled filesystem:
> >
> > WARNING: CPU: 76 PID: 51024 at mm/memory.c:2317 wp_page_copy+0xc40/0xd50
> > ...
> > wp_page_copy+0x98c/0xd50 (unreliable)
> > do_wp_page+0xd8/0xad0
> > __handle_mm_fault+0x748/0x1b90
> > handle_mm_fault+0x120/0x1f0
> > __do_page_fault+0x240/0xd70
> > do_page_fault+0x38/0xd0
> > handle_page_fault+0x10/0x30
> >
> > The warning happens on failed __copy_from_user_inatomic() which tries to
> > copy data into a CoW page.
> >
> > This happens because of race between MADV_DONTNEED and CoW page fault:
> >
> > CPU0 CPU1
> > handle_mm_fault()
> > do_wp_page()
> > wp_page_copy()
> > do_wp_page()
> > madvise(MADV_DONTNEED)
> > zap_page_range()
> > zap_pte_range()
> > ptep_get_and_clear_full()
> > <TLB flush>
> > __copy_from_user_inatomic()
> > sees empty PTE and fails
> > WARN_ON_ONCE(1)
> > clear_page()
> >
> > The solution is to re-try __copy_from_user_inatomic() under PTL after
> > checking that PTE is matches the orig_pte.
> >
> > The second copy attempt can still fail, like due to non-readable PTE,
> > but there's nothing reasonable we can do about, except clearing the CoW
> > page.
>
> You don't think this is worthy of a cc:stable?
Please, add it.
Although, if I read history correctly, it is 15 year old bug that nobody
noticed until we added WARN() there :/
--
Kirill A. Shutemov
prev parent reply other threads:[~2020-02-20 12:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 15:41 [PATCH] mm: Avoid data corruption on CoW fault into PFN-mapped VMA Kirill A. Shutemov
2020-02-19 21:22 ` Andrew Morton
2020-02-20 12:06 ` Kirill A. Shutemov [this message]
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=20200220120621.m2mmgih6bdzoqbck@box \
--to=kirill@shutemov.name \
--cc=Justin.He@arm.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=jmoyer@redhat.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.