From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jon Maloy Subject: Re: skb_try_coalesce bug? Date: Tue, 22 Apr 2014 15:38:00 -0400 Message-ID: <5356C518.7050602@ericsson.com> References: <20140422120125.GC7019@eerihug-hybrid.rnd.ki.sw.ericsson.se> <1398172293.29946.37.camel@edumazet-glaptop2.roam.corp.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: To: Eric Dumazet , Erik Hugne Return-path: Received: from usevmg20.ericsson.net ([198.24.6.45]:42501 "EHLO usevmg20.ericsson.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750888AbaDVTid (ORCPT ); Tue, 22 Apr 2014 15:38:33 -0400 In-Reply-To: <1398172293.29946.37.camel@edumazet-glaptop2.roam.corp.google.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 >