[libvirt] [PATCH 1/4] qemu: Tolerate storage source private data being NULL for hotplug SCSI hostdev

John Ferlan posted 4 patches 7 years, 5 months ago
[libvirt] [PATCH 1/4] qemu: Tolerate storage source private data being NULL for hotplug SCSI hostdev
Posted by John Ferlan 7 years, 5 months ago
Commit id 'c5c96545' neglected to validate that the srcPriv was
non-NULL before dereferencing. Similar problem to what was fixed
by commit id '8056721c' but missed during multiple rebases and
code reworks.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/qemu/qemu_hotplug.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 6ef28bf05..9317e134a 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2286,7 +2286,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
     virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
     virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
     qemuDomainStorageSourcePrivatePtr srcPriv;
-    qemuDomainSecretInfoPtr secinfo;
+    qemuDomainSecretInfoPtr secinfo = NULL;
 
     if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -2328,7 +2328,8 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
         goto cleanup;
 
     srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
-    secinfo = srcPriv->secinfo;
+    if (srcPriv)
+        secinfo = srcPriv->secinfo;
     if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
         if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0)
             goto cleanup;
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] qemu: Tolerate storage source private data being NULL for hotplug SCSI hostdev
Posted by Eric Farman 7 years, 5 months ago

On 12/06/2017 08:08 AM, John Ferlan wrote:
> Commit id 'c5c96545' neglected to validate that the srcPriv was
> non-NULL before dereferencing. Similar problem to what was fixed
> by commit id '8056721c' but missed during multiple rebases and
> code reworks.
> 
> Signed-off-by: John Ferlan <jferlan@redhat.com>

Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>

> ---
>   src/qemu/qemu_hotplug.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 6ef28bf05..9317e134a 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -2286,7 +2286,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
>       virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
>       virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
>       qemuDomainStorageSourcePrivatePtr srcPriv;
> -    qemuDomainSecretInfoPtr secinfo;
> +    qemuDomainSecretInfoPtr secinfo = NULL;
> 
>       if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
>           virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> @@ -2328,7 +2328,8 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
>           goto cleanup;
> 
>       srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
> -    secinfo = srcPriv->secinfo;
> +    if (srcPriv)
> +        secinfo = srcPriv->secinfo;
>       if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
>           if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0)
>               goto cleanup;
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] qemu: Tolerate storage source private data being NULL for hotplug SCSI hostdev
Posted by John Ferlan 7 years, 5 months ago

On 12/13/2017 10:06 AM, Eric Farman wrote:
> 
> 
> On 12/06/2017 08:08 AM, John Ferlan wrote:
>> Commit id 'c5c96545' neglected to validate that the srcPriv was
>> non-NULL before dereferencing. Similar problem to what was fixed
>> by commit id '8056721c' but missed during multiple rebases and
>> code reworks.
>>
>> Signed-off-by: John Ferlan <jferlan@redhat.com>
> 
> Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>
> 

Thanks - I went ahead and pushed this while the rest is being worked out.

Tks -

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list