libvirt/src/nwfilter
Daniel P. Berrange ac903dbdc7 Add a mutex to serialize updates to firewall
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: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 925de19ed7)
2014-03-10 12:25:24 +00:00
..
nwfilter_dhcpsnoop.c Don't pass virConnectPtr in nwfilter 'struct domUpdateCBStruct' 2014-02-06 12:46:58 +02:00
nwfilter_dhcpsnoop.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
nwfilter_driver.c Add a mutex to serialize updates to firewall 2014-03-10 12:25:24 +00:00
nwfilter_driver.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
nwfilter_ebiptables_driver.c nwfilter: Use -m conntrack rather than -m state 2013-08-06 20:30:46 -04:00
nwfilter_ebiptables_driver.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
nwfilter_gentech_driver.c Add a mutex to serialize updates to firewall 2014-03-10 12:25:24 +00:00
nwfilter_gentech_driver.h Add a mutex to serialize updates to firewall 2014-03-10 12:25:24 +00:00
nwfilter_learnipaddr.c Don't pass virConnectPtr in nwfilter 'struct domUpdateCBStruct' 2014-02-06 12:46:58 +02:00
nwfilter_learnipaddr.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00