render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
2ba5aa
From 32957eca8129f926d205310ee7efbc1168e8ebdc Mon Sep 17 00:00:00 2001
2ba5aa
Message-Id: <32957eca8129f926d205310ee7efbc1168e8ebdc@dist-git>
2ba5aa
From: Marc Hartmayer <mhartmay@linux.ibm.com>
2ba5aa
Date: Thu, 8 Oct 2020 11:07:00 -0400
2ba5aa
Subject: [PATCH] udevProcessCSS: Check if def->driver is non-NULL
2ba5aa
2ba5aa
Don't process subchannel devices where `def->driver` is not set. This
2ba5aa
fixes the following segfault:
2ba5aa
2ba5aa
Thread 21 "nodedev-init" received signal SIGSEGV, Segmentation fault.
2ba5aa
[Switching to Thread 0x3ffb08fc910 (LWP 64303)]
2ba5aa
(gdb) bt
2ba5aa
 #0  0x000003fffd1272b4 in __strcmp_vx () at /lib64/libc.so.6
2ba5aa
 #1  0x000003ffc260c3a8 in udevProcessCSS (device=0x3ff9018d130, def=0x3ff90194a90)
2ba5aa
 #2  0x000003ffc260cb78 in udevGetDeviceDetails (device=0x3ff9018d130, def=0x3ff90194a90)
2ba5aa
 #3  0x000003ffc260d126 in udevAddOneDevice (device=0x3ff9018d130)
2ba5aa
 #4  0x000003ffc260d414 in udevProcessDeviceListEntry (udev=0x3ffa810d800, list_entry=0x3ff90001990)
2ba5aa
 #5  0x000003ffc260d638 in udevEnumerateDevices (udev=0x3ffa810d800)
2ba5aa
 #6  0x000003ffc260e08e in nodeStateInitializeEnumerate (opaque=0x3ffa810d800)
2ba5aa
 #7  0x000003fffdaa14b6 in virThreadHelper (data=0x3ffa810df00)
2ba5aa
 #8  0x000003fffc309ed6 in start_thread ()
2ba5aa
 #9  0x000003fffd185e66 in thread_start ()
2ba5aa
(gdb) p *def
2ba5aa
$2 = {
2ba5aa
  name = 0x0,
2ba5aa
  sysfs_path = 0x3ff90198e80 "/sys/devices/css0/0.0.ff40",
2ba5aa
  parent = 0x0,
2ba5aa
  parent_sysfs_path = 0x0,
2ba5aa
  parent_wwnn = 0x0,
2ba5aa
  parent_wwpn = 0x0,
2ba5aa
  parent_fabric_wwn = 0x0,
2ba5aa
  driver = 0x0,
2ba5aa
  devnode = 0x0,
2ba5aa
  devlinks = 0x3ff90194670,
2ba5aa
  caps = 0x3ff90194380
2ba5aa
}
2ba5aa
2ba5aa
Fixes: 05e6cdafa6e0 ("node_device: detect CSS devices")
2ba5aa
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2ba5aa
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2ba5aa
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
2ba5aa
(cherry picked from commit cb09344a2cccc0cc9bcefa3cb53d7af45ba92631)
2ba5aa
https://bugzilla.redhat.com/show_bug.cgi?id=1853289
2ba5aa
https://bugzilla.redhat.com/show_bug.cgi?id=1865932
2ba5aa
Message-Id: <20201008150700.52157-6-bfiuczyn@redhat.com>
2ba5aa
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2ba5aa
---
2ba5aa
 src/node_device/node_device_udev.c | 5 +++--
2ba5aa
 1 file changed, 3 insertions(+), 2 deletions(-)
2ba5aa
2ba5aa
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
2ba5aa
index b6b28bc35a..88cf1edf50 100644
2ba5aa
--- a/src/node_device/node_device_udev.c
2ba5aa
+++ b/src/node_device/node_device_udev.c
2ba5aa
@@ -1130,8 +1130,9 @@ udevProcessCSS(struct udev_device *device,
2ba5aa
                virNodeDeviceDefPtr def)
2ba5aa
 {
2ba5aa
     /* only process IO subchannel and vfio-ccw devices to keep the list sane */
2ba5aa
-    if (STRNEQ(def->driver, "io_subchannel") &&
2ba5aa
-        STRNEQ(def->driver, "vfio_ccw"))
2ba5aa
+    if (!def->driver ||
2ba5aa
+        (STRNEQ(def->driver, "io_subchannel") &&
2ba5aa
+         STRNEQ(def->driver, "vfio_ccw")))
2ba5aa
         return -1;
2ba5aa
 
2ba5aa
     if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0)
2ba5aa
-- 
2ba5aa
2.28.0
2ba5aa