All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon Maloy <jon.maloy@ericsson.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	Erik Hugne <erik.hugne@ericsson.com>
Cc: <netdev@vger.kernel.org>
Subject: Re: skb_try_coalesce bug?
Date: Tue, 22 Apr 2014 15:38:00 -0400	[thread overview]
Message-ID: <5356C518.7050602@ericsson.com> (raw)
In-Reply-To: <1398172293.29946.37.camel@edumazet-glaptop2.roam.corp.google.com>

On 04/22/2014 09:11 AM, Eric Dumazet wrote:
> On Tue, 2014-04-22 at 14:01 +0200, Erik Hugne wrote:
>> It seems that if the head skb of a reassembly chain have enough tailroom
>> to hold the data of a received fragment, skb_try_coalesce() will append this
>> directly to the head, even if preceding fragments have been put on a frag list.
>> This will cause a corrupted buffer to be passed to userland when 
>> skb_copy_datagram_iovec() later copies the contents of head, and then each frag
>> one by one to the target iovec.
>>  
>> Is skb_try_coalesce() broken, or are we using it wrongly in tipc?
> 
> I am not sure how it could happen with the current implementation ?
> 
> static inline bool skb_is_nonlinear(const struct sk_buff *skb)
> {
> 	return skb->data_len;
> }
> 
> static inline int skb_tailroom(const struct sk_buff *skb)
> {
> 	return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail;
> }
> 
> /**
>  * skb_try_coalesce - try to merge skb to prior one
>  * @to: prior buffer
>  * @from: buffer to add
>  * @fragstolen: pointer to boolean
>  * @delta_truesize: how much more was allocated than was requested
>  */
> bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
>                       bool *fragstolen, int *delta_truesize)
> {
>         int i, delta, len = from->len;
> 
>         *fragstolen = false;
> 
>         if (skb_cloned(to))
>                 return false;
> 
>         if (len <= skb_tailroom(to)) {
>                 BUG_ON(skb_copy_bits(from, 0, skb_put(to, len), len));

In the case I encountered, our head buffer is linear (skb->data_len == 0),
so it is the real tailroom value that is returned. An alas, that one is big
enough to contain the last (small) fragment of the message.

///jon


> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  reply	other threads:[~2014-04-22 19:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-22 12:01 skb_try_coalesce bug? Erik Hugne
2014-04-22 13:11 ` Eric Dumazet
2014-04-22 19:38   ` Jon Maloy [this message]
2014-04-22 20:05     ` Eric Dumazet
2014-04-22 20:35       ` Jon Maloy
2014-04-22 21:28         ` Jon Maloy
2014-04-22 21:29         ` Eric Dumazet
2014-04-22 21:31           ` Jon Maloy
2014-04-22 21:37           ` Eric Dumazet
2014-04-23 16:56             ` Jon Maloy
2014-04-23 17:33               ` David Miller
2014-04-23 17:54                 ` Jon Maloy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5356C518.7050602@ericsson.com \
    --to=jon.maloy@ericsson.com \
    --cc=eric.dumazet@gmail.com \
    --cc=erik.hugne@ericsson.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.