From: Fam Zheng <famz@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: John Snow <jsnow@redhat.com>, qemu-devel@nongnu.org, ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qdev: Fix use after free in qdev_init_nofail error path
Date: Tue, 2 Aug 2016 16:17:47 +0800 [thread overview]
Message-ID: <20160802081747.GC2095@ad.usersys.redhat.com> (raw)
In-Reply-To: <20160802101453.418ab9c4@nial.brq.redhat.com>
On Tue, 08/02 10:14, Igor Mammedov wrote:
> On Tue, 2 Aug 2016 00:00:27 -0400
> John Snow <jsnow@redhat.com> wrote:
>
> > On 08/01/2016 11:41 PM, Fam Zheng wrote:
> > > Since 69382d8b (qdev: Fix object reference leak in case device.realize()
> > > fails), object_property_set_bool could release the object. The error
> > > path wants the type name, so hold an reference before realizing it.
> > >
> > > Cc: Igor Mammedov <imammedo@redhat.com>
> > > Signed-off-by: Fam Zheng <famz@redhat.com>
> > > ---
> > > hw/core/qdev.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> > > index ee4a083..5783442 100644
> > > --- a/hw/core/qdev.c
> > > +++ b/hw/core/qdev.c
> > > @@ -354,12 +354,14 @@ void qdev_init_nofail(DeviceState *dev)
> > >
> > > assert(!dev->realized);
> > >
> > > + object_ref(OBJECT(dev));
> > > object_property_set_bool(OBJECT(dev), true, "realized", &err);
> > > if (err) {
> > > error_reportf_err(err, "Initialization of device %s failed: ",
> > > object_get_typename(OBJECT(dev)));
> > > exit(1);
> > > }
> > > + object_unref(OBJECT(dev));
> > > }
> > >
> > > void qdev_machine_creation_done(void)
> > >
> >
> > Thanks :)
> >
> > (For the list: this fixes qcow2 iotest 051. This is for-2.7.)
> I don't see any error at 'make check' time,
> could you provide reproducer CLI?
It crashes for me with something as simple as:
$ qemu-system-x86_64 -drive if=ide
Fam
next prev parent reply other threads:[~2016-08-02 8:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-02 3:41 [Qemu-devel] [PATCH] qdev: Fix use after free in qdev_init_nofail error path Fam Zheng
2016-08-02 4:00 ` John Snow
2016-08-02 6:43 ` Paolo Bonzini
2016-08-02 8:14 ` Igor Mammedov
2016-08-02 8:17 ` Fam Zheng [this message]
2016-08-02 7:55 ` Igor Mammedov
2016-08-02 8:42 ` Fam Zheng
2016-08-02 13:05 ` Paolo Bonzini
2016-08-02 13:25 ` Igor Mammedov
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=20160802081747.GC2095@ad.usersys.redhat.com \
--to=famz@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=jsnow@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).