From: Eric Blake <eblake@redhat.com>
To: Michael Roth <mdroth@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, lcapitulino@redhat.com, famz@redhat.com,
qemu-stable@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/3] qapi: add visit_start_union and visit_end_union
Date: Thu, 11 Sep 2014 20:29:24 -0600 [thread overview]
Message-ID: <54125A84.6060503@redhat.com> (raw)
In-Reply-To: <1410477659-9163-2-git-send-email-mdroth@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1622 bytes --]
On 09/11/2014 05:20 PM, Michael Roth wrote:
> In some cases an input visitor might bail out on filling out a
> struct for various reasons, such as missing fields when running
> in strict mode. In the case of a QAPI Union type, this may lead
> to cases where the .kind field which encodes the union type
> is uninitialized. Subsequently, other visitors, such as the
> dealloc visitor, may use this .kind value as if it were
> initialized, leading to assumptions about the union type which
> in this case may lead to segfaults. For example, freeing an
> integer value.
>
>
> +bool visit_start_union(Visitor *v, bool data_present, Error **errp)
> +{
> + if (v->start_union) {
> + return v->start_union(v, data_present, errp);
> + }
> + return true;
> +}
Any rules on whether errp must be set if returning false, and must not
be set if returning true? If so, do we need a bool return, or is errp
sufficient?
> +++ b/scripts/qapi-visit.py
> @@ -357,6 +357,9 @@ void visit_type_%(name)s(Visitor *m, %(name)s **obj, const char *name, Error **e
> if (err) {
> goto out_obj;
> }
> + if (!visit_start_union(m, !!(*obj)->data, &err)) {
> + goto out_obj;
> + }
> switch ((*obj)->kind) {
and if there aren't rules, then a visitor that sets err but still
returns true would result in this code not exiting early, but passing an
already-set error into the switch, which is probably not desirable.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
next prev parent reply other threads:[~2014-09-12 2:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-11 23:20 [Qemu-devel] [PATCH 0/3] qapi: fix crash in dealloc visitor for union types Michael Roth
2014-09-11 23:20 ` [Qemu-devel] [PATCH 1/3] qapi: add visit_start_union and visit_end_union Michael Roth
2014-09-12 2:29 ` Eric Blake [this message]
2014-09-12 15:22 ` Michael Roth
2014-09-12 10:17 ` Paolo Bonzini
2014-09-12 15:34 ` Michael Roth
2014-09-12 15:39 ` Paolo Bonzini
2014-09-12 16:17 ` Michael Roth
2014-09-12 16:29 ` Paolo Bonzini
2014-09-12 18:28 ` Michael Roth
2014-09-11 23:20 ` [Qemu-devel] [PATCH 2/3] qapi: dealloc visitor, implement visit_start_union Michael Roth
2014-09-12 2:34 ` Eric Blake
2014-09-11 23:20 ` [Qemu-devel] [PATCH 3/3] tests: add QMP input visitor test for unions with no discriminator Michael Roth
2014-09-12 3:04 ` [Qemu-devel] [PATCH 4/3] qemu-iotests: Test missing "driver" key for blockdev-add Fam Zheng
2014-09-12 4:17 ` Eric Blake
2014-09-12 3:06 ` [Qemu-devel] [PATCH 0/3] qapi: fix crash in dealloc visitor for union types Fam Zheng
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=54125A84.6060503@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=famz@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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.