From: "PaX Team" <pageexec@freemail.hu>
To: Kees Cook <keescook@chromium.org>, Rik van Riel <riel@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Michel Lespinasse <walken@google.com>,
Cyrill Gorcunov <gorcunov@openvz.org>,
Hugh Dickins <hughd@google.com>,
linux-mm@kvack.org, Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH] mm: fix use-after-free in sys_remap_file_pages
Date: Fri, 13 Dec 2013 12:10:17 +0100 [thread overview]
Message-ID: <52AAEB19.27706.CCB8B7D@pageexec.freemail.hu> (raw)
In-Reply-To: <20131212224118.17a951c2@annuminas.surriel.com>
On 12 Dec 2013 at 22:41, Rik van Riel wrote:
> If the vma has been freed by the time the code jumps to the
> out label (because it was freed by a function called from
> mmap_region), surely it will also already have been freed
> by the time this patch dereferences it?
oops, yes, i meant to save the flags away before mmap_region,
no idea how i ended up with this ;).
> Also, setting vma = NULL to avoid the if (vma) branch at
> the out: label is unnecessarily obfuscated. Lets make things
> clear by documenting what is going on, and having a label
> after that dereference.
on that note, how about this as well:
> --- a/mm/fremap.c
> +++ b/mm/fremap.c
> @@ -203,6 +203,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
> if (mapping_cap_account_dirty(mapping)) {
> unsigned long addr;
> struct file *file = get_file(vma->vm_file);
> + vm_flags = vma->vm_flags;
>
> addr = mmap_region(file, start, size,
> vma->vm_flags, pgoff);
^^^^^^^^^^^^^
pass in vm_flags instead of vma->vm_flags just to prevent someone
from 'optimizing' away the read in the future?
> @@ -213,7 +214,8 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
> BUG_ON(addr != start);
> err = 0;
> }
> - goto out;
> + /* mmap_region may have freed vma */
> + goto out_freed;
perhaps {copy,move} this comment above the previous hunk since that's
where the relevant action is?
cheers,
PaX Team
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-12-13 11:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-12 22:07 Kees Cook
2013-12-13 3:41 ` Rik van Riel
2013-12-13 6:24 ` Cyrill Gorcunov
2013-12-13 11:10 ` PaX Team [this message]
2013-12-13 14:43 ` [PATCH -v2] " Rik van Riel
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=52AAEB19.27706.CCB8B7D@pageexec.freemail.hu \
--to=pageexec@freemail.hu \
--cc=akpm@linux-foundation.org \
--cc=dvyukov@google.com \
--cc=gorcunov@openvz.org \
--cc=hughd@google.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=riel@redhat.com \
--cc=walken@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