* skb_try_coalesce and fraglists (bug?)
@ 2015-02-04 16:33 Erik Hugne
2015-02-04 17:28 ` Eric Dumazet
0 siblings, 1 reply; 2+ messages in thread
From: Erik Hugne @ 2015-02-04 16:33 UTC (permalink / raw)
To: netdev; +Cc: mkubecek, ying.xue
skb_try_coalesce should bail out for a number of reasons, if the target skb is
cloned, doesn't have enough room, or if either source or target skb have
fraglists.
However, it seems that the skb_has_frag_list check is done too late, and a small
skb may be copied into the tailroom of the head, even if it has a fraglist.
Wouldn't this be more correct?
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 56db472..8d02140 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4056,6 +4056,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));
@@ -4063,9 +4066,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;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: skb_try_coalesce and fraglists (bug?)
2015-02-04 16:33 skb_try_coalesce and fraglists (bug?) Erik Hugne
@ 2015-02-04 17:28 ` Eric Dumazet
0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2015-02-04 17:28 UTC (permalink / raw)
To: Erik Hugne; +Cc: netdev, mkubecek, ying.xue
On Wed, 2015-02-04 at 17:33 +0100, Erik Hugne wrote:
> skb_try_coalesce should bail out for a number of reasons, if the target skb is
> cloned, doesn't have enough room, or if either source or target skb have
> fraglists.
>
> However, it seems that the skb_has_frag_list check is done too late, and a small
> skb may be copied into the tailroom of the head, even if it has a fraglist.
>
> Wouldn't this be more correct?
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 56db472..8d02140 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -4056,6 +4056,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));
> @@ -4063,9 +4066,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;
>
Patch is not needed.
If to had a fraglist, skb_tailroom(to) would be 0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-04 17:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-04 16:33 skb_try_coalesce and fraglists (bug?) Erik Hugne
2015-02-04 17:28 ` Eric Dumazet
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).