Message ID | 20180702203203.21316-1-aring@mojatatu.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Hello. [CC David Palma and Rabi Narayan Sahoo] On 02.07.2018 22:32, Alexander Aring wrote: > This patch fixes patch add handling to take care tail and headroom for > single 6lowpan frames. We need to be sure we have a skb with the right > head and tailroom for single frames. This patch do it by using > skb_copy_expand() if head and tailroom is not enough allocated by upper > layer. > > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195059 > Reported-by: David Palma <david.palma@ntnu.no> > Reported-by: Rabi Narayan Sahoo <rabinarayans0828@gmail.com> > Signed-off-by: Alexander Aring <aring@mojatatu.com> David, Rabi and you please test these two patches and verify that it fixes the problems you have? regards Stefan Schmidt > --- > net/ieee802154/6lowpan/tx.c | 21 ++++++++++++++++++--- > 1 file changed, 18 insertions(+), 3 deletions(-) > > diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c > index e6ff5128e61a..d0c4d220de08 100644 > --- a/net/ieee802154/6lowpan/tx.c > +++ b/net/ieee802154/6lowpan/tx.c > @@ -265,9 +265,24 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev) > /* We must take a copy of the skb before we modify/replace the ipv6 > * header as the header could be used elsewhere > */ > - skb = skb_unshare(skb, GFP_ATOMIC); > - if (!skb) > - return NET_XMIT_DROP; > + if (unlikely(skb_headroom(skb) < ldev->needed_headroom || > + skb_tailroom(skb) < ldev->needed_tailroom)) { > + struct sk_buff *nskb; > + > + nskb = skb_copy_expand(skb, ldev->needed_headroom, > + ldev->needed_tailroom, GFP_ATOMIC); > + if (likely(skb)) { > + consume_skb(skb); > + skb = nskb; > + } else { > + kfree_skb(skb); > + return NET_XMIT_DROP; > + } > + } else { > + skb = skb_unshare(skb, GFP_ATOMIC); > + if (!skb) > + return NET_XMIT_DROP; > + } > > ret = lowpan_header(skb, ldev, &dgram_size, &dgram_offset); > if (ret < 0) { > -- To unsubscribe from this list: send the line "unsubscribe linux-wpan" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Stefan, On 05/07/18 13:16, Stefan Schmidt wrote: > Hello. > > [CC David Palma and Rabi Narayan Sahoo] > > On 02.07.2018 22:32, Alexander Aring wrote: >> This patch fixes patch add handling to take care tail and headroom for >> single 6lowpan frames. We need to be sure we have a skb with the right >> head and tailroom for single frames. This patch do it by using >> skb_copy_expand() if head and tailroom is not enough allocated by upper >> layer. >> >> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195059 >> Reported-by: David Palma <david.palma@ntnu.no> >> Reported-by: Rabi Narayan Sahoo <rabinarayans0828@gmail.com> >> Signed-off-by: Alexander Aring <aring@mojatatu.com> > > David, Rabi and you please test these two patches and verify that it > fixes the problems you have? > > regards > Stefan Schmidt > The patches fix the problems! I've tested them against different packet sizes and no kernel panic. The patches were applied in Debian's 4.9.88-1+deb9u1 x86_64 kernel, which before the patches showed the reported issue. Thanks again to Alex for looking into it. Cheers,
Hello David. On 06.07.2018 09:54, David Palma wrote: > Hi Stefan, > > On 05/07/18 13:16, Stefan Schmidt wrote: >> Hello. >> >> [CC David Palma and Rabi Narayan Sahoo] >> >> On 02.07.2018 22:32, Alexander Aring wrote: >>> This patch fixes patch add handling to take care tail and headroom for >>> single 6lowpan frames. We need to be sure we have a skb with the right >>> head and tailroom for single frames. This patch do it by using >>> skb_copy_expand() if head and tailroom is not enough allocated by upper >>> layer. >>> >>> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195059 >>> Reported-by: David Palma <david.palma@ntnu.no> >>> Reported-by: Rabi Narayan Sahoo <rabinarayans0828@gmail.com> >>> Signed-off-by: Alexander Aring <aring@mojatatu.com> >> >> David, Rabi and you please test these two patches and verify that it >> fixes the problems you have? >> >> regards >> Stefan Schmidt >> > > The patches fix the problems! > > I've tested them against different packet sizes and no kernel panic. Thanks for confirming. > The patches were applied in Debian's 4.9.88-1+deb9u1 x86_64 kernel, > which before the patches showed the reported issue. I will see that I get them into the stable kernel as well. For LTS or Debian kernels you might want to poke the maintainers of them directly once this patch had hit Linux mainline. regards Stefan Schmidt -- To unsubscribe from this list: send the line "unsubscribe linux-wpan" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello. On 02.07.2018 22:32, Alexander Aring wrote: > This patch fixes patch add handling to take care tail and headroom for The "patch add" text here is form some patch managing? Please fix this when doing the re-spin for the problem below. > single 6lowpan frames. We need to be sure we have a skb with the right > head and tailroom for single frames. This patch do it by using > skb_copy_expand() if head and tailroom is not enough allocated by upper > layer. > > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195059 > Reported-by: David Palma <david.palma@ntnu.no> > Reported-by: Rabi Narayan Sahoo <rabinarayans0828@gmail.com> > Signed-off-by: Alexander Aring <aring@mojatatu.com> > --- > net/ieee802154/6lowpan/tx.c | 21 ++++++++++++++++++--- > 1 file changed, 18 insertions(+), 3 deletions(-) > > diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c > index e6ff5128e61a..d0c4d220de08 100644 > --- a/net/ieee802154/6lowpan/tx.c > +++ b/net/ieee802154/6lowpan/tx.c > @@ -265,9 +265,24 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev) > /* We must take a copy of the skb before we modify/replace the ipv6 > * header as the header could be used elsewhere > */ > - skb = skb_unshare(skb, GFP_ATOMIC); > - if (!skb) > - return NET_XMIT_DROP; > + if (unlikely(skb_headroom(skb) < ldev->needed_headroom || > + skb_tailroom(skb) < ldev->needed_tailroom)) { > + struct sk_buff *nskb; > + > + nskb = skb_copy_expand(skb, ldev->needed_headroom, > + ldev->needed_tailroom, GFP_ATOMIC); > + if (likely(skb)) { I think you wanted to check for nskb here. > + consume_skb(skb); > + skb = nskb; > + } else { > + kfree_skb(skb); > + return NET_XMIT_DROP; > + } > + } else { > + skb = skb_unshare(skb, GFP_ATOMIC); > + if (!skb) > + return NET_XMIT_DROP; > + } > > ret = lowpan_header(skb, ldev, &dgram_size, &dgram_offset); > if (ret < 0) { > The rest looks fine to me. regards Stefan Schmidt -- To unsubscribe from this list: send the line "unsubscribe linux-wpan" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c index e6ff5128e61a..d0c4d220de08 100644 --- a/net/ieee802154/6lowpan/tx.c +++ b/net/ieee802154/6lowpan/tx.c @@ -265,9 +265,24 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev) /* We must take a copy of the skb before we modify/replace the ipv6 * header as the header could be used elsewhere */ - skb = skb_unshare(skb, GFP_ATOMIC); - if (!skb) - return NET_XMIT_DROP; + if (unlikely(skb_headroom(skb) < ldev->needed_headroom || + skb_tailroom(skb) < ldev->needed_tailroom)) { + struct sk_buff *nskb; + + nskb = skb_copy_expand(skb, ldev->needed_headroom, + ldev->needed_tailroom, GFP_ATOMIC); + if (likely(skb)) { + consume_skb(skb); + skb = nskb; + } else { + kfree_skb(skb); + return NET_XMIT_DROP; + } + } else { + skb = skb_unshare(skb, GFP_ATOMIC); + if (!skb) + return NET_XMIT_DROP; + } ret = lowpan_header(skb, ldev, &dgram_size, &dgram_offset); if (ret < 0) {
This patch fixes patch add handling to take care tail and headroom for single 6lowpan frames. We need to be sure we have a skb with the right head and tailroom for single frames. This patch do it by using skb_copy_expand() if head and tailroom is not enough allocated by upper layer. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195059 Reported-by: David Palma <david.palma@ntnu.no> Reported-by: Rabi Narayan Sahoo <rabinarayans0828@gmail.com> Signed-off-by: Alexander Aring <aring@mojatatu.com> --- net/ieee802154/6lowpan/tx.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)