]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/lock: syndrome bits don't work on ESX
authorVMware, Inc <>
Mon, 21 Nov 2011 23:59:21 +0000 (15:59 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 21 Nov 2011 23:59:21 +0000 (15:59 -0800)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/lock/ul.c
open-vm-tools/lib/lock/ulInt.h

index be7a703f5530cc7cc24155822f7a852f3e85e18b..5b0e28e02afee5f661ea9d7a2ef1431a4fb05392 100644 (file)
@@ -123,8 +123,39 @@ MXUserSyndrome(void)
    syndrome = Atomic_Read(&syndromeMem);
 
    if (syndrome == 0) {
-      while (Random_Crypto(sizeof syndrome, &syndrome) && (syndrome == 0))
-         ;
+#if defined(VMX86_SERVER)
+      /*
+       * On ESX Random_Crypto may hang (PR 787027). Ask for the time, in
+       * seconds since the epoch.
+       *
+       * XXX PR filed to get ESX to fix this.
+       */
+
+      syndrome = time(NULL) & 0xFFFFFFFF;
+#else
+      uint32 retries = 25;
+
+      /*
+       * Do not assume that the source of bits from the host OS are sane.
+       * Perhaps its random bits service is not working or always returns
+       * zero or something is misconfigured. Only perform a small number
+       * of retries attempting to appropriate the required bits.
+       */
+
+      do {
+         /* Only changes syndrome on success. No need to check for errors */
+         Random_Crypto(sizeof syndrome, &syndrome);
+
+         if (syndrome != 0) {
+            break;
+         }
+      } while (retries--);
+#endif
+
+      /*
+       * If the source was unable to provide the appropriate bits, switch
+       * to plan B.
+       */
 
       if (syndrome == 0) {
          syndrome++;  // Fudge in case of failure
@@ -134,9 +165,10 @@ MXUserSyndrome(void)
       Atomic_ReadIfEqualWrite(&syndromeMem, 0, syndrome);
 
       syndrome = Atomic_Read(&syndromeMem);
-      ASSERT(syndrome);
    }
 
+   ASSERT(syndrome);
+
    return syndrome;
 }
 #endif
@@ -163,7 +195,8 @@ MXUserGetSignature(MXUserObjectType objectType)  // IN:
 {
    uint32 signature;
 
-   ASSERT((objectType != MXUSER_TYPE_NEVER_USE) && (objectType < 16));
+   ASSERT((objectType >= 0) && (objectType < 16) &&
+          (objectType != MXUSER_TYPE_NEVER_USE));
 
 #if defined(MXUSER_SYNDROME)
    /*
index 6bdcc0d677de34c03d539ccf13ef488c725ae2f5..fba801f9a7d847e332ac7f77aaba210158d9abcc 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "safetime.h"
 #include <errno.h>
 
 #if defined(_WIN32)