From patchwork Thu Feb 14 13:23:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 158387 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1366832jaa; Thu, 14 Feb 2019 05:24:39 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib/ceFi3QosYgyOiUo0Jsb4LhwkUdmw0SmIWM7vm0kVeIOAnsbv+L51Uho2YJTCe0F3VeT6 X-Received: by 2002:a17:902:6949:: with SMTP id k9mr4224771plt.188.1550150679292; Thu, 14 Feb 2019 05:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550150679; cv=none; d=google.com; s=arc-20160816; b=IyWyFlIeb3p9J7AUQdS6VsWJI+MzSSJsN2oF3UkPCQnOR4gGHUzB1rT71vm/5LkN0v 6APnOP3U1vRKrPo1ZBizGIwI81tOzJR5U+P+G07RnpMtNehw6e601QZZ2xo0cmEwZRSc pMmSshjYrfpDE7dJQdFM51js9X4x8AHXoBXQOiSk+L/3MN+yu9kKIpR1AZ7k3GnooRc+ qWuZVtutZRVyF0JI/bOPR167Q/kHtd0oJj3nTpN+Km56vvXDj7+hXRIyKTZ2+mNfgMcY mutpZS/pEHTq7PgOUtZ4IweELhAY3ON+co+pk6iB9WJW5O+v5svXUGa5Xtxqb98yvpFJ IRaw== 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=/DA8zQ7zVMwl0qY6dEhmaf4DYZzRwvi7D9GLz7eYfy8=; b=N8hZ7gVnY+F+Nz2k0w3bBpFHRYCfTLDCGagc3yrJfUwID7CwJFhwFcZteNd8GQqNay uWVGW+N4+SEA4gslyWJSE+bRf1ZEpnW/pjPb7jMoiOWL+TkYejHJeWNArIz24fQv0PYO 5/wbXExHJblQoVvkIMsrTihKYuPL4pVrcjNEfGO6XRyK7rAjMHb6Up7OeD1HID73DDxw Terb4jZ6MPWt86aecXYrPls99Hn2GQAZbTh8fRBnAo7HWpsCFELKJXlGmT9LuxvAL0vx kHGlZsRs+7HHfwyU1/5yiT7m0se7uZsRvFINdeCmhsrsNJiXBjrQCoHT2ATbXh8Yl2py lRJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z7U5EqXA; 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 36si2748782plc.250.2019.02.14.05.24.39; Thu, 14 Feb 2019 05:24:39 -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=z7U5EqXA; 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 S2436688AbfBNNYi (ORCPT + 15 others); Thu, 14 Feb 2019 08:24:38 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:39729 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436698AbfBNNYi (ORCPT ); Thu, 14 Feb 2019 08:24:38 -0500 Received: by mail-lj1-f194.google.com with SMTP id g80so5210986ljg.6 for ; Thu, 14 Feb 2019 05:24:37 -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=/DA8zQ7zVMwl0qY6dEhmaf4DYZzRwvi7D9GLz7eYfy8=; b=z7U5EqXAMeJMymQ8bW3Kc2P4drBGsYAoS/q0fMjxz3rrT0CkB/VBVypLZ6d4bNnTdI 5RqqYnoCLI0YaSk0T+CHhNw+zKp4yU2+76lk+7x/ikpjzkxH7wjFeLJrxXriPzQsuBVA 4M4gZEFiseFptpQtqXgXXLxy4kqnEvb6ZXoTpmFkwRFDw+Wle4ugCW3aoMASL2eWG+W3 e8fBB6akosFckeSlEBVYgdZ2dAu/cCoA/liPVrPZY0t2huuQKQnXmGmwBkRKKyYQSwwl BJTsa+3ml6RpRcYvZ6fuTHDRe69WXvi+eN4twQcWNAr/Ah7pc+OGHCB6WxgLg9cWFr7s 5IuQ== 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=/DA8zQ7zVMwl0qY6dEhmaf4DYZzRwvi7D9GLz7eYfy8=; b=g2H2aun4y+6M6bIKo0svlK3T2qiVTvJuxmghNb1HLfTpsrnzAe4NdHEeaq7WQxglFP lbus6rqaMN+0jJWbqvdcM3392ePpu2vFtO79GpDDU6QWayEyJkAVnAsVJvlz4Ad4JDMq IeIKEJLpJh9WcKe9Jmzo0os02uvd42GkQP85ebgj8KmAGyniSYrG4QyP/Fr8LGeX7XMH rGxA1pwbWp21b+n3gQin+R6pLSQzqUVsRIa3xpJMHbDPsizLRdG8js9IAi6vD956CgeP ygVHUL725XH/RI/FeyhGkx9eIAcYSfRBZxCzL7qU86RO6Xpwpq5vU9TBHbI+RVFmb9sx t1FA== X-Gm-Message-State: AHQUAuYpUOcZxlPspwLeSiT7EVTlu//uqz+KQmFmui+mIKr4R4TjM8HU bNZDU6Qh1f9F16xRJY8owMEQQQ== X-Received: by 2002:a2e:9a16:: with SMTP id o22-v6mr2453850lji.112.1550150676784; Thu, 14 Feb 2019 05:24:36 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id k13-v6sm427752ljg.84.2019.02.14.05.24.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 05:24:35 -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 , Linus Walleij Subject: [PATCH 4/8 v3] kaweth: use skb_cow_head() to deal with cloned skbs Date: Thu, 14 Feb 2019 14:23:59 +0100 Message-Id: <20190214132403.10687-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190214132403.10687-1-linus.walleij@linaro.org> References: <20190214132403.10687-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 Signed-off-by: Linus Walleij --- - 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);