netdev-port: Fix invalid memory access in netdev_vport_poll_add().
authorBen Pfaff <blp@nicira.com>
Fri, 4 Mar 2011 21:44:35 +0000 (13:44 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 4 Mar 2011 21:58:03 +0000 (13:58 -0800)
shash_find_data() returns an shash_node's 'data' member, but this code here
wants the shash_node itself, so it needs to use shash_find() instead.

This bug meant that any attempt to add a single netdev_vport to more than
one netdev_monitor would cause a segmentation fault.  Here's an example
command that reproduces it reliably for me under valgrind (because ofproto
always monitors its ports and the bridge monitors bond interfaces):

ovs-vsctl -- add-bond br0 bond0 p0 p1 \
          -- set interface p0 type=patch options:peer=p1 \
          -- set interface p1 type=patch options:peer=p0

Bug #4527.
Reported-by: Krishna Miriyala <krishna@nicira.com>
lib/netdev-vport.c

index ae043c2..c6d4db8 100644 (file)
@@ -502,7 +502,7 @@ netdev_vport_poll_add(struct netdev *netdev,
     struct list *list;
     struct shash_node *shash_node;
 
-    shash_node = shash_find_data(&netdev_vport_notifiers, poll_name);
+    shash_node = shash_find(&netdev_vport_notifiers, poll_name);
     if (!shash_node) {
         list = xmalloc(sizeof *list);
         list_init(list);