VirtualBox

Changeset 57501 in vbox


Ignore:
Timestamp:
Aug 22, 2015 7:15:54 PM (9 years ago)
Author:
vboxsync
Message:

VERR_SUP_VP_NOT_BUILD_CERT_IPE: Dump the certificates. This requires message box changes in TrustedError as it would easily grow to large otherwise.

Location:
trunk/src/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r56916 r57501  
    4343
    4444# include <iprt/buildconfig.h>
     45# include <iprt/ctype.h>
    4546# include <iprt/initterm.h>
    4647# include <iprt/process.h>
     
    625626#else  /* VBOX_WITH_HARDENING */
    626627
     628
     629/**
     630 * Special entrypoint used by the hardening code when something goes south.
     631 *
     632 * Display an error dialog to the user.
     633 *
     634 * @param   pszWhere    Indicates where the error occured.
     635 * @param   enmWhat     Indicates what init operation was going on at the time.
     636 * @param   rc          The VBox status code corresponding to the error.
     637 * @param   pszMsgFmt   The message format string.
     638 * @param   va          Format arguments.
     639 */
    627640extern "C" DECLEXPORT(void) TrustedError(const char *pszWhere, SUPINITOP enmWhat, int rc, const char *pszMsgFmt, va_list va)
    628641{
     
    630643    ShutUpAppKit();
    631644# endif /* RT_OS_DARWIN */
    632 
    633     /* We have to create QApplication anyway just to show the only one error-message.
    634      * This is a bit hackish as we don't have the argument vector handy. */
     645    char szMsgBuf[_16K];
     646
     647    /*
     648     * We have to create QApplication anyway just to show the only one error-message.
     649     * This is a bit hackish as we don't have the argument vector handy.
     650     */
    635651    int argc = 0;
    636652    char *argv[2] = { NULL, NULL };
    637653    QApplication a(argc, &argv[0]);
    638654
    639     /* Prepare the error-message: */
    640     QString strTitle = QApplication::tr("VirtualBox - Error In %1").arg(pszWhere);
    641 
    642     char szMsgBuf[1024];
     655    /*
     656     * The details starts off a properly formatted rc and where/what, we use
     657     * the szMsgBuf for this, thus this have to come before the actual message
     658     * formatting.
     659     */
     660    RTStrPrintf(szMsgBuf, sizeof(szMsgBuf),
     661                "<!--EOM-->"
     662                "where: %s\n"
     663                "what:  %d\n"
     664                "%Rra\n",
     665                pszWhere, enmWhat, rc);
     666    QString strDetails = szMsgBuf;
     667
     668    /*
     669     * Format the error message. Take whatever comes after a double new line as
     670     * something better off in the details section.
     671     */
    643672    RTStrPrintfV(szMsgBuf, sizeof(szMsgBuf), pszMsgFmt, va);
     673
     674    char *pszDetails = strstr(szMsgBuf, "\n\n");
     675    if (pszDetails)
     676    {
     677        while (RT_C_IS_SPACE(*pszDetails))
     678            *pszDetails++ = '\0';
     679        if (*pszDetails)
     680        {
     681            strDetails += "\n";
     682            strDetails += pszDetails;
     683        }
     684        RTStrStripR(szMsgBuf);
     685    }
     686
    644687    QString strText = QApplication::tr("<html><b>%1 (rc=%2)</b><br/><br/>").arg(szMsgBuf).arg(rc);
    645688    strText.replace(QString("\n"), QString("<br>"));
    646689
     690    /*
     691     * Append possibly helpful hints to the error message.
     692     */
    647693    switch (enmWhat)
    648694    {
     
    681727    strText += "</html>";
    682728
     729
    683730# ifdef RT_OS_LINUX
    684     /* We have to to make sure that we display the error-message
    685      * after the parent displayed its own message. */
     731    /*
     732     * We have to to make sure that we display the error-message
     733     * after the parent displayed its own message.
     734     */
    686735    sleep(2);
    687 # endif /* RT_OS_LINUX */
    688 
    689     QMessageBox::critical(0 /* parent */, strTitle, strText,
    690                           QMessageBox::Abort /* 1st button */, 0 /* 2nd button */);
     736# endif
     737
     738    /*
     739     * Create the message box and show it.
     740     */
     741    QString strTitle = QApplication::tr("VirtualBox - Error In %1").arg(pszWhere);
     742    QIMessageBox msgBox(strTitle, strText, AlertIconType_Critical, AlertButton_Ok | AlertButtonOption_Default);
     743    if (!strDetails.isEmpty())
     744        msgBox.setDetailsText(strDetails);
     745
     746    msgBox.exec();
     747
    691748    qFatal("%s", strText.toUtf8().constData());
    692749}
     
    694751#endif /* VBOX_WITH_HARDENING */
    695752
     753
  • trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp

    r57456 r57501  
    157157    uint32_t        cchErrorInfo;
    158158    /** The error info. */
    159     char            szErrorInfo[2048];
     159    char            szErrorInfo[16384 - sizeof(RTLISTNODE) - sizeof(HANDLE)*2 - sizeof(uint64_t) - sizeof(uint32_t) - 0x20];
    160160} SUPDRVNTERRORINFO;
    161161/** Pointer to error info. */
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp

    r57358 r57501  
    921921
    922922/**
    923  * @callback_method_impl{RTCRPKCS7VERIFYCERTCALLBACK,
     923 * @callback_method_impl{FNRTDUMPPRINTFV, Formats into RTERRINFO. }
     924 */
     925static DECLCALLBACK(void) supHardNtViAsn1DumpToErrInfo(void *pvUser, const char *pszFormat, va_list va)
     926{
     927    PRTERRINFO pErrInfo = (PRTERRINFO)pvUser;
     928    RTErrInfoAddV(pErrInfo, pErrInfo->rc, pszFormat, va);
     929}
     930
     931
     932/**
     933 * @callback_method_impl{FNRTCRPKCS7VERIFYCERTCALLBACK,
    924934 * Standard code signing.  Use this for Microsoft SPC.}
    925935 */
     
    939949        if (RTCrX509Certificate_Compare(pCert, &g_BuildX509Cert) == 0) /* healthy paranoia */
    940950            return VINF_SUCCESS;
    941         return RTErrInfoSetF(pErrInfo, VERR_SUP_VP_NOT_BUILD_CERT_IPE, "Not valid kernel code signature.");
     951        int rc = RTErrInfoSetF(pErrInfo, VERR_SUP_VP_NOT_BUILD_CERT_IPE, "Not valid kernel code signature (fFlags=%#x).", fFlags);
     952        if (pErrInfo)
     953        {
     954            RTErrInfoAdd(pErrInfo, rc, "\n\nExe cert:\n");
     955            RTAsn1Dump(&pCert->SeqCore.Asn1Core, 0 /*fFlags*/, 0 /*uLevel*/, supHardNtViAsn1DumpToErrInfo, pErrInfo);
     956            RTErrInfoAdd(pErrInfo, rc, "\n\nBuild cert:\n");
     957            RTAsn1Dump(&g_BuildX509Cert.SeqCore.Asn1Core, 0 /*fFlags*/, 0 /*uLevel*/, supHardNtViAsn1DumpToErrInfo, pErrInfo);
     958        }
     959        return rc;
    942960    }
    943961
  • trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp

    r57358 r57501  
    217217    char                        szWhere[80];
    218218    /** Error message / path name string space. */
    219     char                        szErrorMsg[4096];
     219    char                        szErrorMsg[16384+1024];
    220220} SUPR3WINPROCPARAMS;
    221221
     
    43654365         * better chance resolving the issue.
    43664366         */
    4367         char szErrorInfo[_4K];
     4367        char szErrorInfo[16384];
    43684368        int rc = VERR_OPEN_FAILED;
    43694369        if (SUP_NT_STATUS_IS_VBOX(rcNt)) /* See VBoxDrvNtErr2NtStatus. */
     
    44114411                                  "NtCreateFile(%ls) failed: %Rrc (rcNt=%#x)%s", s_wszName, rc, rcNt,
    44124412                                  supR3HardenedWinReadErrorInfoDevice(szErrorInfo, sizeof(szErrorInfo),
    4413                                                                     "\nVBoxDrvStub error: "));
     4413                                                                      "\nVBoxDrvStub error: "));
    44144414        }
    44154415        else
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