From 219b5d87ae3e68d17107ffce5181bbd6e1a9790d Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 13 Sep 2011 17:48:44 +0100 Subject: [PATCH] gro: Only reset frag0 when skb can be pulled, CVE-2011-2723 Currently skb_gro_header_slow unconditionally resets frag0 and frag0_len. However, when we can't pull on the skb this leaves the GRO fields in an inconsistent state. This patch fixes this by only resetting those fields after the pskb_may_pull test. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller (cherry picked from commit 17dd759c67f21e34f2156abcf415e1f60605a188) CVE-2011-2723 BugLink: http://bugs.launchpad.net/bugs/844371 Signed-off-by: Andy Whitcroft Signed-off-by: Tim Gardner --- include/linux/netdevice.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 71caf7a..191e4aa 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1433,9 +1433,12 @@ static inline int skb_gro_header_hard(struct sk_buff *skb, unsigned int hlen) static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen, unsigned int offset) { + if (!pskb_may_pull(skb, hlen)) + return NULL; + NAPI_GRO_CB(skb)->frag0 = NULL; NAPI_GRO_CB(skb)->frag0_len = 0; - return pskb_may_pull(skb, hlen) ? skb->data + offset : NULL; + return skb->data + offset; } static inline void *skb_gro_mac_header(struct sk_buff *skb) -- 1.7.10.4