From: Eric Blake <eblake@redhat.com>
To: Murilo Opsfelder Araujo <muriloo@linux.vnet.ibm.com>,
qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, qemu-ppc@nongnu.org,
Max Reitz <mreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
R Nageswara Sastry <nasastry@in.ibm.com>,
qemu-stable <qemu-stable@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 1/1] block/nbd: fix segmentation fault when .desc is not null-terminated
Date: Fri, 5 Jan 2018 07:57:07 -0600 [thread overview]
Message-ID: <07c8789d-bebb-deed-b64c-806edf17f99c@redhat.com> (raw)
In-Reply-To: <20180105133241.14141-2-muriloo@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1821 bytes --]
On 01/05/2018 07:32 AM, Murilo Opsfelder Araujo wrote:
> The find_desc_by_name() from util/qemu-option.c relies on the .name not being
> NULL to call strcmp(). This check becomes unsafe when the list is not
> NULL-terminated, which is the case of nbd_runtime_opts in block/nbd.c, and can
> result in segmentation fault when strcmp() tries to access an invalid memory:
Thanks for the report and patch. Adding qemu-stable in cc.
>
> This patch fixes the segmentation fault in strcmp() by adding a NULL element at
> the end of nbd_runtime_opts.desc list, which is the common practice to most of
> other structs like runtime_opts in block/null.c. Thus, the desc[i].name != NULL
> check becomes safe because it will not evaluate to true when .desc list reached
> its end.
>
> Reported-by: R. Nageswara Sastry <nasastry@in.ibm.com>
> Buglink: https://bugs.launchpad.net/qemu/+bug/1727259
> Signed-off-by: Murilo Opsfelder Araujo <muriloo@linux.vnet.ibm.com>
I'll update the commit message to add in the commit id that introduced
the problem, as well as check that other QemuOptsList do not have a
similar problem; I'm queueing this on the NBD tree and will submit a
pull request soon.
Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
> block/nbd.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/block/nbd.c b/block/nbd.c
> index a50d24b50a..8b8ba56cdd 100644
> --- a/block/nbd.c
> +++ b/block/nbd.c
> @@ -388,6 +388,7 @@ static QemuOptsList nbd_runtime_opts = {
> .type = QEMU_OPT_STRING,
> .help = "ID of the TLS credentials to use",
> },
> + { /* end of list */ }
> },
> };
>
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2018-01-05 13:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-05 13:32 [Qemu-devel] [PATCH 0/1] qemu/nbd: fix segmentation fault when .desc is not null-terminated Murilo Opsfelder Araujo
2018-01-05 13:32 ` [Qemu-devel] [PATCH 1/1] block/nbd: " Murilo Opsfelder Araujo
2018-01-05 13:57 ` Eric Blake [this message]
2018-01-05 14:47 ` Murilo Opsfelder Araújo
2018-01-05 17:08 ` Eric Blake
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=07c8789d-bebb-deed-b64c-806edf17f99c@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=muriloo@linux.vnet.ibm.com \
--cc=nasastry@in.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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 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).