VirtualBox

Changeset 31323 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 2, 2010 6:18:22 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64354
Message:

SrvIntNetR0.cpp: Fixed lock order inversion in IntNetR0IfSetActive, must take the mutex before grabbing a (paranoid) busy reference.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r31322 r31323  
    37383738 *
    37393739 * This function will update the active interface count on the network and
    3740  * activate or deactivate the trunk connection if necessary.  Note that in
    3741  * order to do this it is necessary to abandond the network semaphore.
     3740 * activate or deactivate the trunk connection if necessary.
     3741 *
     3742 * The call must own the giant lock (we cannot take it here).
    37423743 *
    37433744 * @returns VBox status code.
     
    37573758     * to save us the extra hazzle.
    37583759     */
    3759     PINTNET         pIntNet = pNetwork->pIntNet;
    3760     int rc = RTSemMutexRequest(pIntNet->hMtxCreateOpenDestroy, RT_INDEFINITE_WAIT);
    3761     AssertRCReturn(rc, rc);
    3762 
    37633760    PINTNETTRUNKIF  pTrunk  = NULL;
    37643761    RTSPINLOCKTMP   Tmp     = RTSPINLOCKTMP_INITIALIZER;
     
    38063803    /*
    38073804     * Tell the trunk if necessary.
     3805     * The wait for !busy is for the Solaris streams trunk driver (mostly).
    38083806     */
    38093807    if (pTrunk && pTrunk->pIfPort)
     
    38143812        pTrunk->pIfPort->pfnSetState(pTrunk->pIfPort, fActive ? INTNETTRUNKIFSTATE_ACTIVE : INTNETTRUNKIFSTATE_INACTIVE);
    38153813    }
    3816 
    3817     RTSemMutexRelease(pIntNet->hMtxCreateOpenDestroy);
    38183814
    38193815    return VINF_SUCCESS;
     
    38513847     * tricky there wrt to locking order.
    38523848     *
    3853      * Note! We mark the interface busy so the network cannot be removed while
    3854      *       we're working on it - paranoia strikes again.
    3855      */
    3856     intnetR0BusyIncIf(pIf);
    3857 
    3858     int rc;
    3859     PINTNETNETWORK pNetwork = pIf->pNetwork;
    3860     if (pNetwork)
    3861         rc = intnetR0NetworkSetIfActive(pNetwork, pIf, fActive);
    3862     else
    3863         rc = VERR_WRONG_ORDER;
    3864 
    3865     intnetR0BusyDecIf(pIf);
     3849     * 1. We take the giant lock here.  This makes sure nobody is re-enabling
     3850     *    the network while we're pausing it and vice versa.  This also enables
     3851     *    us to wait for the network to become idle before telling the trunk.
     3852     *    (Important on Solaris.)
     3853     *
     3854     * 2. For paranoid reasons, we grab a busy reference to the calling
     3855     *    interface.  This is totally unnecessary but should hurt (when done
     3856     *    after grabbing the giant lock).
     3857     */
     3858    int rc = RTSemMutexRequest(pIntNet->hMtxCreateOpenDestroy, RT_INDEFINITE_WAIT);
     3859    if (RT_SUCCESS(rc))
     3860    {
     3861        intnetR0BusyIncIf(pIf);
     3862
     3863        PINTNETNETWORK pNetwork = pIf->pNetwork;
     3864        if (pNetwork)
     3865            rc = intnetR0NetworkSetIfActive(pNetwork, pIf, fActive);
     3866        else
     3867            rc = VERR_WRONG_ORDER;
     3868
     3869        intnetR0BusyDecIf(pIf);
     3870        RTSemMutexRelease(pIntNet->hMtxCreateOpenDestroy);
     3871    }
     3872
    38663873    intnetR0IfRelease(pIf, pSession);
     3874    LogFlow(("IntNetR0IfSetActive: returns %Rrc\n", rc));
    38673875    return rc;
    38683876}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette