Changeset 95067 in vbox
- Timestamp:
- May 23, 2022 9:37:30 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/darwin/SUPR3HardenedMain-darwin.cpp
r93215 r95067 72 72 73 73 /** @sa dyld_dynamic_interpose(). */ 74 typedef const mach_header * FNDYLDDYNAMICINTERPOSE(const struct mach_header* mh, PCDYLDINTERPOSE paSym, size_t cSyms); 74 typedef const mach_header *FNDYLDDYNAMICINTERPOSE(const struct mach_header *mh, PCDYLDINTERPOSE paSym, size_t cSyms); 75 /** Pointer to dyld_dynamic_interpose. */ 75 76 typedef FNDYLDDYNAMICINTERPOSE *PFNDYLDDYNAMICINTERPOSE; 76 77 77 78 /** @sa dlopen(). */ 78 79 typedef void *FNDLOPEN(const char *path, int mode); 80 /** Pointer to dlopen. */ 79 81 typedef FNDLOPEN *PFNDLOPEN; 80 82 … … 83 85 * Internal Functions * 84 86 *********************************************************************************************************************************/ 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); 87 extern "C" void _dyld_register_func_for_add_image(void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide)); 88 89 static void *supR3HardenedDarwinDlopenInterpose(const char *path, int mode); 89 90 static int supR3HardenedDarwinIssetugidInterpose(void); 90 91 … … 93 94 * Global Variables * 94 95 *********************************************************************************************************************************/ 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. */ 98 static bool g_fMacOs11Plus = false; 97 99 /** Resolved dyld_dynamic_interpose() value. */ 98 100 static PFNDYLDDYNAMICINTERPOSE g_pfnDyldDynamicInterpose = NULL; … … 114 116 * @sa dlopen() man page. 115 117 */ 116 static void * 118 static void *supR3HardenedDarwinDlopenInterpose(const char *path, int mode) 117 119 { 118 120 /* … … 137 139 * when we run on BigSur. Other paths are still subject to verification. 138 140 */ 139 if ( !g_fMacOs11 141 if ( !g_fMacOs11Plus 140 142 || strncmp(path, RT_STR_TUPLE("/System/Library"))) 141 143 rc = supR3HardenedVerifyFileFollowSymlinks(path, RTHCUINTPTR_MAX, true /* fMaybe3rdParty */, … … 187 189 * @param vmaddr_slide The slide value for ASLR. 188 190 */ 189 static DECLCALLBACK(void) supR3HardenedDarwinAddImage(const struct mach_header *mh, intptr_t vmaddr_slide)191 static DECLCALLBACK(void) supR3HardenedDarwinAddImage(const struct mach_header *mh, intptr_t vmaddr_slide) 190 192 { 191 193 RT_NOREF(vmaddr_slide); 192 194 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)); 194 196 } 195 197 … … 212 214 int rc = sysctlbyname("kern.osproductversion", &szVers[0], &cbVers, NULL, 0); 213 215 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; 216 218 217 219 /* 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.