Fix hash table bogus read in ip6 vxlan-gpe 23/1323/3
authorFlorin Coras <fcoras@cisco.com>
Tue, 31 May 2016 12:53:44 +0000 (15:53 +0300)
committerChris Luke <chris_luke@cable.comcast.com>
Tue, 31 May 2016 19:38:50 +0000 (19:38 +0000)
- consistent use of hash_*_mem methods.
- tunnel setup copies the key from the wrong location
- remove extraneous storage for keys copied from the vxlan
  node that is not applicable here

Change-Id: I419fd30a52ba387104abe467c296de85233823d1
Signed-off-by: Florin Coras <fcoras@cisco.com>
Signed-off-by: Chris Luke <chrisy@flirble.org>
vnet/vnet/vxlan-gpe/vxlan_gpe.c
vnet/vnet/vxlan-gpe/vxlan_gpe.h

index e6565f4..2baf182 100644 (file)
@@ -228,7 +228,7 @@ int vnet_vxlan_gpe_add_del_tunnel
     key6.remote.as_u64[1] = a->remote.ip6.as_u64[1];
     key6.vni = clib_host_to_net_u32 (a->vni << 8);
 
-    p = hash_get(gm->vxlan6_gpe_tunnel_by_key, &key6);
+    p = hash_get_mem(gm->vxlan6_gpe_tunnel_by_key, &key6);
   }
   
   if (a->is_add)
@@ -250,11 +250,6 @@ int vnet_vxlan_gpe_add_del_tunnel
       else            foreach_copy_ipv6
 #undef _
 
-      if (a->is_ip6) {
-        /* copy the key */
-        t->key6 = key6;
-      }
-
       if (!a->is_ip6) t->flags |= VXLAN_GPE_TUNNEL_IS_IPV4;
 
       if (!a->is_ip6) {
@@ -279,8 +274,8 @@ int vnet_vxlan_gpe_add_del_tunnel
       else
       {
           key6_copy = clib_mem_alloc (sizeof (*key6_copy));
-          clib_memcpy (key6_copy, &key4, sizeof (*key6_copy));
-          hash_set_mem (gm->vxlan4_gpe_tunnel_by_key, key6_copy,
+          clib_memcpy (key6_copy, &key6, sizeof (*key6_copy));
+          hash_set_mem (gm->vxlan6_gpe_tunnel_by_key, key6_copy,
                         t - gm->tunnels);
       }
       
index be420b5..c733e21 100644 (file)
@@ -90,11 +90,6 @@ typedef struct {
   u32 hw_if_index;
   u32 sw_if_index;
 
-  union { /* storage for the hash key */
-       vxlan4_gpe_tunnel_key_t key4;
-       vxlan6_gpe_tunnel_key_t key6;
-  };
-
   /* flags */
   u32 flags;
 } vxlan_gpe_tunnel_t;