Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp823256rwb; Mon, 26 Sep 2022 06:22:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4OEUTi3PTqZBhOyB9x2JlxFrsx8XI5j1XFBM3er1+lVY4mwPPA2lb/5BlrEvCJJm3VmK0P X-Received: by 2002:a17:907:3e28:b0:782:81d:a4f9 with SMTP id hp40-20020a1709073e2800b00782081da4f9mr18199629ejc.558.1664198520608; Mon, 26 Sep 2022 06:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198520; cv=none; d=google.com; s=arc-20160816; b=LWIxZb0sI/oGtUzeTFwTg4FwDZ4/y59EeR0nLopR2hkswltmjujb1QygvQEAIkFKqH kGpnvV7WEbTdYRbd+86h9XKkcpyLP7Oxt988R9IA6X691nSugL5isCjohtixf/5clXBS VSUzVkn0eYvLuEguHJwK0aNeIAp4H+kQQYiw2hXkR50ER7JQBm1Rl4vXJ86xiP7a+UJC IYvrBRuk873pYYb6voBxXl4AAMQtrIE3/rY8FKdWcNjGBZbhTTjfV9bos+SWb1Y4bWI+ HmjqABJujBb90kTzbvf8SrSDLljPmqEHEXmQVB+W/Fvei56Sn3D+Gf+1XFjv+OCelopN yCrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U2HuJmmBakIyYglPhdNqjiJSh7B/0KNOaahGoijaPbk=; b=Ap3OlhinNQMIX9/s4uo6x2ZSw6/bZ1P0MaPkuRwRD0S3R6HRTzYrAtdduiwQn9KN8C yRA7T3Lf1nMjelA4M2fYWogSy5qIVTcO6cT0byv3SveE9cGBYpm2kWLC65vUh5nX5eRP eImArn0xc9v4Estb32LFA9C/nLMTcJ0PeZNFAIfVIx1oG27BgwPYj2CaqW7ztXxN0QLc d3R5dXnfcVVN+jWD8+PWuwP1lQuAAQ+tx5wvpefSrE6l3DRTnT4kJ6MPfEoyp9wJqiJ7 OfHU+V4T9xxemanGNueKjMYFpRFU/aBld2UABU+0TpkZXrLIoxrBywdrqEBGv0R77VZM 9stg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gOrCPghy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa34-20020a17090786a200b007417e9a2c71si16071126ejc.352.2022.09.26.06.21.34; Mon, 26 Sep 2022 06:22:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gOrCPghy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235666AbiIZKcU (ORCPT + 99 others); Mon, 26 Sep 2022 06:32:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235632AbiIZKaJ (ORCPT ); Mon, 26 Sep 2022 06:30:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5FBF1AD99; Mon, 26 Sep 2022 03:19:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 023D660B5E; Mon, 26 Sep 2022 10:19:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4CA6C433D6; Mon, 26 Sep 2022 10:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187590; bh=xpf3VBCUV+vbajoUKGEU25izfAZdtkyl5dtrqwY9HQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gOrCPghycjvRnRiePZWm3q0arGCj6pHAOmKwVKyGoECvReubu0uLqXH0wLLJW/O8Y 4XIYxmPZw9gAlQOUEGy9mRKvtTnVaKI7PYYbkeUUTqx2VYf+gY0p7Wr4Ee1zW2yvSm q2dUcMUB9En8L/5aeuIOlbdL+KUbwMasdliMPDLY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Anderson , Andrew Lunn , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 49/58] net: sunhme: Fix packet reception for len < RX_COPY_THRESHOLD Date: Mon, 26 Sep 2022 12:12:08 +0200 Message-Id: <20220926100743.247701751@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100741.430882406@linuxfoundation.org> References: <20220926100741.430882406@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Anderson [ Upstream commit 878e2405710aacfeeb19364c300f38b7a9abfe8f ] There is a separate receive path for small packets (under 256 bytes). Instead of allocating a new dma-capable skb to be used for the next packet, this path allocates a skb and copies the data into it (reusing the existing sbk for the next packet). There are two bytes of junk data at the beginning of every packet. I believe these are inserted in order to allow aligned DMA and IP headers. We skip over them using skb_reserve. Before copying over the data, we must use a barrier to ensure we see the whole packet. The current code only synchronizes len bytes, starting from the beginning of the packet, including the junk bytes. However, this leaves off the final two bytes in the packet. Synchronize the whole packet. To reproduce this problem, ping a HME with a payload size between 17 and 214 $ ping -s 17 which will complain rather loudly about the data mismatch. Small packets (below 60 bytes on the wire) do not have this issue. I suspect this is related to the padding added to increase the minimum packet size. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Sean Anderson Reviewed-by: Andrew Lunn Link: https://lore.kernel.org/r/20220920235018.1675956-1-seanga2@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/sun/sunhme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index 882908e74cc9..a4090163d870 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2064,9 +2064,9 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev) skb_reserve(copy_skb, 2); skb_put(copy_skb, len); - dma_sync_single_for_cpu(hp->dma_dev, dma_addr, len, DMA_FROM_DEVICE); + dma_sync_single_for_cpu(hp->dma_dev, dma_addr, len + 2, DMA_FROM_DEVICE); skb_copy_from_linear_data(skb, copy_skb->data, len); - dma_sync_single_for_device(hp->dma_dev, dma_addr, len, DMA_FROM_DEVICE); + dma_sync_single_for_device(hp->dma_dev, dma_addr, len + 2, DMA_FROM_DEVICE); /* Reuse original ring buffer. */ hme_write_rxd(hp, this, (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), -- 2.35.1