[ovs-dev] [PATCH 2/6] datapath: fix size of struct ovs_gso_cb

Pravin B Shelar pshelar at ovn.org
Wed Aug 3 17:08:10 UTC 2016


struct ovs_gso_cb is stored in skb->cd. avoid going beyond size
of skb->cb.

Signed-off-by: Pravin B Shelar <pshelar at ovn.org>
---
 datapath/linux/compat/gso.c | 1 +
 datapath/linux/compat/gso.h | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/datapath/linux/compat/gso.c b/datapath/linux/compat/gso.c
index 1f24e74..10412c0 100644
--- a/datapath/linux/compat/gso.c
+++ b/datapath/linux/compat/gso.c
@@ -171,6 +171,7 @@ static struct sk_buff *tnl_skb_gso_segment(struct sk_buff *skb,
 	__be16 proto = skb->protocol;
 	char cb[sizeof(skb->cb)];
 
+	BUILD_BUG_ON(sizeof(struct ovs_gso_cb) > FIELD_SIZEOF(struct sk_buff, cb));
 	OVS_GSO_CB(skb)->ipv6 = (sa_family == AF_INET6);
 	/* setup whole inner packet to get protocol. */
 	__skb_pull(skb, mac_offset);
diff --git a/datapath/linux/compat/gso.h b/datapath/linux/compat/gso.h
index fa0a7db..e93998c 100644
--- a/datapath/linux/compat/gso.h
+++ b/datapath/linux/compat/gso.h
@@ -14,6 +14,7 @@ struct ovs_gso_cb {
 #ifndef USE_UPSTREAM_TUNNEL_GSO
 	gso_fix_segment_t fix_segment;
 #endif
+	bool ipv6;
 #ifndef HAVE_INNER_PROTOCOL
 	__be16		inner_protocol;
 #endif
@@ -21,7 +22,6 @@ struct ovs_gso_cb {
 	/* Keep original tunnel info during userspace action execution. */
 	struct metadata_dst *fill_md_dst;
 #endif
-	bool ipv6;
 };
 #define OVS_GSO_CB(skb) ((struct ovs_gso_cb *)(skb)->cb)
 
-- 
1.9.1




More information about the dev mailing list