儲存庫 vbox 的更動 12423
- 時間撮記:
- 2008-9-12 下午02:42:49 (16 年 以前)
- 位置:
- trunk
- 檔案:
-
- 修改 9 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/include/VBox/sup.h
r11889 r12423 566 566 567 567 /** 568 * Verifies the integrity of a file, and optionally opens it. 569 * 570 * The integrity check is for whether the file is suitable for loading into 571 * the hypervisor or VM process. The integrity check may include verifying 572 * the authenticode/elfsign/whatever signature of the file, which can take 573 * a little while. 574 * 575 * @returns VBox status code. On failure it will have printed a LogRel message. 576 * 577 * @param pszFilename The file. 578 * @param pszWhat For the LogRel on failure. 579 * @param phFile Where to store the handle to the opened file. This is optional, pass NULL 580 * if the file should not be opened. 581 */ 582 SUPR3DECL(int) SUPR3HardenedVerifyFile(const char *pszFilename, const char *pszWhat, PRTFILE phFile); 583 584 /** 585 * Load a module into R0 HC. 586 * 587 * This will verify the file integrity in a similar manner as 568 * Load a module into R0 HC. 569 * 570 * This will verify the file integrity in a similar manner as 588 571 * SUPR3HardenedVerifyFile before loading it. 589 572 * … … 637 620 */ 638 621 SUPR3DECL(int) SUPGipGetPhys(PRTHCPHYS pHCPhys); 622 623 /** 624 * Verifies the integrity of a file, and optionally opens it. 625 * 626 * The integrity check is for whether the file is suitable for loading into 627 * the hypervisor or VM process. The integrity check may include verifying 628 * the authenticode/elfsign/whatever signature of the file, which can take 629 * a little while. 630 * 631 * @returns VBox status code. On failure it will have printed a LogRel message. 632 * 633 * @param pszFilename The file. 634 * @param pszWhat For the LogRel on failure. 635 * @param phFile Where to store the handle to the opened file. This is optional, pass NULL 636 * if the file should not be opened. 637 */ 638 SUPR3DECL(int) SUPR3HardenedVerifyFile(const char *pszFilename, const char *pszWhat, PRTFILE phFile); 639 640 /** 641 * Same as RTLdrLoad() but will verify the files it loads (hardened builds). 642 * 643 * Will add dll suffix if missing and try load the file. 644 * 645 * @returns iprt status code. 646 * @param pszFilename Image filename. This must have a path. 647 * @param phLdrMod Where to store the handle to the loaded module. 648 */ 649 SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod); 650 651 /** 652 * Same as RTLdrLoadAppPriv() but it will verify the files it loads (hardened 653 * builds). 654 * 655 * Will add dll suffix to the file if missing, then look for it in the 656 * architecture dependent application directory. 657 * 658 * @returns iprt status code. 659 * @param pszFilename Image filename. 660 * @param phLdrMod Where to store the handle to the loaded module. 661 */ 662 SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod); 639 663 640 664 /** @} */ -
trunk/include/iprt/ldr.h
r11888 r12423 69 69 70 70 /** 71 * Loads a dynamic load library (/shared object) image file using native 72 * OS facilities. 73 * 74 * If the path is specified in the filename, only this path is used. 75 * If only the image file name is specified, then try to load it from: 76 * - RTPathAppPrivateArch 77 * - RTPathSharedLibs (legacy) 78 * 79 * @returns iprt status code. 80 * @param pszFilename Image filename. 71 * Loads a dynamic load library (/shared object) image file residing in the 72 * RTPathAppPrivateArch() directory. 73 * 74 * Suffix is not required. 75 * 76 * @returns iprt status code. 77 * @param pszFilename Image filename. No path. 81 78 * @param phLdrMod Where to store the handle to the loaded module. 82 79 */ 83 RTDECL(int) RTLdrLoadApp SharedLib(const char *pszFilename, PRTLDRMOD phLdrMod);80 RTDECL(int) RTLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod); 84 81 85 82 /** -
trunk/src/VBox/Devices/Serial/DevSerial.cpp
r11284 r12423 242 242 if (RT_LIKELY(s->pDrvChar)) 243 243 s->pDrvChar->pfnSetParameters(s->pDrvChar, speed, parity, data_bits, stop_bits); 244 #ifdef RT_OS_DARWIN 245 if (RT_LIKELY(s->pDrvChar)) 246 s->cNsDelay = (69444 - 2000) / s->divider; /* 69444 == 1000,000,000 / (115,000 / 8); 2000 = fudge factor */ 247 #endif 244 248 } 245 249 … … 386 390 case 5: 387 391 ret = s->lsr; 392 #ifdef RT_OS_DARWIN 393 if ( !(ret & UART_LSR_THRE) 394 && pThis->HeldXmitNanoTS 395 && RTTimeNanoTS() - s->HeldXmitNanoTS >= s->cNsDelay) { 396 ret = s->lsr |= UART_LSR_THRE; 397 } 398 #endif 388 399 break; 389 400 case 6: -
trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp
r12368 r12423 26 26 #include <VBox/VBoxHDD-new.h> 27 27 #include <VBox/err.h> 28 28 #include <VBox/sup.h> 29 29 #include <VBox/log.h> 30 30 31 #include <iprt/alloc.h> 31 32 #include <iprt/assert.h> … … 195 196 196 197 /* Try to load the plugin (RTLdrLoad takes care of the suffix). */ 197 rc = RTLdrLoad(pszPluginName, &hPlugin);198 rc = SUPR3HardenedLdrLoad(pszPluginName, &hPlugin); 198 199 if (RT_SUCCESS(rc)) 199 200 { … … 730 731 } 731 732 732 rc = RTLdrLoad(pszPluginPath, &hPlugin);733 rc = SUPR3HardenedLdrLoad(pszPluginPath, &hPlugin); 733 734 if (RT_SUCCESS(rc)) 734 735 { … … 1015 1016 } 1016 1017 1017 rc = RTLdrLoad(pszPluginPath, &hPlugin);1018 rc = SUPR3HardenedLdrLoad(pszPluginPath, &hPlugin); 1018 1019 if (RT_SUCCESS(rc)) 1019 1020 { -
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r11822 r12423 51 51 #include <iprt/param.h> 52 52 #include <iprt/process.h> 53 #include <VBox/sup.h> 53 54 #endif 54 55 … … 690 691 691 692 Log2(("VBoxHeadless: loading VBoxFFmpegFB shared library\n")); 692 rrc = RTLdrLoad("VBoxFFmpegFB", &hLdrFFmpegFB);693 rrc = SUPR3HardenedLdrLoad("VBoxFFmpegFB", &hLdrFFmpegFB); 693 694 694 695 if (RT_SUCCESS(rrc)) -
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r11889 r12423 47 47 */ 48 48 49 50 49 /******************************************************************************* 51 50 * Header Files * … … 68 67 #include <iprt/thread.h> 69 68 #include <iprt/process.h> 69 #include <iprt/path.h> 70 70 #include <iprt/string.h> 71 71 #include <iprt/env.h> … … 738 738 { 739 739 RTHCPHYS Phys = (uintptr_t)pvStart + PAGE_SIZE * 1024; 740 unsignediPage = cPages;740 size_t iPage = cPages; 741 741 while (iPage-- > 0) 742 742 paPages[iPage].Phys = Phys + (iPage << PAGE_SHIFT); … … 758 758 pReq->Hdr.rc = VERR_INTERNAL_ERROR; 759 759 pReq->u.In.pvR3 = pvStart; 760 pReq->u.In.cPages = cPages; AssertRelease(pReq->u.In.cPages == cPages);760 pReq->u.In.cPages = (uint32_t)cPages; AssertRelease(pReq->u.In.cPages == cPages); 761 761 rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_PAGE_LOCK, pReq, SUP_IOCTL_PAGE_LOCK_SIZE(cPages)); 762 762 if (RT_SUCCESS(rc)) … … 876 876 pReq->Hdr.fFlags = SUPREQHDR_FLAGS_MAGIC | SUPREQHDR_FLAGS_EXTRA_OUT; 877 877 pReq->Hdr.rc = VERR_INTERNAL_ERROR; 878 pReq->u.In.cPages = cPages; AssertRelease(pReq->u.In.cPages == cPages);878 pReq->u.In.cPages = (uint32_t)cPages; AssertRelease(pReq->u.In.cPages == cPages); 879 879 rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_PAGE_ALLOC, pReq, SUP_IOCTL_PAGE_ALLOC_SIZE(cPages)); 880 880 if (RT_SUCCESS(rc)) … … 991 991 Req.Hdr.fFlags = SUPREQHDR_FLAGS_DEFAULT; 992 992 Req.Hdr.rc = VERR_INTERNAL_ERROR; 993 Req.u.In.cPages = cPages;993 Req.u.In.cPages = (uint32_t)cPages; 994 994 int rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_CONT_ALLOC, &Req, SUP_IOCTL_CONT_ALLOC_SIZE); 995 995 if ( RT_SUCCESS(rc) … … 1060 1060 /* fake physical addresses. */ 1061 1061 RTHCPHYS Phys = (uintptr_t)*ppvPages + PAGE_SIZE * 1024; 1062 unsignediPage = cPages;1062 size_t iPage = cPages; 1063 1063 while (iPage-- > 0) 1064 1064 paPages[iPage].Phys = Phys + (iPage << PAGE_SHIFT); … … 1079 1079 pReq->Hdr.fFlags = SUPREQHDR_FLAGS_MAGIC | SUPREQHDR_FLAGS_EXTRA_OUT; 1080 1080 pReq->Hdr.rc = VERR_INTERNAL_ERROR; 1081 pReq->u.In.cPages = cPages; AssertRelease(pReq->u.In.cPages == cPages);1081 pReq->u.In.cPages = (uint32_t)cPages; AssertRelease(pReq->u.In.cPages == cPages); 1082 1082 rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_LOW_ALLOC, pReq, SUP_IOCTL_LOW_ALLOC_SIZE(cPages)); 1083 1083 if (RT_SUCCESS(rc)) … … 1148 1148 AssertPtr(pszFilename); 1149 1149 AssertPtr(pszMsg); 1150 AssertReturn(!phFile, VERR_NOT_IMPLEMENTED); /** @todo Implement this. The deal is that we make sure the 1150 AssertReturn(!phFile, VERR_NOT_IMPLEMENTED); /** @todo Implement this. The deal is that we make sure the 1151 1151 file is the same we verified after opening it. */ 1152 1152 … … 1192 1192 } 1193 1193 else 1194 LogRel(("SUPLoadModule: Verification of \"%s\" failed, rc=%Rrc\n", rc)); 1194 LogRel(("SUPLoadModule: Verification of \"%s\" failed, rc=%Rrc\n", rc)); 1195 1195 return rc; 1196 1196 } … … 1890 1890 } 1891 1891 1892 1893 /** 1894 * Worker for SUPR3HardenedLdrLoad and SUPR3HardenedLdrLoadAppPriv. 1895 * 1896 * @returns iprt status code. 1897 * @param pszFilename The full file name. 1898 * @param phLdrMod Where to store the handle to the loaded module. 1899 */ 1900 static int supR3HardenedLdrLoadIt(const char *pszFilename, PRTLDRMOD phLdrMod) 1901 { 1902 #ifdef VBOX_WITH_HARDENING 1903 /* 1904 * Verify the image file. 1905 */ 1906 rc = supR3HardenedVerifyFile(pszFilename, false /* fFatal */); 1907 if (RT_FAILURE(rc)) 1908 { 1909 LogRel(("supR3HardenedLdrLoadIt: Verification of \"%s\" failed, rc=%Rrc\n", rc)); 1910 return rc; 1911 } 1912 #endif 1913 1914 /* 1915 * Try load it. 1916 */ 1917 return RTLdrLoad(pszFilename, phLdrMod); 1918 } 1919 1920 1921 SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod) 1922 { 1923 /* 1924 * Validate input. 1925 */ 1926 AssertPtrReturn(pszFilename, VERR_INVALID_PARAMETER); 1927 AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER); 1928 *phLdrMod = NIL_RTLDRMOD; 1929 AssertReturn(RTPathHavePath(pszFilename), VERR_INVALID_PARAMETER); 1930 1931 /* 1932 * Add the default extension if it's missing. 1933 */ 1934 if (!RTPathHaveExt(pszFilename)) 1935 { 1936 const char *pszSuff = RTLdrGetSuff(); 1937 size_t cchSuff = strlen(pszSuff); 1938 size_t cchFilename = strlen(pszFilename); 1939 char *psz = (char *)alloca(cchFilename + cchSuff + 1); 1940 AssertReturn(psz, VERR_NO_TMP_MEMORY); 1941 memcpy(psz, pszFilename, cchFilename); 1942 memcpy(psz + cchFilename, pszSuff, cchSuff + 1); 1943 pszFilename = psz; 1944 } 1945 1946 /* 1947 * Pass it on to the common library loader. 1948 */ 1949 return supR3HardenedLdrLoadIt(pszFilename, phLdrMod); 1950 } 1951 1952 1953 SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod) 1954 { 1955 LogFlow(("SUPR3HardenedLdrLoadAppPriv: pszFilename=%p:{%s} phLdrMod=%p\n", pszFilename, pszFilename, phLdrMod)); 1956 1957 /* 1958 * Validate input. 1959 */ 1960 AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER); 1961 *phLdrMod = NIL_RTLDRMOD; 1962 AssertPtrReturn(pszFilename, VERR_INVALID_PARAMETER); 1963 AssertMsgReturn(!RTPathHavePath(pszFilename), ("%s\n", pszFilename), VERR_INVALID_PARAMETER); 1964 1965 /* 1966 * Check the filename. 1967 */ 1968 size_t cchFilename = strlen(pszFilename); 1969 AssertMsgReturn(cchFilename < (RTPATH_MAX / 4) * 3, ("%zu\n", cchFilename), VERR_INVALID_PARAMETER); 1970 1971 const char *pszExt = ""; 1972 size_t cchExt = 0; 1973 if (!RTPathHaveExt(pszFilename)) 1974 { 1975 pszExt = RTLdrGetSuff(); 1976 cchExt = strlen(pszExt); 1977 } 1978 1979 /* 1980 * Construct the private arch path and check if the file exists. 1981 */ 1982 char szPath[RTPATH_MAX]; 1983 int rc = RTPathAppPrivateArch(szPath, sizeof(szPath) - 1 - cchExt - cchFilename); 1984 AssertRCReturn(rc, rc); 1985 1986 char *psz = strchr(szPath, '\0'); 1987 *psz++ = RTPATH_SLASH; 1988 memcpy(psz, pszFilename, cchFilename); 1989 psz += cchFilename; 1990 memcpy(psz, pszExt, cchExt + 1); 1991 1992 if (!RTPathExists(szPath)) 1993 { 1994 LogRel(("SUPR3HardenedLdrLoadAppPriv: \"%s\" not found\n", szPath)); 1995 return VERR_FILE_NOT_FOUND; 1996 } 1997 1998 /* 1999 * Pass it on to SUPR3HardenedLdrLoad. 2000 */ 2001 rc = SUPR3HardenedLdrLoad(szPath, phLdrMod); 2002 2003 LogFlow(("SUPR3HardenedLdrLoadAppPriv: returns %Rrc\n", rc)); 2004 return rc; 2005 } 2006 -
trunk/src/VBox/Main/ConsoleVRDPServer.cpp
r12127 r12423 1949 1949 if (!mVRDPLibrary) 1950 1950 { 1951 rc = RTLdrLoadAppSharedLib("VBoxVRDP", &mVRDPLibrary);1951 rc = SUPR3HardenedLdrLoadAppPriv ("VBoxVRDP", &mVRDPLibrary); 1952 1952 1953 1953 if (VBOX_SUCCESS(rc)) -
trunk/src/VBox/Main/hgcm/HGCM.cpp
r10807 r12423 131 131 static DECLCALLBACK(void) svcHlpCallComplete (VBOXHGCMCALLHANDLE callHandle, int32_t rc); 132 132 static DECLCALLBACK(void) svcHlpDisconnectClient (void *pvInstance, uint32_t u32ClientId); 133 133 134 134 public: 135 135 … … 253 253 } 254 254 255 int rc = RTLdrLoadAppSharedLib(m_pszSvcLibrary, &m_hLdrMod);255 int rc = SUPR3HardenedLdrLoadAppPriv (m_pszSvcLibrary, &m_hLdrMod); 256 256 257 257 if (VBOX_SUCCESS(rc)) … … 716 716 { 717 717 HGCMService *pService = static_cast <HGCMService *> (pvInstance); 718 718 719 719 if (pService) 720 720 { -
trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp
r11888 r12423 137 137 138 138 /** 139 * Loads a dynamic load library (/shared object) image file using native 140 * OS facilities. 141 * 142 * If the path is specified in the filename, only this path is used. 143 * If only the image file name is specified, then try to load it from: 144 * - RTPathAppPrivateArch 145 * - RTPathSharedLibs (legacy) 139 * Loads a dynamic load library (/shared object) image file residing in the 140 * RTPathAppPrivateArch() directory. 141 * 142 * Suffix is not required. 146 143 * 147 144 * @returns iprt status code. 148 * @param pszFilename Image filename. 145 * @param pszFilename Image filename. No path. 149 146 * @param phLdrMod Where to store the handle to the loaded module. 150 147 */ 151 RTDECL(int) RTLdrLoadApp SharedLib(const char *pszFilename, PRTLDRMOD phLdrMod)152 { 153 LogFlow(("RTLdrLoadApp SharedLib: pszFilename=%p:{%s} phLdrMod=%p\n", pszFilename, pszFilename, phLdrMod));148 RTDECL(int) RTLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod) 149 { 150 LogFlow(("RTLdrLoadAppPriv: pszFilename=%p:{%s} phLdrMod=%p\n", pszFilename, pszFilename, phLdrMod)); 154 151 155 152 /* 156 153 * Validate input. 157 154 */ 158 AssertMsgReturn(VALID_PTR(pszFilename), ("pszFilename=%p\n", pszFilename), VERR_INVALID_PARAMETER); 159 AssertMsgReturn(VALID_PTR(phLdrMod), ("phLdrMod=%p\n", phLdrMod), VERR_INVALID_PARAMETER); 160 161 /* 162 * If a path is specified, just load the file. 163 */ 164 if (RTPathHavePath(pszFilename)) 165 return RTLdrLoad(pszFilename, phLdrMod); 166 167 /* 168 * By default nothing is found. 169 */ 170 int rc = VERR_FILE_NOT_FOUND; 155 AssertPtrReturn(phLdrMod, VERR_INVALID_PARAMETER); 171 156 *phLdrMod = NIL_RTLDRMOD; 172 173 /* 174 * Try default locations. 175 */ 176 int i; 177 for (i = 0;; i++) 157 AssertPtrReturn(pszFilename, VERR_INVALID_PARAMETER); 158 AssertMsgReturn(!RTPathHavePath(pszFilename), ("%s\n", pszFilename), VERR_INVALID_PARAMETER); 159 160 /* 161 * Check the filename. 162 */ 163 size_t cchFilename = strlen(pszFilename); 164 AssertMsgReturn(cchFilename > (RTPATH_MAX / 4) * 3, ("%zu\n", cchFilename), VERR_INVALID_PARAMETER); 165 166 const char *pszExt = ""; 167 size_t cchExt = 0; 168 if (!RTPathHaveExt(pszFilename)) 178 169 { 179 /* 180 * Get the appropriate base path. 181 */ 182 char szBase[RTPATH_MAX]; 183 if (i == 0) 184 rc = RTPathAppPrivateArch(szBase, sizeof (szBase)); 185 else if (i == 1) 186 rc = RTPathSharedLibs(szBase, sizeof (szBase)); 187 else 188 break; 189 190 if (RT_SUCCESS(rc)) 191 { 192 /* 193 * Got the base path. Construct szPath = pszBase + pszFilename 194 */ 195 char szPath[RTPATH_MAX]; 196 rc = RTPathAbsEx(szBase, pszFilename, szPath, sizeof (szPath)); 197 if (RT_SUCCESS(rc)) 198 { 199 /* 200 * Finally try to load the image file. 201 */ 202 rc = RTLdrLoad(szPath, phLdrMod); 203 if (RT_SUCCESS(rc)) 204 { 205 /* 206 * Successfully loaded the image file. 207 */ 208 LogFlow(("Library loaded: [%s]\n", szPath)); 209 break; 210 } 211 } 212 } 170 pszExt = RTLdrGetSuff(); 171 cchExt = strlen(pszExt); 213 172 } 214 LogFlow(("RTLdrLoadAppSharedLib: returns %Rrc\n", rc)); 173 174 /* 175 * Construct the private arch path and check if the file exists. 176 */ 177 char szPath[RTPATH_MAX]; 178 int rc = RTPathAppPrivateArch(szPath, sizeof(szPath) - 1 - cchExt - cchFilename); 179 AssertRCReturn(rc, rc); 180 181 char *psz = strchr(szPath, '\0'); 182 *psz++ = RTPATH_SLASH; 183 memcpy(psz, pszFilename, cchFilename); 184 psz += cchFilename; 185 memcpy(psz, pszExt, cchExt + 1); 186 187 if (!RTPathExists(szPath)) 188 { 189 LogRel(("RTLdrLoadAppPriv: \"%s\" not found\n", szPath)); 190 return VERR_FILE_NOT_FOUND; 191 } 192 193 /* 194 * Pass it on to RTLdrLoad. 195 */ 196 rc = RTLdrLoad(szPath, phLdrMod); 197 198 LogFlow(("RTLdrLoadAppPriv: returns %Rrc\n", rc)); 215 199 return rc; 216 200 }
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器