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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <11a9744a-e7f-33d0-474-c2f2eb7e079@google.com>
Date:   Fri, 9 Jun 2023 13:11:18 -0700 (PDT)
From:   Hugh Dickins <hughd@...gle.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
cc:     Hugh Dickins <hughd@...gle.com>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Mike Rapoport <rppt@...nel.org>,
        "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Matthew Wilcox <willy@...radead.org>,
        David Hildenbrand <david@...hat.com>,
        Suren Baghdasaryan <surenb@...gle.com>,
        Qi Zheng <zhengqi.arch@...edance.com>,
        Yang Shi <shy828301@...il.com>,
        Mel Gorman <mgorman@...hsingularity.net>,
        Peter Xu <peterx@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Will Deacon <will@...nel.org>, Yu Zhao <yuzhao@...gle.com>,
        Alistair Popple <apopple@...dia.com>,
        Ralph Campbell <rcampbell@...dia.com>,
        Ira Weiny <ira.weiny@...el.com>,
        Steven Price <steven.price@....com>,
        SeongJae Park <sj@...nel.org>,
        Lorenzo Stoakes <lstoakes@...il.com>,
        Huang Ying <ying.huang@...el.com>,
        Naoya Horiguchi <naoya.horiguchi@....com>,
        Christophe Leroy <christophe.leroy@...roup.eu>,
        Zack Rusin <zackr@...are.com>, Jason Gunthorpe <jgg@...pe.ca>,
        Axel Rasmussen <axelrasmussen@...gle.com>,
        Anshuman Khandual <anshuman.khandual@....com>,
        Pasha Tatashin <pasha.tatashin@...een.com>,
        Miaohe Lin <linmiaohe@...wei.com>,
        Minchan Kim <minchan@...nel.org>,
        Christoph Hellwig <hch@...radead.org>,
        Song Liu <song@...nel.org>,
        Thomas Hellstrom <thomas.hellstrom@...ux.intel.com>,
        Ryan Roberts <ryan.roberts@....com>,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH v2 28/32] mm/memory: allow pte_offset_map[_lock]() to
 fail

On Fri, 9 Jun 2023, Andrew Morton wrote:
> On Thu, 8 Jun 2023 18:43:38 -0700 (PDT) Hugh Dickins <hughd@...gle.com> wrote:
> 
> > copy_pte_range(): use pte_offset_map_nolock(), and allow for it to fail;
> > but with a comment on some further assumptions that are being made there.
> > 
> > zap_pte_range() and zap_pmd_range(): adjust their interaction so that
> > a pte_offset_map_lock() failure in zap_pte_range() leads to a retry in
> > zap_pmd_range(); remove call to pmd_none_or_trans_huge_or_clear_bad().
> > 
> > Allow pte_offset_map_lock() to fail in many functions.  Update comment
> > on calling pte_alloc() in do_anonymous_page().  Remove redundant calls
> > to pmd_trans_unstable(), pmd_devmap_trans_unstable(), pmd_none() and
> > pmd_bad(); but leave pmd_none_or_clear_bad() calls in free_pmd_range()
> > and copy_pmd_range(), those do simplify the next level down.
> > 
> > ...
> >
> > @@ -3728,11 +3737,9 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
> >  			vmf->page = pfn_swap_entry_to_page(entry);
> >  			vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd,
> >  					vmf->address, &vmf->ptl);
> > -			if (unlikely(!pte_same(*vmf->pte, vmf->orig_pte))) {
> > -				spin_unlock(vmf->ptl);
> > -				goto out;
> > -			}
> > -
> > +			if (unlikely(!vmf->pte ||
> > +				     !pte_same(*vmf->pte, vmf->orig_pte)))
> > +				goto unlock;
> >  			/*
> >  			 * Get a page reference while we know the page can't be
> >  			 * freed.
> 
> This hunk falls afoul of
> https://lkml.kernel.org/r/20230602092949.545577-5-ryan.roberts@arm.com.
> 
> I did this:
> 
> @@ -3729,7 +3738,8 @@ vm_fault_t do_swap_page(struct vm_fault
>  			vmf->page = pfn_swap_entry_to_page(entry);
>  			vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd,
>  					vmf->address, &vmf->ptl);
> -			if (unlikely(!pte_same(*vmf->pte, vmf->orig_pte)))
> +			if (unlikely(!vmf->pte ||
> +				     !pte_same(*vmf->pte, vmf->orig_pte)))
>  				goto unlock;
>  
>  			/*

Yes, that's exactly right: thanks, Andrew.

Hugh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ