lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230327183438.GC4184@monkey>
Date:   Mon, 27 Mar 2023 11:34:38 -0700
From:   Mike Kravetz <mike.kravetz@...cle.com>
To:     Peter Xu <peterx@...hat.com>
Cc:     David Hildenbrand <david@...hat.com>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Mike Rapoport <rppt@...ux.vnet.ibm.com>,
        Nadav Amit <nadav.amit@...il.com>,
        Axel Rasmussen <axelrasmussen@...gle.com>,
        Andrea Arcangeli <aarcange@...hat.com>,
        Muhammad Usama Anjum <usama.anjum@...labora.com>,
        linux-stable <stable@...r.kernel.org>
Subject: Re: [PATCH v3] mm/hugetlb: Fix uffd wr-protection for CoW
 optimization path

On 03/26/23 10:46, Peter Xu wrote:
> On Fri, Mar 24, 2023 at 11:36:53PM +0100, David Hildenbrand wrote:
> > > > @@ -5487,6 +5487,17 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma,
> > > >   	unsigned long haddr = address & huge_page_mask(h);
> > > >   	struct mmu_notifier_range range;
> > > > +	/*
> > > > +	 * Never handle CoW for uffd-wp protected pages.  It should be only
> > > > +	 * handled when the uffd-wp protection is removed.
> > > > +	 *
> > > > +	 * Note that only the CoW optimization path (in hugetlb_no_page())
> > > > +	 * can trigger this, because hugetlb_fault() will always resolve
> > > > +	 * uffd-wp bit first.
> > > > +	 */
> > > > +	if (!unshare && huge_pte_uffd_wp(pte))
> > > > +		return 0;
> > > 
> > > This looks correct.  However, since the previous version looked correct I must
> > > ask.  Can we have unshare set and huge_pte_uffd_wp true?  If so, then it seems
> > > we would need to possibly propogate that uffd_wp to the new pte as in v2
> 
> Good point, thanks for spotting!
> 
> > 
> > We can. A reproducer would share an anon hugetlb page because parent and
> > child. In the parent, we would uffd-wp that page. We could trigger unsharing
> > by R/O-pinning that page.
> 
> Right.  This seems to be a separate bug..  It should be triggered in
> totally different context and much harder due to rare use of RO pins,
> meanwhile used with userfault-wp.
> 
> If both of you agree, I can prepare a separate patch for this bug, and I'll
> better prepare a reproducer/selftest with it.
> 

I am OK with separate patches, and agree that the R/O pinning case is less
likely to happen.

Since this patch addresses the issue found by Muhammad,

Reviewed-by: Mike Kravetz <mike.kravetz@...cle.com>
-- 
Mike Kravetz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ