linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lstoakes@gmail.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>
Cc: Suren Baghdasaryan <surenb@google.com>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	sidhartha.kumar@oracle.com, Matthew Wilcox <willy@infradead.org>,
	linux-fsdevel@vger.kernel.org, bpf@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 1/5] mm/mmap: Correctly position vma_iterator in __split_vma()
Date: Mon, 10 Jun 2024 13:09:01 +0100	[thread overview]
Message-ID: <119b01ac-a57a-43cf-90ca-093e850c4b7e@lucifer.local> (raw)
In-Reply-To: <20240531163217.1584450-2-Liam.Howlett@oracle.com>

On Fri, May 31, 2024 at 12:32:13PM -0400, Liam R. Howlett wrote:
> The vma iterator may be left pointing to the newly created vma.  This
> happens when inserting the new vma at the end of the old vma
> (!new_below).
>
> The incorrect position in the vma iterator is not exposed currently
> since the vma iterator is repositioned in the munmap path and is not
> reused in any of the other paths.
>
> This has limited impact in the current code, but is required for future
> changes.
>
> Fixes: b2b3b886738f ("mm: don't use __vma_adjust() in __split_vma()")
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> ---
>  mm/mmap.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 83b4682ec85c..31d464e6a656 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2442,6 +2442,9 @@ static int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma,
>  	/* Success. */
>  	if (new_below)
>  		vma_next(vmi);
> +	else
> +		vma_prev(vmi);
> +
>  	return 0;
>
>  out_free_mpol:
> --
> 2.43.0
>

Looks good to me.

As Suren alludes to, I agree that it's important to comment to indicate
that you want to move the iterator to point to the VMA that's been
shrunk rather than the newly inserted VMA.

Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>


  parent reply	other threads:[~2024-06-10 12:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-31 16:32 [RFC PATCH 0/5] Avoid MAP_FIXED gap exposure Liam R. Howlett
2024-05-31 16:32 ` [RFC PATCH 1/5] mm/mmap: Correctly position vma_iterator in __split_vma() Liam R. Howlett
2024-06-06  0:51   ` Suren Baghdasaryan
2024-06-07 14:25     ` Liam R. Howlett
2024-06-10 12:09   ` Lorenzo Stoakes [this message]
2024-05-31 16:32 ` [RFC PATCH 2/5] mm/mmap: Split do_vmi_align_munmap() into a gather and complete operation Liam R. Howlett
2024-06-07  0:14   ` Suren Baghdasaryan
2024-06-07 14:23     ` Liam R. Howlett
2024-05-31 16:32 ` [RFC PATCH 3/5] mm/mmap: Introduce vma_munmap_struct for use in munmap operations Liam R. Howlett
2024-06-07 14:38   ` Suren Baghdasaryan
2024-05-31 16:32 ` [RFC PATCH 4/5] mm/mmap: Change munmap to use vma_munmap_struct() for accounting and surrounding vmas Liam R. Howlett
2024-06-07 14:38   ` Suren Baghdasaryan
2024-06-07 15:24     ` Liam R. Howlett
2024-05-31 16:32 ` [RFC PATCH 5/5] mm/mmap: Use split munmap calls for MAP_FIXED Liam R. Howlett

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=119b01ac-a57a-43cf-90ca-093e850c4b7e@lucifer.local \
    --to=lstoakes@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sidhartha.kumar@oracle.com \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --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