render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
51d9a2
From 62d0406b726b0d62cb136924e7dce2a2fd364ec6 Mon Sep 17 00:00:00 2001
51d9a2
Message-Id: <62d0406b726b0d62cb136924e7dce2a2fd364ec6@dist-git>
51d9a2
From: Peter Krempa <pkrempa@redhat.com>
51d9a2
Date: Tue, 3 Jul 2018 16:48:38 +0200
51d9a2
Subject: [PATCH] qemu: hotplug: Don't access srcPriv when it's not allocated
51d9a2
51d9a2
The private data of a virStorageSource which is backing an iSCSI hostdev
51d9a2
may be NULL if no authentication is present. The code handling the
51d9a2
hotplug would attempt to extract the authentication info stored in
51d9a2
'secinfo' without checking if it is allocated which resulted in a crash.
51d9a2
51d9a2
Here we opt the easy way to check if srcPriv is not NULL so that we
51d9a2
don't duplicate all the logic which selects whether the disk source has
51d9a2
a secret.
51d9a2
51d9a2
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1597550
51d9a2
51d9a2
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
51d9a2
Reviewed-by: John Ferlan <jferlan@redhat.com>
51d9a2
(cherry picked from commit 33a475056fdd76c030528982e422bae79c0a0e4a)
51d9a2
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
51d9a2
---
51d9a2
 src/qemu/qemu_hotplug.c | 3 ++-
51d9a2
 1 file changed, 2 insertions(+), 1 deletion(-)
51d9a2
51d9a2
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
51d9a2
index fcd8eb0ffa..075f2fb72e 100644
51d9a2
--- a/src/qemu/qemu_hotplug.c
51d9a2
+++ b/src/qemu/qemu_hotplug.c
51d9a2
@@ -2240,7 +2240,8 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
51d9a2
     if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
51d9a2
         qemuDomainStorageSourcePrivatePtr srcPriv =
51d9a2
             QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(scsisrc->u.iscsi.src);
51d9a2
-        secinfo = srcPriv->secinfo;
51d9a2
+        if (srcPriv)
51d9a2
+            secinfo = srcPriv->secinfo;
51d9a2
     }
51d9a2
 
51d9a2
     if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
51d9a2
-- 
51d9a2
2.18.0
51d9a2