Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp814637rwb; Mon, 26 Sep 2022 06:16:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM63C8P/srRiDa6iz7plbDObxGfGLsGNGA9O4h/QFaqlVpxqzlKFAvT0/HWlDrxeVuFwOAd1 X-Received: by 2002:a17:906:4fce:b0:783:af0d:1ea2 with SMTP id i14-20020a1709064fce00b00783af0d1ea2mr2542679ejw.276.1664198163294; Mon, 26 Sep 2022 06:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198163; cv=none; d=google.com; s=arc-20160816; b=BvTOt9GxNxK+uUXancIPC18OwRaAb3Xb4Bs1dio/6bz3NiSpikM2Es24RUusiGmg7N B3sNj2fyYB+V5LepzzGzQqOGHt5czi/ZyqaDDvE0oEhKPlSoIbzyQkTkQQsjyT4Q35bB iJJ/QUtSDXPZzjYsCVMYxyWyaq7YfAlWgg8fefpGBawl2AVqHSSXRBynYG36mS0J21Sa +G7BPkV4YyICcat3uXJVqwVq8Id1sSFGqhG9Tbv6Tt/FDtFDNNXA57aqRW3r4C/AIJ64 40AApFIvjREPFJPOgewqEywLLztAvNXIPVm/geYXHXVLtqgDH6v989c5qstmdodge4iG oyKQ== 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=jkl5HwwW1ClrfRne3az/MEsL88D8CU7nwNMNcI4clF8=; b=iCT0D9lQItwvBi8HuxOiLKjM98HvnuSloe3fR41/eOUCK2zZC0Nluzn7auGaZ0tBFz swH2i+gLMKXFZG7TYVAt/ujlAYxKt9ygIqEPOB4tOeJDn2qN+xex/NAef5zjP9vaIL8+ TH2wrcCh2dNGlAuM5vB8DEGFLKitpuducPlyqxe4P6qw1useKEMMESszYUc3bRIerYG/ BBfl29rupmT5464cZxF973XJOBgeMjIjPSBKKCpgKhX0YUiuoRzSfnyaaX925qagRzDe aQmPN/dpI/cmkkPoZgdjT7JlqniLTZ8X3ENO9RQSpTo3RFIT4EEaXSGYiUxQrgngrW+H EllQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YzF2hSU5; 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 ji5-20020a170907980500b007708617c995si10078347ejc.339.2022.09.26.06.15.35; Mon, 26 Sep 2022 06:16:03 -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=YzF2hSU5; 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 S237885AbiIZLZd (ORCPT + 99 others); Mon, 26 Sep 2022 07:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238007AbiIZLXw (ORCPT ); Mon, 26 Sep 2022 07:23:52 -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 197A043E6D; Mon, 26 Sep 2022 03:40:08 -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 E202F60C0D; Mon, 26 Sep 2022 10:39:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02A43C433C1; Mon, 26 Sep 2022 10:39:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664188766; bh=JXZj6lNusKKzwTQlu5y1VwDInsIzQ4IgA76LmAqU26Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YzF2hSU5VAlSY/idUqbCZ+Ce6WZed11/w41o+EOz9O6+tTH2cNZ9QYzy+jcdaE5Km Pr6/37dP0pExQbQzmLZWV8/l7nEW+KxARpMJLowcyxrINt/3Nk9HftyjuiGTswHiqH BaCnWqleAXA3wFCDCftSQTFNQuiqsIpV13WBrB+A= 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 5.15 113/148] net: sunhme: Fix packet reception for len < RX_COPY_THRESHOLD Date: Mon, 26 Sep 2022 12:12:27 +0200 Message-Id: <20220926100800.367951360@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100756.074519146@linuxfoundation.org> References: <20220926100756.074519146@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 b05ee2e0e305..735f24a70626 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2039,9 +2039,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