linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Lorenzo Stoakes <lstoakes@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Rapoport <rppt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>
Subject: Re: [PATCH v2] mm: userfaultfd: avoid passing an invalid range to vma_merge()
Date: Wed, 17 May 2023 20:38:56 -0400	[thread overview]
Message-ID: <ZGVzoMBTq85xg1Hx@x1n> (raw)
In-Reply-To: <20230517225142.xbchqdmp6ma5wzkg@revolver>

On Wed, May 17, 2023 at 06:51:42PM -0400, Liam R. Howlett wrote:
> > Yes, IIUC that's what we want because vma_merge() just handles everything
> > there (including split, or say, vma range adjustments) if any !NULL
> > returned.
> 
> I don't get your use of split here. __vma_adjust() used to be used by
> split, but it never split a VMA.  vma_merge() is not used by split at
> all.

I guess maybe I just made it confusing somehow when using "split" here..

I meant the vma range adjustments when vma_merge(), so indeed it's not
really a split, but it's still a logical split to me.

To be explicit, taking example of the uffd unregister case that was
essentially case 4, where part of PPPP will be "split" out and merged with
NNNN:

        ****
        PPPPPPNNNNNN
        might become
        PPNNNNNNNNNN
        case 4 below

        if (prev && addr < prev->vm_end) {	/* case 4 */
                vma_end = addr;
                adjust = next;
                adj_start = -(prev->vm_end - addr);
                err = dup_anon_vma(next, prev);
                ...
        } 

PPPP is adjusted here (where I was trying to refer as a "split", because
vma_end is less than before so part of PPPP is cut out):

	vma->vm_start = vma_start;
	vma->vm_end = vma_end;
	vma->vm_pgoff = vma_pgoff;

NNNN adjusted here (where the "split" part merged into NNNN):

	if (adj_start) {
		adjust->vm_start += adj_start;
		adjust->vm_pgoff += adj_start >> PAGE_SHIFT;
                ...
	}

I'll remember to stop using the word "split" in these cases in the future
to avoid confusion.

Thanks,

-- 
Peter Xu



  reply	other threads:[~2023-05-18  0:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-15 19:32 Lorenzo Stoakes
2023-05-15 20:23 ` Liam R. Howlett
2023-05-15 21:27 ` Peter Xu
2023-05-15 22:04   ` Lorenzo Stoakes
2023-05-15 23:07     ` Lorenzo Stoakes
2023-05-16 15:06       ` Peter Xu
2023-05-16 16:49         ` Liam R. Howlett
2023-05-16 20:12           ` Peter Xu
2023-05-16 22:52             ` Liam R. Howlett
2023-05-17 13:50               ` Peter Xu
2023-05-17 22:51                 ` Liam R. Howlett
2023-05-18  0:38                   ` Peter Xu [this message]
2023-05-16 19:25         ` Lorenzo Stoakes
2023-05-16 20:30           ` Peter Xu
2023-05-16 21:01             ` Lorenzo Stoakes
2023-05-16 21:39               ` Peter Xu
2023-05-16 22:15                 ` Lorenzo Stoakes
2023-05-16 22:32                   ` Peter Xu
2023-05-17  6:21                     ` Lorenzo Stoakes
2023-05-16 22:38                 ` Liam R. Howlett
2023-05-16 22:51                   ` Peter Xu
2023-05-16 22:53                     ` Liam R. Howlett
2023-05-15 21:39 ` Peter Xu
2023-05-15 22:10   ` Lorenzo Stoakes

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=ZGVzoMBTq85xg1Hx@x1n \
    --to=peterx@redhat.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lstoakes@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=rppt@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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