Index: /trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp	(revision 66572)
+++ /trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp	(revision 66573)
@@ -1658,33 +1658,38 @@
     {
 #ifdef SUP_HARDENED_SUID
+        /* Drop any root privileges we might be holding, this won't return
+           if it fails but end up calling supR3HardenedFatal[V]. */
+        supR3HardenedMainDropPrivileges();
+#endif
+        /* Close the driver, if we succeeded opening it.  Both because
+           TrustedError may be untrustworthy and because the driver deosn't
+           like us if we fork().  @bugref{8838} */
+        suplibOsTerm(&g_SupPreInitData.Data);
+
         /*
-         * Drop any root privileges we might be holding, this won't return
-         * if it fails but end up calling supR3HardenedFatal[V].
+         * Now try resolve and call the TrustedError entry point if we can find it.
+         * Note! Loader involved, so we must guard against loader hooks calling us.
          */
-        supR3HardenedMainDropPrivileges();
-#endif
-
-        /*
-         * Now try resolve and call the TrustedError entry point if we can
-         * find it.  We'll fork before we attempt this because that way the
-         * session management in main will see us exiting immediately (if
-         * it's involved with us).
-         */
+        static volatile bool s_fRecursive = false;
+        if (!s_fRecursive)
+        {
+            s_fRecursive = true;
+
+            PFNSUPTRUSTEDERROR pfnTrustedError = supR3HardenedMainGetTrustedError(g_pszSupLibHardenedProgName);
+            if (pfnTrustedError)
+            {
+                /* We'll fork before we make the call because that way the session management
+                   in main will see us exiting immediately (if it's involved with us) and possibly
+                   get an error back to the API / user. */
 #if !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
-        int pid = fork();
-        if (pid <= 0)
-#endif
-        {
-            static volatile bool s_fRecursive = false; /* Loader hooks may cause recursion. */
-            if (!s_fRecursive)
-            {
-                s_fRecursive = true;
-
-                PFNSUPTRUSTEDERROR pfnTrustedError = supR3HardenedMainGetTrustedError(g_pszSupLibHardenedProgName);
-                if (pfnTrustedError)
+                int pid = fork();
+                if (pid <= 0)
+#endif
+                {
                     pfnTrustedError(pszWhere, enmWhat, rc, pszMsgFmt, va);
-
-                s_fRecursive = false;
+                }
             }
+
+            s_fRecursive = false;
         }
     }
Index: /trunk/src/VBox/HostDrivers/Support/darwin/SUPLib-darwin.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/darwin/SUPLib-darwin.cpp	(revision 66572)
+++ /trunk/src/VBox/HostDrivers/Support/darwin/SUPLib-darwin.cpp	(revision 66573)
@@ -221,6 +221,4 @@
 
 
-#ifndef IN_SUP_HARDENED_R3
-
 int suplibOsTerm(PSUPLIBDATA pThis)
 {
@@ -254,4 +252,6 @@
 
 
+#ifndef IN_SUP_HARDENED_R3
+
 int suplibOsInstall(void)
 {
Index: /trunk/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp	(revision 66572)
+++ /trunk/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp	(revision 66573)
@@ -120,6 +120,4 @@
 
 
-#ifndef IN_SUP_HARDENED_R3
-
 int suplibOsTerm(PSUPLIBDATA pThis)
 {
@@ -136,4 +134,6 @@
 }
 
+
+#ifndef IN_SUP_HARDENED_R3
 
 int suplibOsInstall(void)
Index: /trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp	(revision 66572)
+++ /trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp	(revision 66573)
@@ -146,6 +146,4 @@
 
 
-#ifndef IN_SUP_HARDENED_R3
-
 int suplibOsTerm(PSUPLIBDATA pThis)
 {
@@ -163,4 +161,6 @@
 }
 
+
+#ifndef IN_SUP_HARDENED_R3
 
 int suplibOsInstall(void)
Index: /trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp	(revision 66572)
+++ /trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp	(revision 66573)
@@ -105,6 +105,4 @@
 
 
-#ifndef IN_SUP_HARDENED_R3
-
 int suplibOsTerm(PSUPLIBDATA pThis)
 {
@@ -122,4 +120,6 @@
 }
 
+
+#ifndef IN_SUP_HARDENED_R3
 
 int suplibOsInstall(void)
Index: /trunk/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp	(revision 66572)
+++ /trunk/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp	(revision 66573)
@@ -154,6 +154,4 @@
 
 
-#ifndef IN_SUP_HARDENED_R3
-
 int suplibOsTerm(PSUPLIBDATA pThis)
 {
@@ -183,4 +181,6 @@
 }
 
+
+#ifndef IN_SUP_HARDENED_R3
 
 int suplibOsInstall(void)
Index: /trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp	(revision 66572)
+++ /trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp	(revision 66573)
@@ -636,4 +636,5 @@
     return rc;
 }
+#endif /* !IN_SUP_HARDENED_R3 */
 
 
@@ -653,4 +654,6 @@
 }
 
+
+#ifndef IN_SUP_HARDENED_R3
 
 int suplibOsIOCtl(PSUPLIBDATA pThis, uintptr_t uFunction, void *pvReq, size_t cbReq)
