Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2979014imu; Sun, 9 Dec 2018 14:10:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/WSKkGqRvzumEUZ+DcbxUoJIxd6pTYZ8DXvJ7lq42IPAwuURAoiGwa/FuOdfZky1RF4gKc7 X-Received: by 2002:a17:902:ac1:: with SMTP id 59mr9718269plp.36.1544393403434; Sun, 09 Dec 2018 14:10:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544393403; cv=none; d=google.com; s=arc-20160816; b=ol+aXJvngQr5y7VaaY7K5CGsxOtnowpbUbKRvr6agPDe4yNYT/WetDp9yQL8JWrxmz mUwj7dkMAaIA3O4kabEfwlXjXc1/+YqDQlMmN7puHuBB50P1DAjgqpsLtHg7OouSfGXX JWlI2Sx/Rg9c+HJkgVIBGs7agl/VftcpA7TNFo3yAUZ6U9HtbVtZhs9OwKRzu1KajBv0 /8UH5gc2PuEhfcDA/9pOoz9iyi8UjQ95Yw61S3p9rb3iu3B+Fbf75LSBPRZKnxBve0dS Y9avxe3J9KIR1F5C7FebsQmKnTHrzJVP33LhTy2GDZtJJxULH0tnYrvavAHLqvaIY3zA 2PAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=+zb34kEI02CVNk+QSmM18Vgl7Z21ECXD1pLsYMIGYYc=; b=JbPSuxcOg5qNiGOLVDBcZi4RoukgP5wpLDsr8lnvOaaV0H1zBrd2iGx4VEK1vrethi 6tsFJczdkXJe7P56dmYnV2yXuNdB4wtKnB8gPhpDSrQhV4FtqtuYux5TvIlcci7A73Bc HcDzcPm/V1/xj/f1F5lL78bxPU/G8yNYrG+cJdBBk3ZF9QiQCXF643h90DhbMmbBE6Uj QfJsLSrYtXGlXtJBKGljWxhg9MEnMTFLIy+5cO7uPfd99KVbFVyT5dmHveJZQl70RpZb 8r2yhh68tgYB7jaMEBRox1jjJerYNxbDhgQvA7SJGTwlPHTuiqusF1YtODeL9AGfx3Bo 82JQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si8170783plk.199.2018.12.09.14.09.48; Sun, 09 Dec 2018 14:10:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726832AbeLIWHJ (ORCPT + 99 others); Sun, 9 Dec 2018 17:07:09 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:37164 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727274AbeLIWHB (ORCPT ); Sun, 9 Dec 2018 17:07:01 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW73I-0002if-Jh; Sun, 09 Dec 2018 21:55:52 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72c-0003LS-1O; Sun, 09 Dec 2018 21:55:10 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Alexander Aring" , "Rabi Narayan Sahoo" , "Stefan Schmidt" , "David Palma" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 103/328] net: 6lowpan: fix reserved space for single frames In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Aring commit ac74f87c789af40936a80131c4759f3e72579c3a upstream. 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 Reported-by: Rabi Narayan Sahoo Signed-off-by: Alexander Aring Signed-off-by: Stefan Schmidt [bwh: Backported to 3.16: - s/ldev/dev/ - Adjust filename] Signed-off-by: Ben Hutchings --- net/ieee802154/6lowpan_rtnl.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) --- a/net/ieee802154/6lowpan_rtnl.c +++ b/net/ieee802154/6lowpan_rtnl.c @@ -388,9 +388,24 @@ static netdev_tx_t lowpan_xmit(struct sk /* 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) < dev->needed_headroom || + skb_tailroom(skb) < dev->needed_tailroom)) { + struct sk_buff *nskb; + + nskb = skb_copy_expand(skb, dev->needed_headroom, + dev->needed_tailroom, GFP_ATOMIC); + if (likely(nskb)) { + 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, dev); if (ret < 0) {