aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-12-03 16:39:53 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-04 13:20:39 -0500
commit117632e64d2a5f464e491fe221d7169a3814a77b (patch)
tree88f3a036305da54a62835d900553dda9bc846a8f /include/linux/skbuff.h
parentc2e4e25afcc8ae1835a6100089f1f9fd3a362430 (diff)
tcp: take care of misalignments
We discovered that TCP stack could retransmit misaligned skbs if a malicious peer acknowledged sub MSS frame. This currently can happen only if output interface is non SG enabled : If SG is enabled, tcp builds headless skbs (all payload is included in fragments), so the tcp trimming process only removes parts of skb fragments, header stay aligned. Some arches cant handle misalignments, so force a head reallocation and shrink headroom to MAX_TCP_HEADER. Dont care about misaligments on x86 and PPC (or other arches setting NET_IP_ALIGN to 0) This patch introduces __pskb_copy() which can specify the headroom of new head, and pskb_copy() becomes a wrapper on top of __pskb_copy() Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index cec0657d0d32..12e6fed73f8e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -568,8 +568,9 @@ extern struct sk_buff *skb_clone(struct sk_buff *skb,
568 gfp_t priority); 568 gfp_t priority);
569extern struct sk_buff *skb_copy(const struct sk_buff *skb, 569extern struct sk_buff *skb_copy(const struct sk_buff *skb,
570 gfp_t priority); 570 gfp_t priority);
571extern struct sk_buff *pskb_copy(struct sk_buff *skb, 571extern struct sk_buff *__pskb_copy(struct sk_buff *skb,
572 gfp_t gfp_mask); 572 int headroom, gfp_t gfp_mask);
573
573extern int pskb_expand_head(struct sk_buff *skb, 574extern int pskb_expand_head(struct sk_buff *skb,
574 int nhead, int ntail, 575 int nhead, int ntail,
575 gfp_t gfp_mask); 576 gfp_t gfp_mask);
@@ -1799,6 +1800,12 @@ static inline dma_addr_t skb_frag_dma_map(struct device *dev,
1799 frag->page_offset + offset, size, dir); 1800 frag->page_offset + offset, size, dir);
1800} 1801}
1801 1802
1803static inline struct sk_buff *pskb_copy(struct sk_buff *skb,
1804 gfp_t gfp_mask)
1805{
1806 return __pskb_copy(skb, skb_headroom(skb), gfp_mask);
1807}
1808
1802/** 1809/**
1803 * skb_clone_writable - is the header of a clone writable 1810 * skb_clone_writable - is the header of a clone writable
1804 * @skb: buffer to check 1811 * @skb: buffer to check