VirtualBox

Changeset 56818 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
Jul 6, 2015 2:15:29 PM (10 years ago)
Author:
vboxsync
Message:

SUPR3HardenedMain.cpp: Must apply SUPSECMAIN_FLAGS_OSX_VM_APP in supR3HardenedMainGetTrustedMain and supR3HardenedMainGetTrustedError.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp

    r56817 r56818  
    17201720
    17211721/**
     1722 * Construct the path to the DLL/SO/DYLIB containing the actual program.
     1723 *
     1724 * @returns VBox status code.
     1725 * @param   pszProgName     The program name.
     1726 * @param   fMainFlags      The flags passed to SUPR3HardenedMain.
     1727 * @param   pszPath         The output buffer.
     1728 * @param   cbPath          The size of the output buffer, in bytes.  Must be at
     1729 *                          least 128 bytes!
     1730 */
     1731static int supR3HardenedMainGetTrustedLib(const char *pszProgName, uint32_t fMainFlags, char *pszPath, size_t cbPath)
     1732{
     1733    supR3HardenedPathAppPrivateArch(pszPath, sizeof(cbPath) - 10);
     1734    const char *pszSubDirSlash;
     1735    switch (g_fSupHardenedMain & SUPSECMAIN_FLAGS_LOC_MASK)
     1736    {
     1737        case SUPSECMAIN_FLAGS_LOC_APP_BIN:
     1738            pszSubDirSlash = "/";
     1739            break;
     1740        case SUPSECMAIN_FLAGS_LOC_TESTCASE:
     1741            pszSubDirSlash = "/testcase/";
     1742            break;
     1743        default:
     1744            pszSubDirSlash = "/";
     1745            supR3HardenedFatal("supR3HardenedMainGetTrustedMain: Unknown program binary location: %#x\n", g_fSupHardenedMain);
     1746    }
     1747#ifdef RT_OS_DARWIN
     1748    if (fFlags & SUPSECMAIN_FLAGS_OSX_VM_APP)
     1749        pszProgName = "VirtualBox";
     1750#endif
     1751    size_t cch = suplibHardenedStrLen(pszPath);
     1752    return suplibHardenedStrCopyEx(&pszPath[cch], cbPath - cch, pszSubDirSlash, pszProgName, SUPLIB_DLL_SUFF, NULL);
     1753}
     1754
     1755
     1756/**
    17221757 * Loads the DLL/SO/DYLIB containing the actual program and
    17231758 * resolves the TrustedError symbol.
     
    17431778     */
    17441779    char szPath[RTPATH_MAX];
    1745     supR3HardenedPathAppPrivateArch(szPath, sizeof(szPath) - 10);
    1746     size_t cch = suplibHardenedStrLen(szPath);
    1747     suplibHardenedStrCopyEx(&szPath[cch], sizeof(szPath) - cch, "/", pszProgName, SUPLIB_DLL_SUFF, NULL);
     1780    supR3HardenedMainGetTrustedLib(pszProgName, g_fSupHardenedMain, szPath, sizeof(szPath));
    17481781
    17491782    /*
     
    17791812 * @returns Pointer to the trusted main of the actual program.
    17801813 * @param   pszProgName     The program name.
     1814 * @param   fMainFlags      The flags passed to SUPR3HardenedMain.
    17811815 * @remarks This function will not return on failure.
    17821816 */
    1783 static PFNSUPTRUSTEDMAIN supR3HardenedMainGetTrustedMain(const char *pszProgName)
     1817static PFNSUPTRUSTEDMAIN supR3HardenedMainGetTrustedMain(const char *pszProgName, uint32_t fMainFlags)
    17841818{
    17851819    /*
     
    17871821     */
    17881822    char szPath[RTPATH_MAX];
    1789     supR3HardenedPathAppPrivateArch(szPath, sizeof(szPath) - 10);
    1790     const char *pszSubDirSlash;
    1791     switch (g_fSupHardenedMain & SUPSECMAIN_FLAGS_LOC_MASK)
    1792     {
    1793         case SUPSECMAIN_FLAGS_LOC_APP_BIN:
    1794             pszSubDirSlash = "/";
    1795             break;
    1796         case SUPSECMAIN_FLAGS_LOC_TESTCASE:
    1797             pszSubDirSlash = "/testcase/";
    1798             break;
    1799         default:
    1800             pszSubDirSlash = "/";
    1801             supR3HardenedFatal("supR3HardenedMainGetTrustedMain: Unknown program binary location: %#x\n", g_fSupHardenedMain);
    1802     }
    1803     size_t cch = suplibHardenedStrLen(szPath);
    1804     suplibHardenedStrCopyEx(&szPath[cch], sizeof(szPath) - cch, pszSubDirSlash, pszProgName, SUPLIB_DLL_SUFF, NULL);
     1823    supR3HardenedMainGetTrustedLib(pszProgName, fMainFlags, szPath, sizeof(szPath));
    18051824
    18061825    /*
     
    18111830    if (!hMod)
    18121831        supR3HardenedFatal("supR3HardenedMainGetTrustedMain: LoadLibrary \"%s\" failed, rc=%d\n",
    1813                             szPath, RtlGetLastWin32Error());
     1832                           szPath, RtlGetLastWin32Error());
    18141833    FARPROC pfn = GetProcAddress(hMod, SUP_HARDENED_SYM("TrustedMain"));
    18151834    if (!pfn)
    18161835        supR3HardenedFatal("supR3HardenedMainGetTrustedMain: Entrypoint \"TrustedMain\" not found in \"%s\" (rc=%d)\n",
    1817                             szPath, RtlGetLastWin32Error());
     1836                           szPath, RtlGetLastWin32Error());
    18181837    return (PFNSUPTRUSTEDMAIN)pfn;
    18191838
     
    18231842    if (!pvMod)
    18241843        supR3HardenedFatal("supR3HardenedMainGetTrustedMain: dlopen(\"%s\",) failed: %s\n",
    1825                             szPath, dlerror());
     1844                           szPath, dlerror());
    18261845    void *pvSym = dlsym(pvMod, SUP_HARDENED_SYM("TrustedMain"));
    18271846    if (!pvSym)
    18281847        supR3HardenedFatal("supR3HardenedMainGetTrustedMain: Entrypoint \"TrustedMain\" not found in \"%s\"!\ndlerror: %s\n",
    1829                             szPath, dlerror());
     1848                           szPath, dlerror());
    18301849    return (PFNSUPTRUSTEDMAIN)(uintptr_t)pvSym;
    18311850#endif
     
    20022021    SUP_DPRINTF(("SUPR3HardenedMain: Load TrustedMain...\n"));
    20032022    g_enmSupR3HardenedMainState = SUPR3HARDENEDMAINSTATE_GET_TRUSTED_MAIN;
    2004     PFNSUPTRUSTEDMAIN pfnTrustedMain = supR3HardenedMainGetTrustedMain(pszProgName);
     2023    PFNSUPTRUSTEDMAIN pfnTrustedMain = supR3HardenedMainGetTrustedMain(pszProgName, fFlags);
    20052024
    20062025    SUP_DPRINTF(("SUPR3HardenedMain: Calling TrustedMain (%p)...\n", pfnTrustedMain));
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