]> git.karo-electronics.de Git - karo-tx-linux.git/commit
Fix SKB_WITH_OVERHEAD calculations.
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 23 Oct 2007 10:08:26 +0000 (03:08 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 16 Nov 2007 16:27:36 +0000 (08:27 -0800)
commit8522b496f9d0e76a8b7e0b3a742f98ca6d182571
tree697d465707741af78596db2bda125b24529711bb
parentb354057389dd96fde7af3161e383150128579bc9
Fix SKB_WITH_OVERHEAD calculations.

patch deea84b0ae3d26b41502ae0a39fe7fe134e703d0 in mainline.

[NET]: Fix SKB_WITH_OVERHEAD calculation

The calculation in SKB_WITH_OVERHEAD is incorrect in that it can cause
an overflow across a page boundary which is what it's meant to prevent.
In particular, the header length (X) should not be lumped together with
skb_shared_info.  The latter needs to be aligned properly while the header
has no choice but to sit in front of wherever the payload is.

Therefore the correct calculation is to take away the aligned size of
skb_shared_info, and then subtract the header length.  The resulting
quantity L satisfies the following inequality:

SKB_DATA_ALIGN(L + X) + sizeof(struct skb_shared_info) <= PAGE_SIZE

This is the quantity used by alloc_skb to do the actual allocation.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
include/linux/skbuff.h