From: Paolo Bonzini <pbonzini@redhat.com>
To: Don Slutz <don.slutz@gmail.com>, qemu-devel@nongnu.org
Cc: Richard Henderson <rth@twiddle.net>,
Gonglei <arei.gonglei@huawei.com>,
Peter Crosthwaite <crosthwaite.peter@gmail.com>
Subject: Re: [Qemu-devel] [PATCH] exec: Stop using memory after free
Date: Tue, 1 Dec 2015 10:52:14 +0100 [thread overview]
Message-ID: <565D6DCE.5010707@redhat.com> (raw)
In-Reply-To: <1448921464-21845-1-git-send-email-Don.Slutz@Gmail.com>
On 30/11/2015 23:11, Don Slutz wrote:
> memory_region_unref(mr) can free memory.
>
> For example I got:
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x7f43280d4700 (LWP 4462)]
> 0x00007f43323283c0 in phys_section_destroy (mr=0x7f43259468b0)
> at /home/don/xen/tools/qemu-xen-dir/exec.c:1023
> 1023 if (mr->subpage) {
> (gdb) bt
> at /home/don/xen/tools/qemu-xen-dir/exec.c:1023
> at /home/don/xen/tools/qemu-xen-dir/exec.c:1034
> at /home/don/xen/tools/qemu-xen-dir/exec.c:2205
> (gdb) p mr
> $1 = (MemoryRegion *) 0x7f43259468b0
>
> And this change prevents this.
Great, thanks! I think this fixes also the problem that Gonglei was
seeing a few months ago. I'll queue it for 2.5.
BTW, since I have your attention, have you noticed my refresh/rewrite of
your SAS1068 patches? A review would be welcome.
Paolo
> Signed-off-by: Don Slutz <Don.Slutz@Gmail.com>
> ---
> exec.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/exec.c b/exec.c
> index de1cf19..0bf0a6e 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1064,9 +1064,11 @@ static uint16_t phys_section_add(PhysPageMap *map,
>
> static void phys_section_destroy(MemoryRegion *mr)
> {
> + bool have_sub_page = mr->subpage;
> +
> memory_region_unref(mr);
>
> - if (mr->subpage) {
> + if (have_sub_page) {
> subpage_t *subpage = container_of(mr, subpage_t, iomem);
> object_unref(OBJECT(&subpage->iomem));
> g_free(subpage);
>
next prev parent reply other threads:[~2015-12-01 9:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-30 22:11 [Qemu-devel] [PATCH] exec: Stop using memory after free Don Slutz
2015-12-01 9:52 ` Paolo Bonzini [this message]
2015-12-01 13:05 ` Gonglei (Arei)
2015-12-02 7:59 ` Gonglei (Arei)
2015-12-02 9:47 ` Paolo Bonzini
2015-12-02 22:01 ` Don Slutz
2015-12-02 22:04 ` Don Slutz
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=565D6DCE.5010707@redhat.com \
--to=pbonzini@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=crosthwaite.peter@gmail.com \
--cc=don.slutz@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).