netdev-dummy: fix crash with more than one passive connection
authorLance Richardson <lrichard@redhat.com>
Wed, 6 Jul 2016 23:39:52 +0000 (19:39 -0400)
committerBen Pfaff <blp@ovn.org>
Fri, 22 Jul 2016 22:16:35 +0000 (15:16 -0700)
commit7778360b0bc6a6bf551da1eff5957662e9feb848
tree7e2ccecb7bef09c0ff066ced35b04fba8941b2f6
parent29dd784d7634e98f16728343df2e57e9fd9d26f2
netdev-dummy: fix crash with more than one passive connection

Investigation found that Some of the occasional failures in the
"ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS" test case are caused
by ovs-vswitchd crashing with SIGSEGV. It turns out that the
crash occurrs when the number of netdev-dummy passive connections
transitions from 1 to 2.  When xrealloc() copies the array of
dummy_packet_stream structures from the original buffer to a
newly allocated one, the struct ovs_list txq member of the structure
becomes corrupt (e.g. if ovs_list_is_empty() would have returned
false before the copy, it will return true after the copy, which
will lead to a crash when the bogus packet buffer on the list is
dereferenced).

Fix by taking a hint from David Wheeler and adding a level of
indirection.

Signed-off-by: Lance Richardson <lrichard@redhat.com>
[blp@ovn.org folded in an additional bug fix]
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/netdev-dummy.c