[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH 01/15] sheepdog: Defuse time bomb i
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH 01/15] sheepdog: Defuse time bomb in sd_open() error handling |
Date: |
Thu, 2 Mar 2017 16:46:08 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 03/02/2017 03:43 PM, Markus Armbruster wrote:
> When qemu_opts_absorb_qdict() fails, sd_open() closes stdin, because
> sd->fd is still zero. Fortunately, qemu_opts_absorb_qdict() can't
> fail, because:
>
> 1. it only fails when qemu_opt_parse() fails, and
> 2. the only member of runtime_opts.desc[] is a QEMU_OPT_STRING, and
> 3. qemu_opt_parse() can't fail for QEMU_OPT_STRING.
>
> Defuse this ticking time bomb by jumping behind the file descriptor
> cleanup on error.
>
> Also do that for the error paths where sd->fd is still -1. The file
> descriptor cleanup happens to do nothing then, but let's not rely on
> that here.
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> block/sheepdog.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> s->fd = get_sheep_fd(s, errp);
> if (s->fd < 0) {
> ret = s->fd;
> - goto out;
> + goto out_no_fd;
> }
Thanks to this change...
>
> ret = find_vdi_name(s, vdi, snapid, tag, &vid, true, errp);
> @@ -1472,6 +1472,7 @@ out:
> if (s->fd >= 0) {
...this 'if' is now always true, and you can unconditionally call
closesocket().
For that matter, the 'out:' label is a bit of a misnomer, since it is
only reached on errors.
> closesocket(s->fd);
> }
> +out_no_fd:
> qemu_opts_del(opts);
> g_free(buf);
> return ret;
>
The cleanup is correct, but looks like it can be more extensive.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-block] [PATCH 07/15] sheepdog: Report errors in pseudo-filename more usefully, (continued)
- [Qemu-block] [PATCH 11/15] gluster: Don't duplicate qapi-util.c's qapi_enum_parse(), Markus Armbruster, 2017/03/02
- [Qemu-block] [PATCH 10/15] gluster: Drop assumptions on SocketTransport names, Markus Armbruster, 2017/03/02
- [Qemu-block] [PATCH 01/15] sheepdog: Defuse time bomb in sd_open() error handling, Markus Armbruster, 2017/03/02
- Re: [Qemu-block] [Qemu-devel] [PATCH 01/15] sheepdog: Defuse time bomb in sd_open() error handling,
Eric Blake <=
- [Qemu-block] [PATCH 08/15] sheepdog: Use SocketAddress and socket_connect(), Markus Armbruster, 2017/03/02
- [Qemu-block] [PATCH 14/15] qapi-schema: Rename SocketAddressFlat's variant tcp to inet, Markus Armbruster, 2017/03/02
- [Qemu-block] [PATCH 13/15] qapi-schema: Rename GlusterServer to SocketAddressFlat, Markus Armbruster, 2017/03/02