VirtualBox

Changeset 94840 in vbox


Ignore:
Timestamp:
May 5, 2022 10:35:12 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
151239
Message:

Main/VirtualBoxImpl: Fix a possible lock order violation when the Machine object calls into the parent VirtualBox object when trying to retain the cryptographic interface, bugref:9955

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r94737 r94840  
    455455    /** Pointer to the cryptographic support interface. */
    456456    PCVBOXCRYPTOIF                      pCryptoIf;
     457    /** Critical section protecting the module handle. */
     458    RTCRITSECT                          CritSectModCrypto;
    457459    /** @} */
    458460};
     
    570572
    571573        i_reportDriverVersions();
     574
     575        /* Create the critical section protecting the cryptographic module handle. */
     576        {
     577            int vrc = RTCritSectInit(&m->CritSectModCrypto);
     578            if (RT_FAILURE(vrc))
     579                throw setErrorBoth(E_FAIL, vrc,
     580                                   tr("Could not create the cryptographic module critical section (%Rrc)"),
     581                                   vrc);
     582
     583        }
    572584
    573585        /* compose the VirtualBox.xml file name */
     
    10961108    }
    10971109
     1110    RTCritSectDelete(&m->CritSectModCrypto);
     1111
    10981112#ifdef VBOX_WITH_EXTPACK
    10991113    if (m->ptrExtPackManager)
     
    61306144    AssertComRCReturnRC(autoCaller.rc());
    61316145
    6132     AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);
     6146    /*
     6147     * No object lock due to some lock order fun with Machine objects.
     6148     * There is a dedicated critical section to protect against concurrency
     6149     * issues when loading the module.
     6150     */
     6151    RTCritSectEnter(&m->CritSectModCrypto);
    61336152
    61346153    /* Try to load the extension pack module if it isn't currently. */
     
    61946213    }
    61956214
     6215    RTCritSectLeave(&m->CritSectModCrypto);
     6216
    61966217    return hrc;
    61976218}
     
    62106231    AutoCaller autoCaller(this);
    62116232    AssertComRCReturnRC(autoCaller.rc());
    6212 
    6213     AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);
    62146233
    62156234    AssertReturn(pCryptoIf == m->pCryptoIf, E_INVALIDARG);
     
    62386257                        tr("The cryptographic support module is in use and can't be unloaded"));
    62396258
     6259    RTCritSectEnter(&m->CritSectModCrypto);
    62406260    if (m->hLdrModCrypto != NIL_RTLDRMOD)
    62416261    {
     
    62446264        m->hLdrModCrypto = NIL_RTLDRMOD;
    62456265    }
     6266    RTCritSectLeave(&m->CritSectModCrypto);
    62466267
    62476268    return S_OK;
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