linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jann Horn <jannh@google.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Suren Baghdasaryan <surenb@google.com>
Subject: Re: linux-next: manual merge of the mm tree with Linus' tree
Date: Fri, 28 Jul 2023 10:00:47 +1000	[thread overview]
Message-ID: <20230728100047.4f9cd375@canb.auug.org.au> (raw)
In-Reply-To: <20230728092915.732d4115@canb.auug.org.au>

[-- Attachment #1: Type: text/plain, Size: 4391 bytes --]

Hi all,

On Fri, 28 Jul 2023 09:29:15 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> On Fri, 28 Jul 2023 09:18:49 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> >
> > Today's linux-next merge of the mm tree got a conflict in:
> > 
> >   mm/memory.c
> > 
> > between commit:
> > 
> >   657b5146955e ("mm: lock_vma_under_rcu() must check vma->anon_vma under vma lock")
> > 
> > from Linus' tree and commits:
> > 
> >   69f6bbd1317f ("mm: handle userfaults under VMA lock")
> >   a3bdf38e85aa ("mm: allow per-VMA locks on file-backed VMAs")
> > 
> > from the mm tree.
> > 
> > I fixed it up (I think, please check - see below) and can carry the fix
> > as necessary. This is now fixed as far as linux-next is concerned, but
> > any non trivial conflicts should be mentioned to your upstream
> > maintainer when your tree is submitted for merging.  You may also want
> > to consider cooperating with the maintainer of the conflicting tree to
> > minimise any particularly complex conflicts.
> > 
> > -- 
> > Cheers,
> > Stephen Rothwell
> > 
> > diff --cc mm/memory.c
> > index ca632b58f792,271982fab2b8..000000000000
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@@ -5392,32 -5597,18 +5597,21 @@@ retry
> >   	if (!vma)
> >   		goto inval;
> >   
> > - 	/* Only anonymous and tcp vmas are supported for now */
> > - 	if (!vma_is_anonymous(vma) && !vma_is_tcp(vma))
> >  -	/* find_mergeable_anon_vma uses adjacent vmas which are not locked */
> >  -	if (vma_is_anonymous(vma) && !vma->anon_vma)
> > --		goto inval;
> > --
> >   	if (!vma_start_read(vma))
> >   		goto inval;
> >   
> >  +	/*
> >  +	 * find_mergeable_anon_vma uses adjacent vmas which are not locked.
> >  +	 * This check must happen after vma_start_read(); otherwise, a
> >  +	 * concurrent mremap() with MREMAP_DONTUNMAP could dissociate the VMA
> >  +	 * from its anon_vma.
> >  +	 */
> > - 	if (unlikely(!vma->anon_vma && !vma_is_tcp(vma)))
> > - 		goto inval_end_read;
> > - 
> > - 	/*
> > - 	 * Due to the possibility of userfault handler dropping mmap_lock, avoid
> > - 	 * it for now and fall back to page fault handling under mmap_lock.
> > - 	 */
> > - 	if (userfaultfd_armed(vma))
> > ++	if (unlikely(vma_is_anonymous(vma) && !vma_is_tcp(vma)))
> >  +		goto inval_end_read;
> >  +
> >   	/* Check since vm_start/vm_end might change before we lock the VMA */
> >  -	if (unlikely(address < vma->vm_start || address >= vma->vm_end)) {
> >  -		vma_end_read(vma);
> >  -		goto inval;
> >  -	}
> >  +	if (unlikely(address < vma->vm_start || address >= vma->vm_end))
> >  +		goto inval_end_read;
> >   
> >   	/* Check if the VMA got isolated after we found it */
> >   	if (vma->detached) {  
> 
> Sorry, doesn't even build ... let me try that again.

I have gone with below.  Again, please check.

-- 
Cheers,
Stephen Rothwell

diff --cc mm/memory.c
index ca632b58f792,271982fab2b8..000000000000
--- a/mm/memory.c
+++ b/mm/memory.c
@@@ -5392,32 -5597,18 +5597,21 @@@ retry
  	if (!vma)
  		goto inval;
  
- 	/* Only anonymous and tcp vmas are supported for now */
- 	if (!vma_is_anonymous(vma) && !vma_is_tcp(vma))
 -	/* find_mergeable_anon_vma uses adjacent vmas which are not locked */
 -	if (vma_is_anonymous(vma) && !vma->anon_vma)
--		goto inval;
--
  	if (!vma_start_read(vma))
  		goto inval;
  
 +	/*
 +	 * find_mergeable_anon_vma uses adjacent vmas which are not locked.
 +	 * This check must happen after vma_start_read(); otherwise, a
 +	 * concurrent mremap() with MREMAP_DONTUNMAP could dissociate the VMA
 +	 * from its anon_vma.
 +	 */
- 	if (unlikely(!vma->anon_vma && !vma_is_tcp(vma)))
- 		goto inval_end_read;
- 
- 	/*
- 	 * Due to the possibility of userfault handler dropping mmap_lock, avoid
- 	 * it for now and fall back to page fault handling under mmap_lock.
- 	 */
- 	if (userfaultfd_armed(vma))
++	if (unlikely(vma_is_anonymous(vma) && !vma->anon_vma))
 +		goto inval_end_read;
 +
  	/* Check since vm_start/vm_end might change before we lock the VMA */
 -	if (unlikely(address < vma->vm_start || address >= vma->vm_end)) {
 -		vma_end_read(vma);
 -		goto inval;
 -	}
 +	if (unlikely(address < vma->vm_start || address >= vma->vm_end))
 +		goto inval_end_read;
  
  	/* Check if the VMA got isolated after we found it */
  	if (vma->detached) {

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2023-07-28  0:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-27 23:18 linux-next: manual merge of the mm tree with Linus' tree Stephen Rothwell
2023-07-27 23:29 ` Stephen Rothwell
2023-07-27 23:40   ` Suren Baghdasaryan
2023-07-27 23:50     ` Matthew Wilcox
2023-07-28  0:08       ` Suren Baghdasaryan
2023-07-28  0:00   ` Stephen Rothwell [this message]
2023-07-28  3:13     ` Matthew Wilcox
2023-07-27 23:49 ` Matthew Wilcox
2023-07-28  0:21   ` Stephen Rothwell
2023-07-28  0:23     ` Suren Baghdasaryan
2023-07-28  0:29       ` Stephen Rothwell
2023-07-28  0:30         ` Suren Baghdasaryan
  -- strict thread matches above, loose matches on Subject: below --
2023-07-06 22:54 Stephen Rothwell
2023-07-07  4:52 ` Baoquan He
2023-06-18 23:23 Stephen Rothwell
2023-06-19 20:25 ` Andrew Morton
2023-06-19 20:43 ` Will Deacon
2023-06-19 21:39   ` Andrew Morton
2023-06-20  9:43     ` Will Deacon
2023-06-20 15:00       ` Jain, Ayush
2023-02-24 23:39 Stephen Rothwell
2023-02-25  2:04 ` Andrew Morton
2023-02-25  7:13   ` Christian Brauner
2023-02-25 20:52     ` Andrew Morton
2023-02-27 10:18       ` Christian Brauner
2023-02-27 17:55         ` Andrew Morton
2022-11-07  2:52 Stephen Rothwell
2022-09-06  9:01 Stephen Rothwell
2022-09-06  9:21 ` Rolf Eike Beer
2022-05-26  6:09 Stephen Rothwell

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=20230728100047.4f9cd375@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=akpm@linux-foundation.org \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=surenb@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.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 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).