From patchwork Fri May 8 12:34:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 226133 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.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,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 438B1C38A2A for ; Fri, 8 May 2020 13:14:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BA7C2496A for ; Fri, 8 May 2020 13:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588943696; bh=XW0RkQR6yn1N3zX53QBJtLJWccqmnQoeGLO076VMjwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nlhMVt+gZr6OUE+4f5QU5zBsL7rb8VOZ8tpmgOp8c2FojhkQS6tfCHoZk9zX7WPHk agDWZ+AJK9rGHbUrsw9ysIgshz3GMmGKEJsJrxSb6FFAeDQYKYlsY+5NWdAuQzM+uY 6CRencK0TUscwnP4YOM8OzohG8EaBR3fBd0AcPlY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729429AbgEHMq2 (ORCPT ); Fri, 8 May 2020 08:46:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:47718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728800AbgEHMq0 (ORCPT ); Fri, 8 May 2020 08:46:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 C99F4208D6; Fri, 8 May 2020 12:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588941986; bh=XW0RkQR6yn1N3zX53QBJtLJWccqmnQoeGLO076VMjwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZ9qyT/oEEKKcOZRqjrDwpNLvOKHIJw8RSEbBlaWy6cK1GgURnCadL4o4TbT0ZYKG lwXgyfNKlx/PhCuCtnRj14dHI1mQjz3+py0OVEy5K1C5z4Swjo3HNW70MeoeGWSfIR 75NP7inzSLTDY5LtMuDNQcbCNnQaFRZc31qsHZpw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Petri Gynther , Eric Dumazet , "David S. Miller" Subject: [PATCH 4.4 251/312] net: bcmgenet: fix skb_len in bcmgenet_xmit_single() Date: Fri, 8 May 2020 14:34:02 +0200 Message-Id: <20200508123142.066988233@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200508123124.574959822@linuxfoundation.org> References: <20200508123124.574959822@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Petri Gynther commit 7dd399130efb5a454daf24075b7563d197114e39 upstream. skb_len needs to be skb_headlen(skb) in bcmgenet_xmit_single(). Fragmented skbs can have only Ethernet + IP + TCP headers (14+20+20=54 bytes) in the linear buffer, followed by the rest in fragments. Bumping skb_len to ETH_ZLEN would be incorrect for this case, as it would introduce garbage between TCP header and the fragment data. This also works with regular/non-fragmented small packets < ETH_ZLEN bytes. Successfully tested this on GENETv3 with 42-byte ARP frames. For testing, I used: ethtool -K eth0 tx-checksum-ipv4 off ethtool -K eth0 tx-checksum-ipv6 off echo 0 > /proc/sys/net/ipv4/tcp_timestamps Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file") Signed-off-by: Petri Gynther Acked-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -1346,7 +1346,7 @@ static int bcmgenet_xmit_single(struct n tx_cb_ptr->skb = skb; - skb_len = skb_headlen(skb) < ETH_ZLEN ? ETH_ZLEN : skb_headlen(skb); + skb_len = skb_headlen(skb); mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE); ret = dma_mapping_error(kdev, mapping);