From patchwork Thu Feb 14 12:49:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 158360 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1324308jaa; Thu, 14 Feb 2019 04:49:46 -0800 (PST) X-Google-Smtp-Source: AHgI3IbMQBmy6N4k9vd/QzVksw2z2uUh21fOKZPwPrHIAYrx7W+DkBzgQMV1Y878xsThOT3pylJr X-Received: by 2002:a62:1382:: with SMTP id 2mr138396pft.157.1550148586493; Thu, 14 Feb 2019 04:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550148586; cv=none; d=google.com; s=arc-20160816; b=nRdYAURy91AcJN2RrCB6eBSUXC0xAnsYpBZfk6iGI04WkrOA8HhfppcbQM3sL6PIkP OUv7qhc4nqoKXHPMgqP1SODuPqPNWdn2CrNI4WxQM1rD4ue0CLEHe8sIhzC5zTpTUAZF NVaieoGQpWWC7ZwnMSucFB1+Y5BhRZB5rI3Iq+xyx5xxlLHau3T7wMvfFO0T+pQfptZ6 0xaOrA1mNj/beVXJ8vInE4xv33DTsEhGrVV0D3lewBeIVS3phmNnZfEEb+McYwX0bX8x 8L/dDLptbUnzTwNeIEoKBXf22oWrqIJGPiSTpyu+BZ3KymYkcUaeaQCy5u1EF7AziY78 1A9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MEBfcUpvsFkrcgNCjUmPh/+T0vkp1uHt8yb01MqBA7U=; b=paaUdnokXtuSReh1sinOWYWFZSAL3+jtBg6FubziMk3TLomf4aaajF1ulEdv/B3Dhp 97Xb+3ypbkYVXbM9TXD3Zi6XGhoG1uPLAG0KL+k5+qUEGyimGGfsYCKW9W8C2j1DEHJP J+fDJtR+dbQvHvz9q2fOvYhYF/S51tYIYi+tHc0Uzh21bMZ9MtVSyylY5OOYaRkaoa1W aBo9EljqNd9wlUbA6jA4S0OcCazPuBKnUvNe0Qa60++VOYOUhOJRL+HlaEl1hR0gPl+v Wv63PEAiA/Ybm3y5wDzjLFmEwWlcUOgUvBG2uZfbLkCB1a6ZT7rikWnjs8TYonVK4ztB 5gsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pm/Ugvk1"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g26si2310745pfi.184.2019.02.14.04.49.46; Thu, 14 Feb 2019 04:49:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pm/Ugvk1"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438533AbfBNMtp (ORCPT + 15 others); Thu, 14 Feb 2019 07:49:45 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:42050 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438103AbfBNMtp (ORCPT ); Thu, 14 Feb 2019 07:49:45 -0500 Received: by mail-lj1-f193.google.com with SMTP id l7-v6so5108036ljg.9 for ; Thu, 14 Feb 2019 04:49:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MEBfcUpvsFkrcgNCjUmPh/+T0vkp1uHt8yb01MqBA7U=; b=pm/Ugvk1Pg901IdT39EYeMJl7a1QQQNalwBjTCHchQT7+7uM4nWGhrlhzxeuwSy4hZ 8q5jpGPkFUdLQ8rla13Z2Asd9bLz6GdlNt2PG5cWiKIubB8S1rs18s1M3Cq7G+SCGiry 4WcvZOhm0/IbFHGh6pOBPgMXX6XG2BB/5Q1AS7cTcvVKhRpW963rCjZNbIPZPUeCQybF Q3KJ7rmFqNuTgUB/LQWELxVjZZHiviJXCqs88jh8fhrjMn5jHjvEHAEyB07+2L2fpyGd uQl+9EjYlGnb6eyne0yCLrwZS5RfMFlsFjowqDjctkF7nWiBd4/8Zgov9tQuCONGZMw/ ZHBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MEBfcUpvsFkrcgNCjUmPh/+T0vkp1uHt8yb01MqBA7U=; b=mA+WWKIYyBw0PkeYSM+aDzl0z1UT/WfULWMKyBypnsL4rcfoRX5aX26H657kbcEJGZ IWCqf+ETeWBZjgqCML5C6etYrD5Rh6V4Y9c17f+ieUUqtwx9RL6kbD6wKFmJvxt8/FKr gKUefaD1D5/lLiUtDmTNvHi0NoMWRtIOPy8SL93g2FclFMn+1K5LL/Ksu00ulHewFaFF Hv8qPNGKLOzp+efMQH0B2fHxTnP/L4te+y7Ix4KCisnRQRWNeMUSU/D6uyAbj8ybxxLf 9tObA8koBzOvrY13CBuBIH/w3drCg9yWtevjzGqZvC4tsgcK5A5zXdDnVo4HvHN2y4ll kLvg== X-Gm-Message-State: AHQUAuZcVJo0sLs4uXYSzN1qIRfb4pHTb839o7QlMJ/hES3TPfWTxb5S o3a7G1l3EfYjrJCN3scaWq7J8A== X-Received: by 2002:a05:651c:112:: with SMTP id a18mr2312428ljb.45.1550148583493; Thu, 14 Feb 2019 04:49:43 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r7-v6sm410853ljg.85.2019.02.14.04.49.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 04:49:42 -0800 (PST) From: Linus Walleij To: Greg Kroah-Hartman , stable@vger.kernel.org, openwrt-devel@lists.openwrt.org Cc: "David S . Miller" , Eric Dumazet , Liping Zhang , John Youn , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , James Hughes , Felix Fietkau Subject: [PATCH 4/8 v2] kaweth: use skb_cow_head() to deal with cloned skbs Date: Thu, 14 Feb 2019 13:49:06 +0100 Message-Id: <20190214124910.1753-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190214124910.1753-1-linus.walleij@linaro.org> References: <20190214124910.1753-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Eric Dumazet commit 39fba7835aacda65284a86e611774cbba71dac20 upstream. We can use skb_cow_head() to properly deal with clones, especially the ones coming from TCP stack that allow their head being modified. This avoids a copy. Signed-off-by: Eric Dumazet Cc: James Hughes Signed-off-by: David S. Miller --- - This was applied upstream in v4.11 - Should be applied to stable v4.9.y --- drivers/net/usb/kaweth.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) -- 2.20.1 diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 66b34ddbe216..72d9e7954b0a 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -803,18 +803,12 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb, } /* We now decide whether we can put our special header into the sk_buff */ - if (skb_cloned(skb) || skb_headroom(skb) < 2) { - /* no such luck - we make our own */ - struct sk_buff *copied_skb; - copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC); - dev_kfree_skb_irq(skb); - skb = copied_skb; - if (!copied_skb) { - kaweth->stats.tx_errors++; - netif_start_queue(net); - spin_unlock_irq(&kaweth->device_lock); - return NETDEV_TX_OK; - } + if (skb_cow_head(skb, 2)) { + kaweth->stats.tx_errors++; + netif_start_queue(net); + spin_unlock_irq(&kaweth->device_lock); + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; } private_header = (__le16 *)__skb_push(skb, 2);