Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp810649rwb; Mon, 26 Sep 2022 06:13:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Okl/90cJnDucvA4ScuF4mCXiRXvxaI0bJ+SHJa49NHomD9ILZ71N7lunoImXrbj8Ii9/p X-Received: by 2002:a17:907:75e4:b0:783:8026:3e54 with SMTP id jz4-20020a17090775e400b0078380263e54mr4254895ejc.495.1664198016729; Mon, 26 Sep 2022 06:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198016; cv=none; d=google.com; s=arc-20160816; b=jwwrHEQTjI+u8jf6hPniAJEsc+Sijy/HVC5+vpjSbg9XlrEyL64vZ6haOVa511nkKa +qzWBdIH0IzsrsO0z14tD5i7rKQjfqklpetbQrE3NmSKn8I6Pzk2CENFMx1PVXRlkRcW WlQDpCP2PrnuXd5db+iYlMv3oNzwxl6FjdptLHQbqf1BWkismfyUWyzYpTCZDjVwZr2/ AxdywMeW7J6YtGgfoVuHkjujaSJD9WAvk8OjA4XO5nSD5+VwA2z/7HzJviwbqFNqFYuF JYrLWDtXSRA9kPz44q3W4WUHkP6CRLI6BBkOXc6KblsAhbcGmS3uDJwS1mywPPEjWZkv PuHg== 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=30F9IQQATWKbcWOWR7JJas16MA4aQ0GFoGkJYUA2k68=; b=n1Fnu+vJHTrQF9wJDs7Q+GSCvNN8oUiLXRmCNQyg6hNq5SR6vaWWFQpQ71dZ/8APlb aDUuR61vVWYGOZAd9+veLUd3HXYfN4gat6mOfDaKrjMNAUYkb72Qyf4EeExANHyHwEXh jvJOt8ykgsF8b44U0jvTa33NS4XmdbS0NxZpvkEseQBPvwgqePDrl8mwQcn974zT2Zta ogvAIvxLTwg9ejrbQn7K3EaSx9rC2I9XcqfgSu27RFqMvCosrqKWD2ZxZiq9b4tQqvr9 41qj6onme6POAtpfrs3VnincfVU8ZYQYqWsAZ5bDWzYu5Bn3togBz9enAzI9fzOXE/pF Q/Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="H/u1gsBJ"; 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 bf18-20020a0564021a5200b004575a5c88cbsi1477095edb.32.2022.09.26.06.13.04; Mon, 26 Sep 2022 06:13:36 -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="H/u1gsBJ"; 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 S236261AbiIZL4A (ORCPT + 99 others); Mon, 26 Sep 2022 07:56:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238586AbiIZLxC (ORCPT ); Mon, 26 Sep 2022 07:53:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D812DD4; Mon, 26 Sep 2022 03:49:31 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3AD86B80925; Mon, 26 Sep 2022 10:49:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7230DC433C1; Mon, 26 Sep 2022 10:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664189343; bh=84ue8kk8ImhjCX9CoLwQR/AtWolF4BJFbvIPQ/+t29o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H/u1gsBJu4Mp6Qq0usVSCs58LTZruAtgZVBpLZs0moHJ68pEeO7xXpX/DHJrirBCs AN22slJA5JkTGuhsUXerO/G9ghMYgj9ZNP7ALxH2o0qH8gTpp761y47i4HEpZXqgxX Mp+yyPFZd5i6G7/X54cDBhT+1S8+XipvzQmagQ5Y= 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.19 155/207] net: sunhme: Fix packet reception for len < RX_COPY_THRESHOLD Date: Mon, 26 Sep 2022 12:12:24 +0200 Message-Id: <20220926100813.589625899@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100806.522017616@linuxfoundation.org> References: <20220926100806.522017616@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 8594ee839628..88aa0d310aee 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2020,9 +2020,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