aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-06-03 21:22:01 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-08 03:20:19 -0400
commit5ff8dda3035d95df5bf6979136eb82b0e301726b (patch)
tree81e78b26cc50de421683cd896ed15aae4d6f107e /net
parent4909122fb8350e70c347f1201256908a92058044 (diff)
net: Ensure partial checksum offset is inside the skb head
On Thu, Jun 04, 2009 at 09:06:00PM +1000, Herbert Xu wrote: > > tun: Optimise handling of bogus gso->hdr_len > > As all current versions of virtio_net generate a value for the > header length that's too small, we should optimise this so that > we don't copy it twice. This can be done by ensuring that it is > at least as large as the place where we'll write the checksum. > > Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> With this applied we can strengthen the partial checksum check: In skb_partial_csum_set we check to see if the checksum offset is within the packet. However, we really should check that it is within the skb head as that's the only bit we can modify without copying. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Acked-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/skbuff.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 6adf19ec95cc..a2473b1600e3 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3026,12 +3026,12 @@ EXPORT_SYMBOL_GPL(skb_tstamp_tx);
3026 */ 3026 */
3027bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off) 3027bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off)
3028{ 3028{
3029 if (unlikely(start > skb->len - 2) || 3029 if (unlikely(start > skb_headlen(skb)) ||
3030 unlikely((int)start + off > skb->len - 2)) { 3030 unlikely((int)start + off > skb_headlen(skb) - 2)) {
3031 if (net_ratelimit()) 3031 if (net_ratelimit())
3032 printk(KERN_WARNING 3032 printk(KERN_WARNING
3033 "bad partial csum: csum=%u/%u len=%u\n", 3033 "bad partial csum: csum=%u/%u len=%u\n",
3034 start, off, skb->len); 3034 start, off, skb_headlen(skb));
3035 return false; 3035 return false;
3036 } 3036 }
3037 skb->ip_summed = CHECKSUM_PARTIAL; 3037 skb->ip_summed = CHECKSUM_PARTIAL;