Zero padding bytes in odp_key_ipv4, odp_key_arp.
authorBen Pfaff <blp@nicira.com>
Tue, 1 Feb 2011 19:23:30 +0000 (11:23 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 3 Feb 2011 22:55:28 +0000 (14:55 -0800)
This is a potential security issue for the kernel.  In userspace it just
provokes false-positive valgrind warnings (which is how I found it).

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath/flow.c
lib/odp-util.c

index 9823b9f..735e147 100644 (file)
@@ -845,6 +845,7 @@ int flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                if (!nla)
                        goto nla_put_failure;
                ipv4_key = nla_data(nla);
+               memset(ipv4_key, 0, sizeof(struct odp_key_ipv4));
                ipv4_key->ipv4_src = swkey->ipv4_src;
                ipv4_key->ipv4_dst = swkey->ipv4_dst;
                ipv4_key->ipv4_proto = swkey->nw_proto;
@@ -856,6 +857,7 @@ int flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                if (!nla)
                        goto nla_put_failure;
                ipv6_key = nla_data(nla);
+               memset(ipv6_key, 0, sizeof(struct odp_key_ipv6));
                memcpy(ipv6_key->ipv6_src, swkey->ipv6_src,
                                sizeof(ipv6_key->ipv6_src));
                memcpy(ipv6_key->ipv6_dst, swkey->ipv6_dst,
@@ -869,6 +871,7 @@ int flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                if (!nla)
                        goto nla_put_failure;
                arp_key = nla_data(nla);
+               memset(arp_key, 0, sizeof(struct odp_key_arp));
                arp_key->arp_sip = swkey->ipv4_src;
                arp_key->arp_tip = swkey->ipv4_dst;
                arp_key->arp_op = htons(swkey->nw_proto);
index c90ff7d..973490d 100644 (file)
@@ -430,6 +430,7 @@ odp_flow_key_from_flow(struct ofpbuf *buf, const struct flow *flow)
 
         ipv4_key = nl_msg_put_unspec_uninit(buf, ODP_KEY_ATTR_IPV4,
                                             sizeof *ipv4_key);
+        memset(ipv4_key, 0, sizeof *ipv4_key);
         ipv4_key->ipv4_src = flow->nw_src;
         ipv4_key->ipv4_dst = flow->nw_dst;
         ipv4_key->ipv4_proto = flow->nw_proto;
@@ -439,6 +440,7 @@ odp_flow_key_from_flow(struct ofpbuf *buf, const struct flow *flow)
 
         ipv6_key = nl_msg_put_unspec_uninit(buf, ODP_KEY_ATTR_IPV6,
                                             sizeof *ipv6_key);
+        memset(ipv6_key, 0, sizeof *ipv6_key);
         memcpy(ipv6_key->ipv6_src, &flow->ipv6_src, sizeof ipv6_key->ipv6_src);
         memcpy(ipv6_key->ipv6_dst, &flow->ipv6_dst, sizeof ipv6_key->ipv6_dst);
         ipv6_key->ipv6_proto = flow->nw_proto;
@@ -448,6 +450,7 @@ odp_flow_key_from_flow(struct ofpbuf *buf, const struct flow *flow)
 
         arp_key = nl_msg_put_unspec_uninit(buf, ODP_KEY_ATTR_ARP,
                                            sizeof *arp_key);
+        memset(arp_key, 0, sizeof *arp_key);
         arp_key->arp_sip = flow->nw_src;
         arp_key->arp_tip = flow->nw_dst;
         arp_key->arp_op = htons(flow->nw_proto);