From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81798C43381 for ; Mon, 18 Feb 2019 14:07:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4367D21901 for ; Mon, 18 Feb 2019 14:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498859; bh=xqhDh9aoPUsKfy0Dhk2sYeKq17olYfKLyh9ObawwcFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=a308CnRxOuncopflkb3UBpe7V+YZo3ELN7uPh789uYyMf7Se6BlcN8J2MKlTjyTEk FKrGQzUvoQGTdxxfwztMv5x4mIgQ862d0zKsw36M1T8Ob+DN1Y75OEKTJK/HF02P/A Wpos7Ue5e+jhScxReptZIVzPeUCsA5rq5p6DCNEE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390737AbfBROHi (ORCPT ); Mon, 18 Feb 2019 09:07:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:50638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390623AbfBROH3 (ORCPT ); Mon, 18 Feb 2019 09:07:29 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A35021901; Mon, 18 Feb 2019 14:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498848; bh=xqhDh9aoPUsKfy0Dhk2sYeKq17olYfKLyh9ObawwcFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aV6ZyLcCg06RKxmcrXdo3i8ECVk55wObO77x+2FInNk8E5qfd5atxAJutIMjs27VF 30tGx9PNaCdFs3RRjqWJRNc/iuHfW4PdBGPUjoIgE/cpXMrvDfcaAtolD3fumT/WNK wSONAcdljSwTaXpvsdMNGPzIo91iQsr/JqSRl7IM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , James Hughes , "David S. Miller" , Linus Walleij Subject: [PATCH 4.4 141/143] kaweth: use skb_cow_head() to deal with cloned skbs Date: Mon, 18 Feb 2019 14:44:29 +0100 Message-Id: <20190218133534.122964458@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133529.099444112@linuxfoundation.org> References: <20190218133529.099444112@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/kaweth.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -812,18 +812,12 @@ static netdev_tx_t kaweth_start_xmit(str } /* 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);