Changeset 54013 in vbox
- Timestamp:
- Jan 28, 2015 1:44:00 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/sup.h
r53824 r54013 1137 1137 1138 1138 /** 1139 * Lock down the module loader interface. 1140 * 1141 * This will lock down the module loader interface. No new modules can be 1142 * loaded and all loaded modules can no longer be freed. 1143 * 1144 * @returns VBox status code. 1145 * @param pErrInfo Where to return extended error information. 1146 * Optional. 1147 */ 1148 SUPR3DECL(int) SUPR3LockDownLoader(PRTERRINFO pErrInfo); 1149 1150 /** 1139 1151 * Get the address of a symbol in a ring-0 module. 1140 1152 * -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r53843 r54013 148 148 static int supdrvIOCtl_LdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRLOAD pReq); 149 149 static int supdrvIOCtl_LdrFree(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRFREE pReq); 150 static int supdrvIOCtl_LdrLockDown(PSUPDRVDEVEXT pDevExt); 150 151 static int supdrvIOCtl_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLDRGETSYMBOL pReq); 151 152 static int supdrvIDC_LdrGetSymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQGETSYM pReq); … … 1710 1711 } 1711 1712 1713 case SUP_CTL_CODE_NO_SIZE(SUP_IOCTL_LDR_LOCK_DOWN): 1714 { 1715 /* validate */ 1716 REQ_CHECK_SIZES(SUP_IOCTL_LDR_LOCK_DOWN); 1717 1718 /* execute */ 1719 pReqHdr->rc = supdrvIOCtl_LdrLockDown(pDevExt); 1720 return 0; 1721 } 1722 1712 1723 case SUP_CTL_CODE_NO_SIZE(SUP_IOCTL_LDR_GET_SYMBOL): 1713 1724 { … … 4557 4568 /* (not found - add it!) */ 4558 4569 4570 /* If the loader interface is locked down, make userland fail early */ 4571 if (pDevExt->fLdrLockedDown) 4572 { 4573 supdrvLdrUnlock(pDevExt); 4574 Log(("supdrvIOCtl_LdrOpen: Not adding '%s' to image list, loader interface is locked down!\n", pReq->u.In.szName)); 4575 return VERR_PERMISSION_DENIED; 4576 } 4577 4559 4578 /* 4560 4579 * Allocate memory. … … 4722 4741 } 4723 4742 4743 /* If the loader interface is locked down, don't load new images */ 4744 if (pDevExt->fLdrLockedDown) 4745 { 4746 supdrvLdrUnlock(pDevExt); 4747 Log(("SUP_IOCTL_LDR_LOAD: Not loading '%s' image bits, loader interface is locked down!\n", pImage->szName)); 4748 return VERR_PERMISSION_DENIED; 4749 } 4750 4724 4751 switch (pReq->u.In.eEPType) 4725 4752 { … … 4984 5011 4985 5012 /** 5013 * Lock down the image loader interface. 5014 * 5015 * @returns IPRT status code. 5016 * @param pDevExt Device globals. 5017 */ 5018 static int supdrvIOCtl_LdrLockDown(PSUPDRVDEVEXT pDevExt) 5019 { 5020 LogFlow(("supdrvIOCtl_LdrLockDown:\n")); 5021 5022 supdrvLdrLock(pDevExt); 5023 if (!pDevExt->fLdrLockedDown) 5024 { 5025 pDevExt->fLdrLockedDown = true; 5026 Log(("supdrvIOCtl_LdrLockDown: Image loader interface locked down\n")); 5027 } 5028 supdrvLdrUnlock(pDevExt); 5029 5030 return VINF_SUCCESS; 5031 } 5032 5033 5034 /** 4986 5035 * Gets the address of a symbol in an open image. 4987 5036 * … … 5252 5301 PSUPDRVLDRIMAGE pImagePrev; 5253 5302 LogFlow(("supdrvLdrFree: pImage=%p\n", pImage)); 5303 5304 /* 5305 * Warn if we're releasing images while the image loader interface is 5306 * locked down -- we won't be able to reload them! 5307 */ 5308 if (pDevExt->fLdrLockedDown) 5309 Log(("supdrvLdrFree: Warning: unloading '%s' image, while loader interface is locked down!\n", pImage->szName)); 5254 5310 5255 5311 /* find it - arg. should've used doubly linked list. */ -
trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
r53269 r54013 215 215 * - (none). 216 216 */ 217 #define SUPDRV_IOC_VERSION 0x001d000 0217 #define SUPDRV_IOC_VERSION 0x001d0001 218 218 219 219 /** SUP_IOCTL_COOKIE. */ … … 480 480 481 481 482 /** @name SUP_IOCTL_LDR_LOCK_DOWN 483 * Lock down the image loader interface. 484 * @{ 485 */ 486 #define SUP_IOCTL_LDR_LOCK_DOWN SUP_CTL_CODE_SIZE(38, SUP_IOCTL_LDR_LOCK_DOWN_SIZE) 487 #define SUP_IOCTL_LDR_LOCK_DOWN_SIZE sizeof(SUPREQHDR) 488 #define SUP_IOCTL_LDR_LOCK_DOWN_SIZE_IN sizeof(SUPREQHDR) 489 #define SUP_IOCTL_LDR_LOCK_DOWN_SIZE_OUT sizeof(SUPREQHDR) 490 /** @} */ 491 492 482 493 /** @name SUP_IOCTL_LDR_GET_SYMBOL 483 494 * Get address of a symbol within an image. -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r53800 r54013 610 610 /** Linked list of loaded code. */ 611 611 PSUPDRVLDRIMAGE volatile pLdrImages; 612 /** Set if the image loading interface got disabled after loading all needed images */ 613 bool fLdrLockedDown; 612 614 613 615 /** @name These members for detecting whether an API caller is in ModuleInit. -
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r53212 r54013 279 279 strcpy(CookieReq.u.In.szMagic, SUPCOOKIE_MAGIC); 280 280 CookieReq.u.In.u32ReqVersion = SUPDRV_IOC_VERSION; 281 const uint32_t uMinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x001 c0000282 ? 0x001 c0001281 const uint32_t uMinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x001d0000 282 ? 0x001d0001 283 283 : SUPDRV_IOC_VERSION & 0xffff0000; 284 284 CookieReq.u.In.u32MinVersion = uMinVersion; … … 1038 1038 1039 1039 1040 SUPR3DECL(int) SUPR3LockDownLoader(PRTERRINFO pErrInfo) 1041 { 1042 /* fake */ 1043 if (RT_UNLIKELY(g_uSupFakeMode)) 1044 return VINF_SUCCESS; 1045 1046 /* 1047 * Lock down the module loader interface. 1048 */ 1049 SUPREQHDR ReqHdr; 1050 ReqHdr.u32Cookie = g_u32Cookie; 1051 ReqHdr.u32SessionCookie = g_u32SessionCookie; 1052 ReqHdr.cbIn = SUP_IOCTL_LDR_LOCK_DOWN_SIZE_IN; 1053 ReqHdr.cbOut = SUP_IOCTL_LDR_LOCK_DOWN_SIZE_OUT; 1054 ReqHdr.fFlags = SUPREQHDR_FLAGS_DEFAULT; 1055 ReqHdr.rc = VERR_INTERNAL_ERROR; 1056 int rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_LDR_LOCK_DOWN, &ReqHdr, SUP_IOCTL_LDR_LOCK_DOWN_SIZE); 1057 if (RT_FAILURE(rc)) 1058 return RTErrInfoSetF(pErrInfo, rc, 1059 "SUPR3LockDownLoader: SUP_IOCTL_LDR_LOCK_DOWN ioctl returned %Rrc", rc); 1060 1061 return ReqHdr.rc; 1062 } 1063 1064 1040 1065 /** 1041 1066 * Fallback for SUPR3PageAllocEx on systems where RTR0MemObjPhysAllocNC isn't -
trunk/src/VBox/VMM/tools/VBoxVMMPreload.cpp
r46175 r54013 52 52 53 53 static uint32_t g_cVerbose = 1; 54 static bool g_fLockDown = false; 54 55 55 56 … … 71 72 { "--only", 'o', RTGETOPT_REQ_STRING }, 72 73 { "--quiet", 'q', RTGETOPT_REQ_NOTHING }, 74 { "--lock" , 'l', RTGETOPT_REQ_NOTHING }, 73 75 { "--verbose", 'v', RTGETOPT_REQ_NOTHING }, 74 76 }; … … 115 117 break; 116 118 119 case 'l': 120 g_fLockDown = true; 121 break; 122 117 123 case 'h': 118 124 RTPrintf(VBOX_PRODUCT " VMM ring-0 Module Preloader Version " VBOX_VERSION_STRING … … 120 126 "All rights reserved.\n" 121 127 "\n" 122 "Usage: VBoxVMMPreload [-h qvV] [-o|--only <mod>]\n"128 "Usage: VBoxVMMPreload [-hlqvV] [-o|--only <mod>]\n" 123 129 "\n"); 124 130 *pfExit = true; … … 145 151 static RTEXITCODE LoadModules(void) 146 152 { 153 RTERRINFOSTATIC ErrInfo; 154 147 155 for (uint32_t i = 0; i < RT_ELEMENTS(g_aModules); i++) 148 156 { … … 156 164 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPathAppPrivateArch or RTPathAppend returned %Rrc", rc); 157 165 158 RTERRINFOSTATIC ErrInfo;159 166 RTErrInfoInitStatic(&ErrInfo); 160 167 rc = SUPR3LoadModule(szPath, g_aModules[i].pszName, &g_aModules[i].pvImageBase, &ErrInfo.Core); … … 167 174 } 168 175 176 if (g_fLockDown) 177 { 178 RTErrInfoInitStatic(&ErrInfo); 179 int rc = SUPR3LockDownLoader(&ErrInfo.Core); 180 if (RT_FAILURE(rc)) 181 return RTMsgErrorExit(RTEXITCODE_FAILURE, "SUPR3LockDownLoader failed: %s (rc=%Rrc)", 182 ErrInfo.Core.pszMsg, rc); 183 if (g_cVerbose >= 1) 184 RTMsgInfo("Locked down module loader interface!\n"); 185 } 186 169 187 RTStrmFlush(g_pStdOut); 170 188 return RTEXITCODE_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.