Skip to content

Commit 5ff8dda

Browse files
herbertxdavem330
authored andcommitted
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 <[email protected]> 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 <[email protected]> Acked-by: Rusty Russell <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4909122 commit 5ff8dda

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/core/skbuff.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,12 +3026,12 @@ EXPORT_SYMBOL_GPL(skb_tstamp_tx);
30263026
*/
30273027
bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off)
30283028
{
3029-
if (unlikely(start > skb->len - 2) ||
3030-
unlikely((int)start + off > skb->len - 2)) {
3029+
if (unlikely(start > skb_headlen(skb)) ||
3030+
unlikely((int)start + off > skb_headlen(skb) - 2)) {
30313031
if (net_ratelimit())
30323032
printk(KERN_WARNING
30333033
"bad partial csum: csum=%u/%u len=%u\n",
3034-
start, off, skb->len);
3034+
start, off, skb_headlen(skb));
30353035
return false;
30363036
}
30373037
skb->ip_summed = CHECKSUM_PARTIAL;

0 commit comments

Comments
 (0)