From d7d04cf9d931eef727d0349611ac22d7e59377c6 Mon Sep 17 00:00:00 2001
From: Oliver Kurth <okurth@vmware.com>
Date: Wed, 30 Oct 2019 11:18:23 -0700
Subject: [PATCH] Avoid securing disk device info for ZFS pools (at this time)

ZFS filesystem pools device names can appear as single directory name
at the root directory.  The current logic to locate the
/sys/class/blocks/<device> PCI structure based on typical device name
format will fail for ZFS pools.  As an immediate fix to the SIGSEGV,
avoid attempting to locate the PCI info; keep vmtoolsd running.

Addresses https://github.com/vmware/open-vm-tools/issues/378
---
 .../services/plugins/guestInfo/diskInfo.c         | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

--- a/open-vm-tools/services/plugins/guestInfo/diskInfo.c
+++ b/open-vm-tools/services/plugins/guestInfo/diskInfo.c
@@ -825,10 +825,19 @@ GuestInfoGetDiskDevice(const char *fsNam
 
       /* Not an LVM; check if a basic block device. */
       char blockDevPath[PATH_MAX];
+      const char *baseDevName = strrchr(fsName, '/');
 
-      Str_Snprintf(blockDevPath, PATH_MAX,  "%s/%s", LINUX_SYS_BLOCK_DIR,
-                   strrchr(fsName, '/') + 1);
-      GuestInfoLinuxBlockDevice(blockDevPath, partEntry, 1 /* first and only*/);
+      /*
+       * ZFS pools are not currently handled and may consist of a simple file
+       * name.  Neither situation can currently be handled in the PCI device
+       * lookup; avoid at this time.
+       */
+      if (baseDevName != NULL && strcmp(partEntry->fsType, "zfs") != 0) {
+         Str_Snprintf(blockDevPath, PATH_MAX,  "%s/%s", LINUX_SYS_BLOCK_DIR,
+                      baseDevName + 1);
+         /* First and only disk device. */
+         GuestInfoLinuxBlockDevice(blockDevPath, partEntry, 1);
+      }
    }
 
    /*
