[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6cac23fc-d8c4-4315-a0e1-ab94f41fe3fb@lucifer.local>
Date: Sun, 23 Feb 2025 09:54:01 +0000
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: "Liam R . Howlett" <Liam.Howlett@...cle.com>,
Vlastimil Babka <vbabka@...e.cz>, Jann Horn <jannh@...gle.com>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org, Brad Spengler <brad.spengler@...nsrcsec.com>
Subject: Re: [PATCH] mm: abort vma_modify() on merge out of memory failure
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@...cle.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);
> _
>
Powered by blists - more mailing lists