• D
    Add a mutex to serialize updates to firewall · df573e50
    Daniel P. Berrange 提交于
    The nwfilter conf update mutex previously serialized
    updates to the internal data structures for firewall
    rules, and updates to the firewall itself. The latter
    was recently turned into a read/write lock, and filter
    instantiation allowed to proceed in parallel. It was
    believed that this was ok, since each filter is created
    on a separate iptables/ebtables chain.
    
    It turns out that there is a subtle lock ordering problem
    on virNWFilterObjPtr instances. __virNWFilterInstantiateFilter
    will hold a lock on the virNWFilterObjPtr it is instantiating.
    This in turn invokes virNWFilterInstantiate which then invokes
    virNWFilterDetermineMissingVarsRec which then invokes
    virNWFilterObjFindByName. This iterates over every single
    virNWFilterObjPtr in the list, locking them and checking their
    name. So if 2 or more threads try to instantiate a filter in
    parallel, they'll all hold 1 lock at the top level in the
    __virNWFilterInstantiateFilter method which will cause the
    other thread to deadlock in virNWFilterObjFindByName.
    
    The fix is to add an exclusive mutex to serialize the
    execution of __virNWFilterInstantiateFilter.
    Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
    (cherry picked from commit 925de19e)
    df573e50
nwfilter_gentech_driver.h 2.6 KB