linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Liam Howlett <liam.howlett@oracle.com>
To: "maple-tree@lists.infradead.org" <maple-tree@lists.infradead.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Qian Cai <quic_qiancai@quicinc.com>
Subject: Re: [PATCH] mm/mmap: Fix potential leak on do_mas_align_munmap()
Date: Fri, 13 May 2022 14:32:57 +0000	[thread overview]
Message-ID: <20220513143246.jfqvxwr6rejsdfou@revolver> (raw)
In-Reply-To: <20220513141548.2019143-1-Liam.Howlett@oracle.com>

* Liam Howlett <liam.howlett@oracle.com> [220513 10:16]:
> There is a leak when the system is low on resources and fails to
> allocate enough memory to complete the munmap task.  Fix this by adding
> the necessary free operations in the unwinding.
> 
> Fixes: a760774e7b7b (mm: start tracking VMAs with maple tree)

This is the wrong fixes.  It fixes "67/69 mm: remove the vma
linked list".


> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> ---
>  mm/mmap.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index ebfd71a79814..9d41df730b22 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2365,7 +2365,7 @@ do_mas_align_munmap(struct ma_state *mas, struct vm_area_struct *vma,
>  		return -ENOMEM;
>  
>  	if (mas_preallocate(&mas_detach, vma, GFP_KERNEL))
> -		return -ENOMEM;
> +		goto detach_alloc_fail;
>  
>  	mas->last = end - 1;
>  	/*
> @@ -2504,6 +2504,8 @@ do_mas_align_munmap(struct ma_state *mas, struct vm_area_struct *vma,
>  map_count_exceeded:
>  split_failed:
>  userfaultfd_error:
> +	mas_destroy(&mas_detach);
> +detach_alloc_fail:
>  	mas_destroy(mas);
>  	return error;
>  }
> -- 
> 2.35.1
> 

      reply	other threads:[~2022-05-13 14:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13 14:15 Liam Howlett
2022-05-13 14:32 ` Liam Howlett [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=20220513143246.jfqvxwr6rejsdfou@revolver \
    --to=liam.howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maple-tree@lists.infradead.org \
    --cc=quic_qiancai@quicinc.com \
    /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