VirtualBox

Ignore:
Timestamp:
Feb 3, 2020 1:31:22 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
135963
Message:

SUPHard/darwin: Ignore patching failures in supR3HardenedPosixInit if the hardened runtime option is active (can't easily modify text pages then). bugref:9466

File:
1 edited

Legend:

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

    r76553 r82957  
    4545# include <unistd.h>   /* readlink() */
    4646# include <stdlib.h>
     47# include <sys/sysctl.h> /* sysctlbyname() */
    4748#elif defined(RT_OS_SOLARIS)
    4849# include <link.h>
     
    640641DECLHIDDEN(void) supR3HardenedPosixInit(void)
    641642{
     643    int  rc;
     644    bool fIgnoreFailure = false;
     645
     646#ifdef RT_OS_DARWIN
     647    /*
     648     * Try figure out / guess if we've got hardened runtime here.  For now we'll
     649     * just ignore patching errors if when hardened runtime is active.
     650     */
     651    int (*pfnCsOps)(pid_t, unsigned int, void *, size_t);
     652    *(void **)&pfnCsOps = dlsym(RTLD_DEFAULT, "csops");
     653    if (!pfnCsOps)
     654        supR3HardenedFatalMsg("supR3HardenedPosixInit", kSupInitOp_Integrity, VERR_SYMBOL_NOT_FOUND,
     655                              "Failed locate the 'csops' function");
     656
     657    uint32_t fFlags = 0;
     658    rc = pfnCsOps(getpid(), 0 /*CS_OPS_STATUS*/, &fFlags, sizeof(fFlags));
     659# if 0
     660    char szMsg[128];
     661    write(2, szMsg, sprintf(szMsg,"DEBUG: p_csflags=%#x rc=%d\n", fFlags, rc));
     662# endif
     663    if (rc != 0)
     664        supR3HardenedFatalMsg("supR3HardenedPosixInit", kSupInitOp_Integrity, VERR_GENERAL_FAILURE,
     665                              "csops/CS_OPS_STATUS failed (%d)", rc);
     666    fIgnoreFailure = RT_BOOL(fFlags & 0x00010000 /*CS_RUNTIME*/);
     667#endif
     668
    642669    for (unsigned i = 0; i < RT_ELEMENTS(g_aHooks); i++)
    643670    {
    644671        PCSUPHARDENEDPOSIXHOOK pHook = &g_aHooks[i];
    645         int rc = supR3HardenedMainPosixHookOne(pHook->pszSymbol, pHook->pfnHook, pHook->ppfnRealResume, pHook->pfnResolve);
    646         if (RT_FAILURE(rc))
     672        rc = supR3HardenedMainPosixHookOne(pHook->pszSymbol, pHook->pfnHook, pHook->ppfnRealResume, pHook->pfnResolve);
     673        if (RT_FAILURE(rc) && !fIgnoreFailure)
    647674            supR3HardenedFatalMsg("supR3HardenedPosixInit", kSupInitOp_Integrity, rc,
    648675                                  "Failed to hook the %s interface", pHook->pszSymbol);
Note: See TracChangeset for help on using the changeset viewer.

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