From: Khalid Aziz <khalid.aziz@oracle.com>
To: Jann Horn <jannh@google.com>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>
Cc: "Michal Hocko" <mhocko@suse.com>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Russell King - ARM Linux" <linux@armlinux.org.uk>,
"Andrea Arcangeli" <aarcange@redhat.com>,
"Florian Weimer" <fweimer@redhat.com>,
"John Hubbard" <jhubbard@nvidia.com>,
"Matthew Wilcox" <willy@infradead.org>,
"Abdul Haleem" <abdhalee@linux.vnet.ibm.com>,
"Joel Stanley" <joel@jms.id.au>,
"Kees Cook" <keescook@chromium.org>,
"Jason Evans" <jasone@google.com>,
"David Goldblatt" <davidtgoldblatt@gmail.com>,
"Edward Tomasz Napierała" <trasz@FreeBSD.org>,
"Anshuman Khandual" <khandual@linux.vnet.ibm.com>,
"Daniel Micay" <danielmicay@gmail.com>
Subject: Re: [PATCH] mm: don't clobber partially overlapping VMA with MAP_FIXED_NOREPLACE
Date: Mon, 15 Oct 2018 01:47:58 -0600 [thread overview]
Message-ID: <bf9a1b9e-1a5d-4e89-62d5-53d8f7c84849@oracle.com> (raw)
In-Reply-To: <20181010152736.99475-1-jannh@google.com>
On 10/10/2018 09:27 AM, Jann Horn wrote:
> Daniel Micay reports that attempting to use MAP_FIXED_NOREPLACE in an
> application causes that application to randomly crash. The existing check
> for handling MAP_FIXED_NOREPLACE looks up the first VMA that either
> overlaps or follows the requested region, and then bails out if that VMA
> overlaps *the start* of the requested region. It does not bail out if the
> VMA only overlaps another part of the requested region.
>
> Fix it by checking that the found VMA only starts at or after the end of
> the requested region, in which case there is no overlap.
>
> Reported-by: Daniel Micay <danielmicay@gmail.com>
> Fixes: a4ff8e8620d3 ("mm: introduce MAP_FIXED_NOREPLACE")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jann Horn <jannh@google.com>
> ---
> mm/mmap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 5f2b2b184c60..f7cd9cb966c0 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -1410,7 +1410,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
> if (flags & MAP_FIXED_NOREPLACE) {
> struct vm_area_struct *vma = find_vma(mm, addr);
>
> - if (vma && vma->vm_start <= addr)
> + if (vma && vma->vm_start < addr + len)
> return -EEXIST;
> }
>
>
Makes sense.
Reviewed-by: Khalid Aziz <khalid.aziz@oracle.com>
--
Khalid
prev parent reply other threads:[~2018-10-15 7:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 15:27 [PATCH] mm: don't clobber partially overlapping VMA with MAP_FIXED_NOREPLACE Jann Horn
2018-10-10 17:19 ` Michal Hocko
2018-10-10 17:26 ` Jann Horn
2018-10-10 17:38 ` Michal Hocko
2018-10-10 18:03 ` John Hubbard
2018-10-10 18:17 ` John Hubbard
2018-10-12 10:23 ` Michael Ellerman
2018-10-12 12:09 ` Jann Horn
2018-10-10 18:36 ` Kees Cook
2018-10-12 12:03 ` Vlastimil Babka
2018-10-15 7:47 ` Khalid Aziz [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=bf9a1b9e-1a5d-4e89-62d5-53d8f7c84849@oracle.com \
--to=khalid.aziz@oracle.com \
--cc=aarcange@redhat.com \
--cc=abdhalee@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=danielmicay@gmail.com \
--cc=davidtgoldblatt@gmail.com \
--cc=fweimer@redhat.com \
--cc=jannh@google.com \
--cc=jasone@google.com \
--cc=jhubbard@nvidia.com \
--cc=joel@jms.id.au \
--cc=keescook@chromium.org \
--cc=khandual@linux.vnet.ibm.com \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=mhocko@suse.com \
--cc=mpe@ellerman.id.au \
--cc=trasz@FreeBSD.org \
--cc=willy@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).