[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZD6z3Af9LKO7pvN+@x1n>
Date: Tue, 18 Apr 2023 11:14:36 -0400
From: Peter Xu <peterx@...hat.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Mike Kravetz <mike.kravetz@...cle.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Mika Penttilä <mpenttil@...hat.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Nadav Amit <nadav.amit@...il.com>,
David Hildenbrand <david@...hat.com>,
linux-stable <stable@...r.kernel.org>
Subject: Re: [PATCH v2 2/6] mm/hugetlb: Fix uffd-wp bit lost when unsharing
happens
Hi, Andrew,
On Mon, Apr 17, 2023 at 04:48:22PM -0700, Andrew Morton wrote:
> On Mon, 17 Apr 2023 15:53:13 -0400 Peter Xu <peterx@...hat.com> wrote:
>
> > When we try to unshare a pinned page for a private hugetlb, uffd-wp bit can
> > get lost during unsharing. Fix it by carrying it over.
> >
> > This should be very rare, only if an unsharing happened on a private
> > hugetlb page with uffd-wp protected (e.g. in a child which shares the same
> > page with parent with UFFD_FEATURE_EVENT_FORK enabled).
>
> What are the user-visible consequences of the bug?
When above condition met, one can lose uffd-wp bit on the privately mapped
hugetlb page. It allows the page to be writable even if it should still be
wr-protected. I assume it can mean data loss.
However it's very hard to trigger. When I wrote the reproducer (provided in
the last patch) I needed to use the newest gup_test cmd introduced by David
to trigger it because I don't even know another way to do a proper RO
longerm pin.
Besides that, it needs a bunch of other conditions all met:
(1) hugetlb being mapped privately,
(2) userfaultfd registered with WP and EVENT_FORK,
(3) the user app fork()s, then,
(4) RO longterm pin onto a wr-protected anonymous page.
If it's not impossible to hit in production I'd say extremely rare.
>
> > Cc: linux-stable <stable@...r.kernel.org>
>
> When proposing a backport, it's better to present the patch as a
> standalone thing, against current -linus. I'll then queue it in
> mm-hotfixes and shall send it upstream during this -rc cycle.
>
> As presented, this patch won't go upstream until after 6.3 is released,
> and as it comes later in time, more backporting effort might be needed.
>
> I can rework things if this fix is reasonably urgent (the "user-visible
> consequences" info is the guide). If not urgent, we can leave things
> as they are.
IMHO it's not urgent so suitable for mm-unstable (current base of this set;
sorry if I forgot to mention it explicitly). I'll post (and remember to
post) patches on top of mm-stable if they're urgent, or e.g. bugs
introduced in current release.
I copied stable for the pure logic of fixing a bug in old kernels. The
consequence of hitting the bug is very bad but chance to hit is very low.
Thanks,
--
Peter Xu
Powered by blists - more mailing lists