Changeset 51868 in vbox
- Timestamp:
- Jul 4, 2014 1:35:22 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/Makefile.kmk
r51857 r51868 289 289 $(VBOX_PATH_RUNTIME_SRC)/common/misc/RTAssertMsg2Weak.cpp \ 290 290 $(VBOX_PATH_RUNTIME_SRC)/common/misc/RTAssertMsg2WeakV.cpp \ 291 $(VBOX_PATH_RUNTIME_SRC)/common/misc/zero.asm \ 291 292 $(VBOX_PATH_RUNTIME_SRC)/common/string/memchr.asm \ 292 293 $(VBOX_PATH_RUNTIME_SRC)/common/string/memcmp.asm \ -
trunk/src/VBox/Runtime/Makefile.kmk
r51862 r51868 433 433 common/misc/term.cpp \ 434 434 common/misc/uri.cpp \ 435 common/misc/zero.asm \ 435 436 common/net/netaddrstr2.cpp \ 436 437 common/net/macstr.cpp \ … … 2056 2057 common/path/RTPathChangeToUnixSlashes.cpp \ 2057 2058 common/math/bignum.cpp \ 2059 common/misc/zero.asm \ 2058 2060 common/string/RTStrPrintHexBytes.cpp \ 2059 2061 common/string/RTUtf16Copy.cpp \ -
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r51862 r51868 43 43 #include <iprt/string.h> 44 44 #ifndef IPRT_WITHOUT_LDR_VERIFY 45 #include <iprt/zero.h> 45 46 # include <iprt/crypto/pkcs7.h> 46 47 # include <iprt/crypto/spc.h> … … 2153 2154 if (cPages * (cbHash + 4) != pAttrib->u.pPageHashes->RawData.Asn1Core.cb) 2154 2155 return RTErrInfoSetF(pErrInfo, VERR_LDRVI_PAGE_HASH_TAB_SIZE_OVERFLOW, 2155 "Page Hashes V2size issue: cb=%#x cbHash=%#x",2156 "Page hashes size issue: cb=%#x cbHash=%#x", 2156 2157 pAttrib->u.pPageHashes->RawData.Asn1Core.cb, cbHash); 2157 2158 … … 2164 2165 2165 2166 uint32_t offPrev = 0; 2167 #ifdef COMPLICATED_AND_WRONG 2166 2168 uint32_t offSectEnd = pModPe->cbHeaders; 2167 2169 uint32_t iSh = UINT32_MAX; 2170 #endif 2168 2171 uint8_t const *pbHashTab = pAttrib->u.pPageHashes->RawData.Asn1Core.uData.pu8; 2169 2172 for (uint32_t iPage = 0; iPage < cPages; iPage++) 2170 2173 { 2171 2174 /* Decode the page offset. */ 2172 uint32_t const off File = RT_MAKE_U32_FROM_U8(pbHashTab[0], pbHashTab[1], pbHashTab[2], pbHashTab[3]);2173 if (off File >= SpecialPlaces.cbToHash)2175 uint32_t const offPageInFile = RT_MAKE_U32_FROM_U8(pbHashTab[0], pbHashTab[1], pbHashTab[2], pbHashTab[3]); 2176 if (offPageInFile >= SpecialPlaces.cbToHash) 2174 2177 { 2175 2178 /* The last entry is zero. */ 2176 if ( off File== SpecialPlaces.cbToHash2179 if ( offPageInFile == SpecialPlaces.cbToHash 2177 2180 && iPage + 1 == cPages 2178 2181 && ASMMemIsAll8(pbHashTab + 4, cbHash, 0) == NULL) … … 2180 2183 return RTErrInfoSetF(pErrInfo, VERR_LDRVI_PAGE_HASH_TAB_TOO_LONG, 2181 2184 "Page hash entry #%u is beyond the signature table start: %#x, %#x", 2182 iPage, off File, SpecialPlaces.cbToHash);2183 } 2184 if (off File < offPrev)2185 iPage, offPageInFile, SpecialPlaces.cbToHash); 2186 } 2187 if (offPageInFile < offPrev) 2185 2188 return RTErrInfoSetF(pErrInfo, VERR_LDRVI_PAGE_HASH_TAB_NOT_STRICTLY_SORTED, 2186 2189 "Page hash table is not strictly sorted: entry #%u @%#x, previous @%#x\n", 2187 iPage, offFile, offPrev); 2188 2190 iPage, offPageInFile, offPrev); 2191 2192 #ifdef COMPLICATED_AND_WRONG 2189 2193 /* Figure out how much to read and how much to zero. Need keep track 2190 2194 of the on-disk section boundraries. */ 2191 if (off File >= offSectEnd)2195 if (offPageInFile >= offSectEnd) 2192 2196 { 2193 2197 iSh++; 2194 2198 if ( iSh < pModPe->cSections 2195 && off File - pModPe->paSections[iSh].PointerToRawData < pModPe->paSections[iSh].SizeOfRawData)2199 && offPageInFile - pModPe->paSections[iSh].PointerToRawData < pModPe->paSections[iSh].SizeOfRawData) 2196 2200 offSectEnd = pModPe->paSections[iSh].PointerToRawData + pModPe->paSections[iSh].SizeOfRawData; 2197 2201 else … … 2199 2203 iSh = 0; 2200 2204 while ( iSh < pModPe->cSections 2201 && off File - pModPe->paSections[iSh].PointerToRawData >= pModPe->paSections[iSh].SizeOfRawData)2205 && offPageInFile - pModPe->paSections[iSh].PointerToRawData >= pModPe->paSections[iSh].SizeOfRawData) 2202 2206 iSh++; 2203 2207 if (iSh < pModPe->cSections) … … 2205 2209 else 2206 2210 return RTErrInfoSetF(pErrInfo, VERR_PAGE_HASH_TAB_HASHES_NON_SECTION_DATA, 2207 "Page hash entry #%u isn't in any section: %#x", iPage, offFile); 2208 } 2209 } 2210 2211 uint32_t cbRead = _4K; 2212 if (offFile + cbRead > offSectEnd) 2213 cbRead = offSectEnd - offFile; 2214 2215 if (offFile + cbRead > SpecialPlaces.cbToHash) 2216 cbRead = SpecialPlaces.cbToHash - offFile; 2211 "Page hash entry #%u isn't in any section: %#x", iPage, offPageInFile); 2212 } 2213 } 2214 2215 #else 2216 /* Figure out how much to read and how much take as zero. Use the next 2217 page offset and the signature as upper boundraries. */ 2218 #endif 2219 uint32_t cbPageInFile = _4K; 2220 #ifdef COMPLICATED_AND_WRONG 2221 if (offPageInFile + cbPageInFile > offSectEnd) 2222 cbPageInFile = offSectEnd - offPageInFile; 2223 #else 2224 if (iPage + 1 < cPages) 2225 { 2226 uint32_t offNextPage = RT_MAKE_U32_FROM_U8(pbHashTab[0 + 4 + cbHash], pbHashTab[1 + 4 + cbHash], 2227 pbHashTab[2 + 4 + cbHash], pbHashTab[3 + 4 + cbHash]); 2228 if (offNextPage - offPageInFile < cbPageInFile) 2229 cbPageInFile = offNextPage - offPageInFile; 2230 } 2231 #endif 2232 2233 if (offPageInFile + cbPageInFile > SpecialPlaces.cbToHash) 2234 cbPageInFile = SpecialPlaces.cbToHash - offPageInFile; 2217 2235 2218 2236 /* Did we get a cache hit? */ 2219 2237 uint8_t *pbCur = (uint8_t *)pvScratch; 2220 if ( off File + cbRead<= offScratchRead + cbScratchRead2221 && off File >= offScratchRead)2222 pbCur += off File - offScratchRead;2238 if ( offPageInFile + cbPageInFile <= offScratchRead + cbScratchRead 2239 && offPageInFile >= offScratchRead) 2240 pbCur += offPageInFile - offScratchRead; 2223 2241 /* Missed, read more. */ 2224 2242 else 2225 2243 { 2226 offScratchRead = offFile; 2227 cbScratchRead = offSectEnd - offFile; 2244 offScratchRead = offPageInFile; 2245 #ifdef COMPLICATED_AND_WRONG 2246 cbScratchRead = offSectEnd - offPageInFile; 2247 #else 2248 cbScratchRead = SpecialPlaces.cbToHash - offPageInFile; 2249 #endif 2228 2250 if (cbScratchRead > cbScratchReadMax) 2229 2251 cbScratchRead = cbScratchReadMax; … … 2235 2257 } 2236 2258 2237 /* Zero any additional bytes in the page. */2238 if (cbRead != _4K)2239 memset(pbCur + cbRead, 0, _4K - cbRead);2240 2241 2259 /* 2242 2260 * Hash it. … … 2247 2265 2248 2266 /* Deal with special places. */ 2249 uint32_t cbLeft = _4K;2250 if (off File < SpecialPlaces.offEndSpecial)2251 { 2252 uint32_t off = off File;2267 uint32_t cbLeft = cbPageInFile; 2268 if (offPageInFile < SpecialPlaces.offEndSpecial) 2269 { 2270 uint32_t off = offPageInFile; 2253 2271 if (off < SpecialPlaces.offCksum) 2254 2272 { … … 2291 2309 2292 2310 rtLdrPE_HashUpdate(&HashCtx, enmDigest, pbCur, cbLeft); 2311 if (cbPageInFile < _4K) 2312 rtLdrPE_HashUpdate(&HashCtx, enmDigest, &g_abRTZero4K[cbPageInFile], _4K - cbPageInFile); 2293 2313 2294 2314 /* … … 2301 2321 if (memcmp(pbHashTab, &HashRes, cbHash) != 0) 2302 2322 return RTErrInfoSetF(pErrInfo, VERR_LDRVI_PAGE_HASH_MISMATCH, 2303 "Page hash v2failed for page #%u, @%#x, %#x bytes: %.*Rhxs != %.*Rhxs",2304 iPage, off File, cbRead, (size_t)cbHash, pbHashTab, (size_t)cbHash, &HashRes);2323 "Page hash failed for page #%u, @%#x, %#x bytes: %.*Rhxs != %.*Rhxs", 2324 iPage, offPageInFile, cbPageInFile, (size_t)cbHash, pbHashTab, (size_t)cbHash, &HashRes); 2305 2325 pbHashTab += cbHash; 2306 offPrev = off File;2326 offPrev = offPageInFile; 2307 2327 } 2308 2328
Note:
See TracChangeset
for help on using the changeset viewer.