VirtualBox

Ignore:
Timestamp:
Nov 21, 2016 2:35:37 PM (8 years ago)
Author:
vboxsync
Message:

SUP,IPRT: If link time validation fails with VERR_CR_X509_CPV_NOT_VALID_AT_TIME, retry with current time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp

    r62677 r64731  
    10951095
    10961096/**
     1097 * RTTimeNow equivaltent that handles ring-3 where we cannot use it.
     1098 *
     1099 * @returns pNow
     1100 * @param   pNow                Where to return the current time.
     1101 */
     1102static PRTTIMESPEC supHardNtTimeNow(PRTTIMESPEC pNow)
     1103{
     1104#ifdef IN_RING3
     1105    /*
     1106     * Just read system time.
     1107     */
     1108    KUSER_SHARED_DATA volatile *pUserSharedData = (KUSER_SHARED_DATA volatile *)MM_SHARED_USER_DATA_VA;
     1109# ifdef RT_ARCH_AMD64
     1110    uint64_t uRet = *(uint64_t volatile *)&pUserSharedData->SystemTime; /* This is what KeQuerySystemTime does (missaligned). */
     1111    return RTTimeSpecSetNtTime(pNow, uRet);
     1112# else
     1113
     1114    LARGE_INTEGER NtTime;
     1115    do
     1116    {
     1117        NtTime.HighPart = pUserSharedData->SystemTime.High1Time;
     1118        NtTime.LowPart  = pUserSharedData->SystemTime.LowPart;
     1119    } while (pUserSharedData->SystemTime.High2Time != NtTime.HighPart);
     1120    return RTTimeSpecSetNtTime(pNow, NtTime.QuadPart);
     1121# endif
     1122#else  /* IN_RING0 */
     1123    return RTTimeNow(pNow);
     1124#endif /* IN_RING0 */
     1125}
     1126
     1127
     1128/**
    10971129 * Verifies the given loader image.
    10981130 *
     
    11731205     *         validations.  This works around issues with old DLLs that
    11741206     *         we sign against with our certificate (crt, sdl, qt).
     1207     *
     1208     * Update: If the validation fails, retry with the current timestamp. This
     1209     *         is a workaround for NTDLL.DLL in build 14971 having a weird
     1210     *         timestamp: 0xDF1E957E (Sat Aug 14 14:05:18 2088).
    11751211     */
    11761212    int rc = RTLdrQueryProp(hLdrMod, RTLDRPROP_TIMESTAMP_SECONDS, &pNtViRdr->uTimestamp, sizeof(pNtViRdr->uTimestamp));
     
    11901226            g_uBuildTimestampHack = pNtViRdr->uTimestamp;
    11911227#endif
     1228
     1229        if (rc == VERR_CR_X509_CPV_NOT_VALID_AT_TIME)
     1230        {
     1231            RTTIMESPEC Now;
     1232            uint64_t uOld = pNtViRdr->uTimestamp;
     1233            pNtViRdr->uTimestamp = RTTimeSpecGetSeconds(supHardNtTimeNow(&Now));
     1234            SUP_DPRINTF(("%ls: VERR_CR_X509_CPV_NOT_VALID_AT_TIME for %#RX64; retrying against current time: %#RX64.\n",
     1235                         pwszName, uOld, pNtViRdr->uTimestamp)); NOREF(uOld);
     1236            rc = RTLdrVerifySignature(hLdrMod, supHardNtViCallback, pNtViRdr, pErrInfo);
     1237        }
    11921238
    11931239        /*
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