From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Brad Spengler <brad.spengler@opensrcsec.com>
Subject: Re: [PATCH] mm: abort vma_modify() on merge out of memory failure
Date: Sun, 23 Feb 2025 09:54:01 +0000 [thread overview]
Message-ID: <6cac23fc-d8c4-4315-a0e1-ab94f41fe3fb@lucifer.local> (raw)
In-Reply-To: <20250222172634.fecb3b5e5f74e310f4a94772@linux-foundation.org>
On Sat, Feb 22, 2025 at 05:26:34PM -0800, Andrew Morton wrote:
> On Sat, 22 Feb 2025 16:19:52 +0000 Lorenzo Stoakes <lorenzo.stoakes@oracle.com> wrote:
>
> > The remainder of vma_modify() relies upon the vmg state remaining pristine
> > after a merge attempt.
> >
>
> This patch is against your "mm: simplify vma merge structure and expand
> comments", presently in mm-unstable. I tweaked things (simple) so it
> applies to mainline:
Thanks that looks correct! Apologies, I ought to have accounted for the need for
this to be hotfix/backported and instead applied against mainline.
Cheers, Lorenzo
>
>
> --- a/mm/vma.c~mm-abort-vma_modify-on-merge-out-of-memory-failure
> +++ a/mm/vma.c
> @@ -1509,24 +1509,28 @@ int do_vmi_munmap(struct vma_iterator *v
> static struct vm_area_struct *vma_modify(struct vma_merge_struct *vmg)
> {
> struct vm_area_struct *vma = vmg->vma;
> + unsigned long start = vmg->start;
> + unsigned long end = vmg->end;
> struct vm_area_struct *merged;
>
> /* First, try to merge. */
> merged = vma_merge_existing_range(vmg);
> if (merged)
> return merged;
> + if (vmg_nomem(vmg))
> + return ERR_PTR(-ENOMEM);
>
> /* Split any preceding portion of the VMA. */
> - if (vma->vm_start < vmg->start) {
> - int err = split_vma(vmg->vmi, vma, vmg->start, 1);
> + if (vma->vm_start < start) {
> + int err = split_vma(vmg->vmi, vma, start, 1);
>
> if (err)
> return ERR_PTR(err);
> }
>
> /* Split any trailing portion of the VMA. */
> - if (vma->vm_end > vmg->end) {
> - int err = split_vma(vmg->vmi, vma, vmg->end, 0);
> + if (vma->vm_end > end) {
> + int err = split_vma(vmg->vmi, vma, end, 0);
>
> if (err)
> return ERR_PTR(err);
> _
>
prev parent reply other threads:[~2025-02-23 9:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-22 16:19 Lorenzo Stoakes
2025-02-23 1:26 ` Andrew Morton
2025-02-23 9:54 ` Lorenzo Stoakes [this message]
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=6cac23fc-d8c4-4315-a0e1-ab94f41fe3fb@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=brad.spengler@opensrcsec.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=stable@vger.kernel.org \
--cc=vbabka@suse.cz \
/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