[libvirt] [PATCH] qemu: Check sev capability pointer before using it

Peter Krempa pkrempa at redhat.com
Tue Aug 7 07:05:09 UTC 2018


On Tue, Aug 07, 2018 at 09:42:05 +0800, Han Han wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1612009
> 
> Check sev capability pointer in function qemuGetSEVInfoToParams to avoid
> null pointer dereferences.
> 
> Signed-off-by: Han Han <hhan at redhat.com>
> ---
>  src/qemu/qemu_driver.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index fb0d4a8c7a..3daaef586f 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -21452,6 +21452,12 @@ qemuGetSEVInfoToParams(virQEMUCapsPtr qemuCaps,
>  
>      virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1);
>  
> +    if (!sev) {
> +        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
> +                       _("SEV is not supported in this guest"));
> +        return -1;
> +    }

I presume the crash happens after restart of libvirtd. The real bug is
that qemuCaps don't serialize the sev data into the status XML thus the
pointer will be cleared and NULL after libvirtd restart.

The error message reported here is then wrong since the guest/host
support SEV but the data is not available.

The crash would not happen otherwise as the function is guarded by
checking QEMU_CAPS_SEV_GUEST.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180807/87c4f14b/attachment-0001.sig>


More information about the libvir-list mailing list