netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: Check frag_lists first to prevent data out of order
@ 2015-08-27  0:56 chenweilong
  2015-08-27  2:12 ` Eric Dumazet
  0 siblings, 1 reply; 8+ messages in thread
From: chenweilong @ 2015-08-27  0:56 UTC (permalink / raw)
  To: davem, edumazet, alexander.h.duyck, willemb, hannes; +Cc: netdev

From: Weilong Chen <chenweilong@huawei.com>

When try to merge several skbs to prior one, if the frag_list is
used and the the last one is a small packet, once the condition
"len <= skb_tailroom(to)" is satisfied, we will get a wrong
packet!
This patch just check frag_lists before the condtion to prevent
this from happening.

Signed-off-by: Weilong Chen <chenweilong@huawei.com>
---
 net/core/skbuff.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 8a725cc..d08edcb 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4133,6 +4133,9 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
 	if (skb_cloned(to))
 		return false;
 
+	if (skb_has_frag_list(to) || skb_has_frag_list(from))
+		return false;
+
 	if (len <= skb_tailroom(to)) {
 		if (len)
 			BUG_ON(skb_copy_bits(from, 0, skb_put(to, len), len));
@@ -4140,9 +4143,6 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
 		return true;
 	}
 
-	if (skb_has_frag_list(to) || skb_has_frag_list(from))
-		return false;
-
 	if (skb_headlen(from) != 0) {
 		struct page *page;
 		unsigned int offset;
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-08-28  5:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-27  0:56 [PATCH net-next] net: Check frag_lists first to prevent data out of order chenweilong
2015-08-27  2:12 ` Eric Dumazet
2015-08-27  2:23   ` Eric Dumazet
2015-08-28  3:35     ` Weilong Chen
2015-08-28  4:26       ` David Miller
2015-08-28  5:34         ` Weilong Chen
2015-08-28  4:37       ` Eric Dumazet
2015-08-28  5:33         ` Weilong Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).