VirtualBox

Changeset 95067 in vbox


Ignore:
Timestamp:
May 23, 2022 9:37:30 PM (3 years ago)
Author:
vboxsync
Message:

SUPHardDarwin: Corrected macOS 11+ detection. bugref:9836

File:
1 edited

Legend:

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

    r93215 r95067  
    7272
    7373/** @sa dyld_dynamic_interpose(). */
    74 typedef const mach_header * FNDYLDDYNAMICINTERPOSE(const struct mach_header* mh, PCDYLDINTERPOSE paSym, size_t cSyms);
     74typedef const mach_header *FNDYLDDYNAMICINTERPOSE(const struct mach_header *mh, PCDYLDINTERPOSE paSym, size_t cSyms);
     75/** Pointer to dyld_dynamic_interpose. */
    7576typedef FNDYLDDYNAMICINTERPOSE *PFNDYLDDYNAMICINTERPOSE;
    7677
    7778/** @sa dlopen(). */
    7879typedef void *FNDLOPEN(const char *path, int mode);
     80/** Pointer to dlopen. */
    7981typedef FNDLOPEN *PFNDLOPEN;
    8082
     
    8385*   Internal Functions                                                                                                           *
    8486*********************************************************************************************************************************/
    85 
    86 extern "C" void _dyld_register_func_for_add_image(void (*func)(const struct mach_header* mh, intptr_t vmaddr_slide));
    87 
    88 static void * supR3HardenedDarwinDlopenInterpose(const char *path, int mode);
     87extern "C" void _dyld_register_func_for_add_image(void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
     88
     89static void *supR3HardenedDarwinDlopenInterpose(const char *path, int mode);
    8990static int supR3HardenedDarwinIssetugidInterpose(void);
    9091
     
    9394*   Global Variables                                                                                                             *
    9495*********************************************************************************************************************************/
    95 /** Flag whether macOS 11.x (BigSur) was detected. */
    96 static bool                    g_fMacOs11 = false;
     96/** Flag whether macOS 11.x (BigSur) or later was detected.
     97 * See comments in supR3HardenedDarwinDlopenInterpose for details. */
     98static bool                    g_fMacOs11Plus = false;
    9799/** Resolved dyld_dynamic_interpose() value. */
    98100static PFNDYLDDYNAMICINTERPOSE g_pfnDyldDynamicInterpose = NULL;
     
    114116 * @sa dlopen() man page.
    115117 */
    116 static void * supR3HardenedDarwinDlopenInterpose(const char *path, int mode)
     118static void *supR3HardenedDarwinDlopenInterpose(const char *path, int mode)
    117119{
    118120    /*
     
    137139         * when we run on BigSur. Other paths are still subject to verification.
    138140         */
    139         if (   !g_fMacOs11
     141        if (   !g_fMacOs11Plus
    140142            || strncmp(path, RT_STR_TUPLE("/System/Library")))
    141143            rc = supR3HardenedVerifyFileFollowSymlinks(path, RTHCUINTPTR_MAX, true /* fMaybe3rdParty */,
     
    187189 * @param   vmaddr_slide    The slide value for ASLR.
    188190 */
    189 static DECLCALLBACK(void) supR3HardenedDarwinAddImage(const struct mach_header* mh, intptr_t vmaddr_slide)
     191static DECLCALLBACK(void) supR3HardenedDarwinAddImage(const struct mach_header *mh, intptr_t vmaddr_slide)
    190192{
    191193    RT_NOREF(vmaddr_slide);
    192194
    193     g_pfnDyldDynamicInterpose((const struct mach_header*)mh, &g_aInterposers[0], RT_ELEMENTS(g_aInterposers));
     195    g_pfnDyldDynamicInterpose(mh, &g_aInterposers[0], RT_ELEMENTS(g_aInterposers));
    194196}
    195197
     
    212214    int rc = sysctlbyname("kern.osproductversion", &szVers[0], &cbVers, NULL, 0);
    213215    if (   !rc
    214         && !memcmp(&szVers[0], RT_STR_TUPLE("10.16")))
    215         g_fMacOs11 = true;
     216        && memcmp(&szVers[0], RT_STR_TUPLE("10.16")) >= 0)
     217        g_fMacOs11Plus = true;
    216218
    217219    /* Saved to call real dlopen() later on, as we will interpose dlopen() from the main binary in the next step as well. */
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