From: Catalin Marinas <catalin.marinas@arm.com>
To: Carlos Llamas <cmllamas@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@suse.com>,
Christian Brauner <brauner@kernel.org>,
linux-mm@kvack.org, bpf@vger.kernel.org, kernel-team@android.com,
Liam Howlett <liam.howlett@oracle.com>,
Suren Baghdasaryan <surenb@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] mm/mmap: undo ->mmap() when arch_validate_flags() fails
Date: Fri, 30 Sep 2022 10:59:36 +0100 [thread overview]
Message-ID: <Yza+CFDEl938+1Zf@arm.com> (raw)
In-Reply-To: <20220930003844.1210987-1-cmllamas@google.com>
On Fri, Sep 30, 2022 at 12:38:43AM +0000, Carlos Llamas wrote:
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 9d780f415be3..36c08e2c78da 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -1797,7 +1797,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
> if (!arch_validate_flags(vma->vm_flags)) {
> error = -EINVAL;
> if (file)
> - goto unmap_and_free_vma;
> + goto close_and_free_vma;
> else
> goto free_vma;
> }
> @@ -1844,6 +1844,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
>
> return addr;
>
> +close_and_free_vma:
> + if (vma->vm_ops && vma->vm_ops->close)
> + vma->vm_ops->close(vma);
> unmap_and_free_vma:
> fput(vma->vm_file);
> vma->vm_file = NULL;
The fix looks right to me but I'm not an mm expert. FWIW:
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
next prev parent reply other threads:[~2022-09-30 9:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 0:38 Carlos Llamas
2022-09-30 9:59 ` Catalin Marinas [this message]
2022-09-30 22:34 ` Andrii Nakryiko
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=Yza+CFDEl938+1Zf@arm.com \
--to=catalin.marinas@arm.com \
--cc=akpm@linux-foundation.org \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=kernel-team@android.com \
--cc=liam.howlett@oracle.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=stable@vger.kernel.org \
--cc=surenb@google.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