aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2012-10-06 18:28:06 -0400
committerDavid S. Miller <davem@davemloft.net>2012-10-07 14:49:17 -0400
commitca07e43e288956a0ad5e6bd075f7aa1fca3bca00 (patch)
treefa3b345f2940b257f7c1b5b268f2ee52926bcbf5 /net
parent51ec04038c113a811b177baa85d293feff9ce995 (diff)
net: gro: fix a potential crash in skb_gro_reset_offset
Before accessing skb first fragment, better make sure there is one. This is probably not needed for old kernels, since an ethernet frame cannot contain only an ethernet header, but the recent GRO addition to tunnels makes this patch needed. Also skb_gro_reset_offset() can be static, it actually allows compiler to inline it. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 1e0a1847c3bb..de2bad717d56 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3631,20 +3631,22 @@ gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb)
3631} 3631}
3632EXPORT_SYMBOL(napi_skb_finish); 3632EXPORT_SYMBOL(napi_skb_finish);
3633 3633
3634void skb_gro_reset_offset(struct sk_buff *skb) 3634static void skb_gro_reset_offset(struct sk_buff *skb)
3635{ 3635{
3636 const struct skb_shared_info *pinfo = skb_shinfo(skb);
3637 const skb_frag_t *frag0 = &pinfo->frags[0];
3638
3636 NAPI_GRO_CB(skb)->data_offset = 0; 3639 NAPI_GRO_CB(skb)->data_offset = 0;
3637 NAPI_GRO_CB(skb)->frag0 = NULL; 3640 NAPI_GRO_CB(skb)->frag0 = NULL;
3638 NAPI_GRO_CB(skb)->frag0_len = 0; 3641 NAPI_GRO_CB(skb)->frag0_len = 0;
3639 3642
3640 if (skb->mac_header == skb->tail && 3643 if (skb->mac_header == skb->tail &&
3641 !PageHighMem(skb_frag_page(&skb_shinfo(skb)->frags[0]))) { 3644 pinfo->nr_frags &&
3642 NAPI_GRO_CB(skb)->frag0 = 3645 !PageHighMem(skb_frag_page(frag0))) {
3643 skb_frag_address(&skb_shinfo(skb)->frags[0]); 3646 NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0);
3644 NAPI_GRO_CB(skb)->frag0_len = skb_frag_size(&skb_shinfo(skb)->frags[0]); 3647 NAPI_GRO_CB(skb)->frag0_len = skb_frag_size(frag0);
3645 } 3648 }
3646} 3649}
3647EXPORT_SYMBOL(skb_gro_reset_offset);
3648 3650
3649gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) 3651gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
3650{ 3652{