linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Bert Karwatzki <spasswolf@web.de>
To: "Liam R . Howlett" <Liam.Howlett@oracle.com>
Cc: Bert Karwatzki <spasswolf@web.de>,
	Suren Baghdasaryan <surenb@google.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Lorenzo Stoakes <lstoakes@gmail.com>,
	Matthew Wilcox <willy@infradead.org>,
	sidhartha.kumar@oracle.com,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Jiri Olsa <olsajiri@gmail.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Kees Cook <kees@kernel.org>, Jeff Xu <jeffxu@chromium.org>
Subject: [PATCH v5.1 01/19] mm/mmap: Correctly position vma_iterator in __split_vma()
Date: Fri, 16 Aug 2024 13:13:42 +0200	[thread overview]
Message-ID: <20240816111405.11793-2-spasswolf@web.de> (raw)
In-Reply-To: <20240816111405.11793-1-spasswolf@web.de>

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>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
---
 mm/vma.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/vma.c b/mm/vma.c
index 84965f2cd580..02e4f7cf489f 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -246,6 +246,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.45.2



  reply	other threads:[~2024-08-16 11:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-16 11:13 [PATCH v5.1 00/19] Rebase v5 patchset to next-20240816 Bert Karwatzki
2024-08-16 11:13 ` Bert Karwatzki [this message]
2024-08-16 11:13 ` [PATCH v5.1 02/19] mm/mmap: Introduce abort_munmap_vmas() Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 03/19] mm/mmap: Introduce vmi_complete_munmap_vmas() Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 04/19] mm/mmap: Extract the gathering of vmas from do_vmi_align_munmap() Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 05/19] mm/mmap: Introduce vma_munmap_struct for use in munmap operations Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 06/19] mm/mmap: Change munmap to use vma_munmap_struct() for accounting and surrounding vmas Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 07/19] mm/mmap: Extract validate_mm() from vma_complete() Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 08/19] mm/mmap: Inline munmap operation in mmap_region() Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 09/19] mm/mmap: Expand mmap_region() munmap call Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 10/19] mm/mmap: Support vma == NULL in init_vma_munmap() Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 11/19] mm/mmap: Reposition vma iterator in mmap_region() Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 12/19] mm/mmap: Track start and end of munmap in vma_munmap_struct Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 13/19] mm/mmap: Clean up unmap_region() argument list Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 14/19] mm/mmap: Avoid zeroing vma tree in mmap_region() Bert Karwatzki
2024-08-16 11:13 ` [PATCH v5.1 15/19] mm/mmap: Use PHYS_PFN " Bert Karwatzki
2024-08-16 11:33 ` [PATCH v5.1 00/19] Rebase v5 patchset to next-20240816 Lorenzo Stoakes
2024-08-16 11:55   ` Bert Karwatzki

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=20240816111405.11793-2-spasswolf@web.de \
    --to=spasswolf@web.de \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=jeffxu@chromium.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lstoakes@gmail.com \
    --cc=olsajiri@gmail.com \
    --cc=paulmck@kernel.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