mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
nwfilter: Resolve SEGV for NWFilter Snoop processing
https://bugzilla.redhat.com/show_bug.cgi?id=1599973
Commit id fca9afa08
changed the @req->ifname to use
@req->binding->portdevname fillingin the @req->binding
in a similar way that @req->ifname would have been
filled in during virNWFilterDHCPSnoopReq processing.
However, in doing so it did not take into account some
code paths where the @req->binding should be checked
instead of @req->binding->portdevname. These checks
led to SEGVs in some cases during libvirtd reload
processing in virNWFilterSnoopRemAllReqIter (for
stop during nwfilterStateCleanup processing) and
virNWFilterSnoopReqLeaseDel (for start during
nwfilterStateInitialize processing).
In particular, when reading the nwfilter.leases file
a new @req is created, but the @req->binding is not
filled in. That's left to virNWFilterDHCPSnoopReq
processing which checks if the @req already exists
in the @virNWFilterSnoopState.snoopReqs hash table
after adding a virNWFilterSnoopState.ifnameToKey
entry for the @req->binding->portdevname by a
@ref->ikey value.
NB: virNWFilterSnoopIPLeaseInstallRule and
virNWFilterDHCPSnoopThread do not need the
req->binding check since they can only be called
after the filter->binding is created/assigned.
Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
e6d3e46bb5
commit
5229494b01
@ -846,7 +846,7 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
virNWFilterSnoopIPLeasePtr ipl;
|
virNWFilterSnoopIPLeasePtr ipl;
|
||||||
char *ipstr = NULL;
|
char *ipstr = NULL;
|
||||||
int ipAddrLeft;
|
int ipAddrLeft = 0;
|
||||||
|
|
||||||
/* protect req->start, req->ifname and the lease */
|
/* protect req->start, req->ifname and the lease */
|
||||||
virNWFilterSnoopReqLock(req);
|
virNWFilterSnoopReqLock(req);
|
||||||
@ -867,6 +867,7 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
|
|||||||
if (update_leasefile)
|
if (update_leasefile)
|
||||||
virNWFilterSnoopLeaseFileSave(ipl);
|
virNWFilterSnoopLeaseFileSave(ipl);
|
||||||
|
|
||||||
|
if (req->binding)
|
||||||
ipAddrLeft = virNWFilterIPAddrMapDelIPAddr(req->binding->portdevname, ipstr);
|
ipAddrLeft = virNWFilterIPAddrMapDelIPAddr(req->binding->portdevname, ipstr);
|
||||||
|
|
||||||
if (!req->threadkey || !instantiate)
|
if (!req->threadkey || !instantiate)
|
||||||
@ -2037,7 +2038,7 @@ virNWFilterSnoopRemAllReqIter(const void *payload,
|
|||||||
/* protect req->binding->portdevname */
|
/* protect req->binding->portdevname */
|
||||||
virNWFilterSnoopReqLock(req);
|
virNWFilterSnoopReqLock(req);
|
||||||
|
|
||||||
if (req->binding->portdevname) {
|
if (req->binding && req->binding->portdevname) {
|
||||||
ignore_value(virHashRemoveEntry(virNWFilterSnoopState.ifnameToKey,
|
ignore_value(virHashRemoveEntry(virNWFilterSnoopState.ifnameToKey,
|
||||||
req->binding->portdevname));
|
req->binding->portdevname));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user