VirtualBox

Changeset 53220 in vbox


Ignore:
Timestamp:
Nov 5, 2014 8:51:38 AM (10 years ago)
Author:
vboxsync
Message:

SUP: Relax image architecture restrictions so 32-bit resource DLLs won't cause unnecessary trouble in 64-bit processes. (untested)

Location:
trunk/src/VBox/HostDrivers/Support/win
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerify-win.h

    r53035 r53220  
    133133/** The file owner must be TrustedInstaller on Vista+. */
    134134#  define SUPHNTVI_F_TRUSTED_INSTALLER_OWNER        RT_BIT(4)
    135 /** Resource image, could be any bitness. */
    136 #  define SUPHNTVI_F_RESOURCE_IMAGE                 RT_BIT(30)
     135/** Ignore the image architecture (otherwise it must match the verification
     136 * code).  Used with resource images and such. */
     137#  define SUPHNTVI_F_IGNORE_ARCHITECTURE            RT_BIT(30)
    137138/** Raw-mode context image, always 32-bit. */
    138139#  define SUPHNTVI_F_RC_IMAGE                       RT_BIT(31)
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp

    r53042 r53220  
    12351235        RTLDRMOD hLdrMod;
    12361236        RTLDRARCH enmArch = fFlags & SUPHNTVI_F_RC_IMAGE ? RTLDRARCH_X86_32 : RTLDRARCH_HOST;
    1237         if (fFlags & SUPHNTVI_F_RESOURCE_IMAGE)
     1237        if (fFlags & SUPHNTVI_F_IGNORE_ARCHITECTURE)
    12381238            enmArch = RTLDRARCH_WHATEVER;
    12391239        rc = RTLdrOpenWithReader(&pNtViRdr->Core, RTLDR_O_FOR_VALIDATION, enmArch, &hLdrMod, pErrInfo);
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp

    r53036 r53220  
    18351835                    : SUPHNTVI_F_REQUIRE_BUILD_CERT;
    18361836    if (f32bitResourceDll)
    1837         fFlags |= SUPHNTVI_F_RESOURCE_IMAGE;
     1837        fFlags |= SUPHNTVI_F_IGNORE_ARCHITECTURE;
    18381838
    18391839    PSUPHNTVIRDR pNtViRdr;
     
    18501850    RTLDRMOD hLdrMod;
    18511851    RTLDRARCH enmArch = fFlags & SUPHNTVI_F_RC_IMAGE ? RTLDRARCH_X86_32 : RTLDRARCH_HOST;
    1852     if (fFlags & SUPHNTVI_F_RESOURCE_IMAGE)
     1852    if (fFlags & SUPHNTVI_F_IGNORE_ARCHITECTURE)
    18531853        enmArch = RTLDRARCH_WHATEVER;
    18541854    rc = RTLdrOpenWithReader(&pNtViRdr->Core, RTLDR_O_FOR_VALIDATION, enmArch, &hLdrMod, pErrInfo);
  • trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp

    r53051 r53220  
    369369*   Internal Functions                                                         *
    370370*******************************************************************************/
    371 static NTSTATUS supR3HardenedScreenImage(HANDLE hFile, bool fImage, PULONG pfAccess, PULONG pfProtect,
     371static NTSTATUS supR3HardenedScreenImage(HANDLE hFile, bool fImage, bool fIgnoreArch, PULONG pfAccess, PULONG pfProtect,
    372372                                         bool *pfCallRealApi, const char *pszCaller, bool fAvoidWinVerifyTrust,
    373373                                         bool *pfQuiet);
     
    10521052                    ULONG fProtect = 0;
    10531053                    bool  fCallRealApi = false;
    1054                     rcNt = supR3HardenedScreenImage(hFile, true /*fImage*/, &fAccess, &fProtect, &fCallRealApi,
    1055                                                     "Imports", false /*fAvoidWinVerifyTrust*/, NULL /*pfQuiet*/);
     1054                    rcNt = supR3HardenedScreenImage(hFile, true /*fImage*/, false /*fIgnoreArch*/, &fAccess, &fProtect,
     1055                                                    &fCallRealApi, "Imports", false /*fAvoidWinVerifyTrust*/, NULL /*pfQuiet*/);
    10561056                    NtClose(hFile);
    10571057                }
     
    12751275
    12761276
    1277 static NTSTATUS supR3HardenedScreenImage(HANDLE hFile, bool fImage, PULONG pfAccess, PULONG pfProtect,
     1277/**
     1278 * Screens an image file or file mapped with execute access.
     1279 *
     1280 * @returns NT status code.
     1281 * @param   hFile                   The file handle.
     1282 * @param   fImage                  Set if image file mapping being made
     1283 *                                  (NtCreateSection thing).
     1284 * @param   fIgnoreArch             Using the DONT_RESOLVE_DLL_REFERENCES flag,
     1285 *                                  which also implies that DLL init / term code
     1286 *                                  isn't called, so the architecture should be
     1287 *                                  ignored.
     1288 * @param   pfAccess                Pointer to the NtCreateSection access flags,
     1289 *                                  so we can modify them if necessary.
     1290 * @param   pfProtect               Pointer to the NtCreateSection protection
     1291 *                                  flags, so we can modify them if necessary.
     1292 * @param   pfCallRealApi           Whether it's ok to go on to the real API.
     1293 * @param   pszCaller               Who is calling (for debugging / logging).
     1294 * @param   fAvoidWinVerifyTrust    Whether we should avoid WinVerifyTrust.
     1295 * @param   pfQuiet                 Where to return whether to be quiet about
     1296 *                                  this image in the log (i.e. we've seen it
     1297 *                                  lots of times already).  Optional.
     1298 */
     1299static NTSTATUS supR3HardenedScreenImage(HANDLE hFile, bool fImage, bool fIgnoreArch, PULONG pfAccess, PULONG pfProtect,
    12781300                                         bool *pfCallRealApi, const char *pszCaller, bool fAvoidWinVerifyTrust, bool *pfQuiet)
    12791301{
     
    15401562     * left of the path buffer for an RTERRINFO buffer.
    15411563     */
     1564    if (fIgnoreArch)
     1565        fFlags |= SUPHNTVI_F_IGNORE_ARCHITECTURE;
    15421566    RTERRINFO ErrInfo;
    15431567    RTErrInfoInit(&ErrInfo, (char *)&uBuf.abBuffer[cbNameBuf], sizeof(uBuf) - cbNameBuf);
     
    16101634    bool  fCallRealApi;
    16111635    //SUP_DPRINTF(("supR3HardenedWinVerifyCachePreload: scanning %ls\n", pwszName));
    1612     supR3HardenedScreenImage(hFile, false, &fAccess, &fProtect, &fCallRealApi, "preload", false /*fAvoidWinVerifyTrust*/,
    1613                              NULL /*pfQuiet*/);
     1636    supR3HardenedScreenImage(hFile, false, false /*fIgnoreArch*/, &fAccess, &fProtect, &fCallRealApi, "preload",
     1637                             false /*fAvoidWinVerifyTrust*/, NULL /*pfQuiet*/);
    16141638    //SUP_DPRINTF(("supR3HardenedWinVerifyCachePreload: done %ls\n", pwszName));
    16151639
     
    16481672            bool fCallRealApi;
    16491673            //SUP_DPRINTF(("supR3HardenedMonitor_NtCreateSection: 1\n"));
    1650             NTSTATUS rcNt = supR3HardenedScreenImage(hFile, fImage, &fAccess, &fProtect, &fCallRealApi,
     1674            NTSTATUS rcNt = supR3HardenedScreenImage(hFile, fImage, true /*fIgnoreArch*/, &fAccess, &fProtect, &fCallRealApi,
    16511675                                                     "NtCreateSection", true /*fAvoidWinVerifyTrust*/, NULL /*pfQuiet*/);
    16521676            //SUP_DPRINTF(("supR3HardenedMonitor_NtCreateSection: 2 rcNt=%#x fCallRealApi=%#x\n", rcNt, fCallRealApi));
     
    19822006            ULONG fProtect = 0;
    19832007            bool  fCallRealApi = false;
    1984             rcNt = supR3HardenedScreenImage(hFile, true /*fImage*/, &fAccess, &fProtect, &fCallRealApi,
     2008            rcNt = supR3HardenedScreenImage(hFile, true /*fImage*/, RT_VALID_PTR(pfFlags) && (*pfFlags & 0x2) /*fIgnoreArch*/,
     2009                                            &fAccess, &fProtect, &fCallRealApi,
    19852010                                            "LdrLoadDll", false /*fAvoidWinVerifyTrust*/, &fQuiet);
    19862011            NtClose(hFile);
     
    21322157        bool  fCallRealApi = false;
    21332158        bool  fQuietFailure = false;
    2134         rcNt = supR3HardenedScreenImage(hFile, true /*fImage*/, &fAccess, &fProtect, &fCallRealApi,
     2159        rcNt = supR3HardenedScreenImage(hFile, true /*fImage*/, true /*fIgnoreArch*/, &fAccess, &fProtect, &fCallRealApi,
    21352160                                        "LdrLoadDll", true /*fAvoidWinVerifyTrust*/, &fQuietFailure);
    21362161        NtClose(hFile);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette