From: Gonglei <arei.gonglei@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] exec: avoid possible overwriting of mmaped area in qemu_ram_remap
Date: Thu, 26 Mar 2015 10:26:29 +0800 [thread overview]
Message-ID: <55136E55.9000703@huawei.com> (raw)
In-Reply-To: <1427289352-6680-1-git-send-email-pbonzini@redhat.com>
On 2015/3/25 21:15, Paolo Bonzini wrote:
> It is not necessary to munmap an area before remapping it with MAP_FIXED;
> if the memory region specified by addr and len overlaps pages of any
> existing mapping, then the overlapped part of the existing mapping will
> be discarded.
>
Yes, it is.
> On the other hand, if QEMU does munmap the pages, there is a small
> probability that another mmap sneaks in and catches the just-freed
> portion of the address space. In effect, munmap followed by
> mmap(MAP_FIXED) is a use-after-free error, and Coverity flags it
> as such. Fix it.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> Please review. :)
>
> exec.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/exec.c b/exec.c
> index 8b922db..6d1e1e4 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1638,7 +1638,6 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
> abort();
> } else {
> flags = MAP_FIXED;
> - munmap(vaddr, length);
> if (block->fd >= 0) {
> flags |= (block->flags & RAM_SHARED ?
> MAP_SHARED : MAP_PRIVATE);
>
Looks good to me, so
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
prev parent reply other threads:[~2015-03-26 2:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-25 13:15 [Qemu-devel] [PATCH] exec: avoid possible overwriting of mmaped area in qemu_ram_remap Paolo Bonzini
2015-03-26 2:26 ` Gonglei [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=55136E55.9000703@huawei.com \
--to=arei.gonglei@huawei.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.