From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, kraxel@redhat.com,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PATCH 0/2] Fix use after free with mux
Date: Mon, 3 Oct 2016 13:47:02 +0400 [thread overview]
Message-ID: <20161003094704.18087-1-marcandre.lureau@redhat.com> (raw)
Hi,
When qemu with muxed monitor quits, it leads to invalid use after free:
valgrind qemu -chardev stdio,mux=on,id=char0 -mon chardev=char0,mode=control,default
==4306== Invalid read of size 8
==4306== at 0x8061D3: json_lexer_destroy (json-lexer.c:385)
==4306== by 0x7E39F8: json_message_parser_destroy (json-streamer.c:134)
==4306== by 0x3447F6: monitor_qmp_event (monitor.c:3908)
==4306== by 0x480153: mux_chr_send_event (qemu-char.c:630)
==4306== by 0x480694: mux_chr_event (qemu-char.c:734)
==4306== by 0x47F1E9: qemu_chr_be_event (qemu-char.c:205)
==4306== by 0x481207: fd_chr_close (qemu-char.c:1114)
==4306== by 0x481659: qemu_chr_close_stdio (qemu-char.c:1221)
==4306== by 0x486F07: qemu_chr_free (qemu-char.c:4146)
==4306== by 0x486F97: qemu_chr_delete (qemu-char.c:4154)
==4306== by 0x487E66: qemu_chr_cleanup (qemu-char.c:4678)
==4306== by 0x495A98: main (vl.c:4675)
==4306== Address 0x28439e90 is 112 bytes inside a block of size 240 free'd
==4306== at 0x4C2CD5A: free (vg_replace_malloc.c:530)
==4306== by 0x1E4CBF2D: g_free (in /usr/lib64/libglib-2.0.so.0.4800.2)
==4306== by 0x344DE9: monitor_cleanup (monitor.c:4058)
==4306== by 0x495A93: main (vl.c:4674)
==4306== Block was alloc'd at
==4306== at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
==4306== by 0x1E4CBE18: g_malloc (in /usr/lib64/libglib-2.0.so.0.4800.2)
==4306== by 0x344BF8: monitor_init (monitor.c:4021)
==4306== by 0x49063C: mon_init_func (vl.c:2417)
==4306== by 0x7FC6DE: qemu_opts_foreach (qemu-option.c:1116)
==4306== by 0x4954E0: main (vl.c:4473)
...
The following two patches fix this by unregistering the muxed chr handlers.
Marc-André Lureau (2):
char: update read handler in all cases
char: use a fixed idx for child muxed chr
qemu-char.c | 24 ++++++++++++++++--------
include/sysemu/char.h | 1 +
2 files changed, 17 insertions(+), 8 deletions(-)
--
2.10.0
next reply other threads:[~2016-10-03 9:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-03 9:47 Marc-André Lureau [this message]
2016-10-03 9:47 ` [Qemu-devel] [PATCH 1/2] char: update read handler in all cases Marc-André Lureau
2016-10-03 9:47 ` [Qemu-devel] [PATCH 2/2] char: use a fixed idx for child muxed chr Marc-André Lureau
2016-10-11 12:20 ` Claudio Imbrenda
2016-10-11 14:28 ` Marc-André Lureau
2016-10-11 16:18 ` Marc-André Lureau
2016-10-11 16:44 ` Daniel P. Berrange
2016-10-12 9:03 ` Marc-André Lureau
2016-10-03 9:56 ` [Qemu-devel] [PATCH 0/2] Fix use after free with mux Paolo Bonzini
2016-10-03 10:08 ` Marc-André Lureau
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=20161003094704.18087-1-marcandre.lureau@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=kraxel@redhat.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 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).