From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: maple-tree@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
linux-next@vger.kernel.org
Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
Sanan Hasanov <sanan.hasanov@Knights.ucf.edu>
Subject: [PATCH] mm/mremap: Fix vma iterator initialization
Date: Thu, 26 Jan 2023 16:20:11 -0500 [thread overview]
Message-ID: <20230126212011.980350-1-Liam.Howlett@oracle.com> (raw)
The vma iterator location is incorrect when there is a failure in the
move_vma() function which alters the address being modified.
Delay the initialization of the vma iterator until the address is
stable.
Reported-by: Sanan Hasanov <sanan.hasanov@Knights.ucf.edu>
Link: https://lore.kernel.org/linux-mm/IA1PR07MB98306BC0F55667A760EABE91ABCE9@IA1PR07MB9830.namprd07.prod.outlook.com/
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
mm/mremap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Andrew,
This can be placed next to ("mm: change munmap splitting order and
move_vma()") and squashed before sending upstream.
diff --git a/mm/mremap.c b/mm/mremap.c
index 1bc81afd90de..6c7f49ab7d19 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -585,7 +585,7 @@ static unsigned long move_vma(struct vm_area_struct *vma,
unsigned long hiwater_vm;
int err = 0;
bool need_rmap_locks;
- VMA_ITERATOR(vmi, mm, old_addr);
+ struct vma_iterator vmi;
/*
* We'd prefer to avoid failure later on in do_munmap:
@@ -701,6 +701,7 @@ static unsigned long move_vma(struct vm_area_struct *vma,
return new_addr;
}
+ vma_iter_init(&vmi, mm, old_addr);
if (do_vmi_munmap(&vmi, mm, old_addr, old_len, uf_unmap, false) < 0) {
/* OOM: unable to split vma, just get accounts right */
if (vm_flags & VM_ACCOUNT && !(flags & MREMAP_DONTUNMAP))
--
2.39.0
reply other threads:[~2023-01-26 21:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230126212011.980350-1-Liam.Howlett@oracle.com \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-next@vger.kernel.org \
--cc=maple-tree@lists.infradead.org \
--cc=sanan.hasanov@Knights.ucf.edu \
/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
all inboxes | Powered by JetHome®