Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3672777pxv; Mon, 26 Jul 2021 09:08:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7VKIJa6qSYcxsGUAU1jjsvJR7r/QJktqRcyVOT9161xfHy//9HQs0W02b6oTzkRJpIBMl X-Received: by 2002:a17:906:d20b:: with SMTP id w11mr18074731ejz.242.1627315695291; Mon, 26 Jul 2021 09:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315695; cv=none; d=google.com; s=arc-20160816; b=V5hoBA8XaNCEy4yn7TwoLOV1gCJV4v127n95fZGcChGi46u6vHtQuSMlHEVrpw0GCX m9CSqspd1tWUoKdSXlLfCip4PbUXzJabf13glM4lL5rI4zyRYwKIkSf8N4qGR+oPgwvD PckWV+hOmfzgu+ofSJEBrZ8mHvuN38uXJ9KF3q1mv114v6Mrp3zAfybCnEhpfkg5Z0+f yZflASrXFU3VB0zTm4w9xSN82GsJXLDF4kIgXa0githu1dpYe6P9wT9UgANQ3P5rsrke E0dmedsQJPZMHYSYLi+MPRh2WQ8DW0KTlBqm0bZhtQAI7aiH38Vskf4FyUA6v0NNh6F0 ddSg== 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=ezuxRo+HtuKrof7N7qNyiJ1nIsLZPO/fjHCg/0iwtX4=; b=KXzMxl53zXOMryNChmVtPgFk2PBoFEorhv06mLobxT4ODkgeM2NXoz08BHr1Cgw1lh TIksARoMDOi93p2gFjW/b6T9Dt3/2O/ddCAOCDPNQHHNFoCbR5zI4O4tOweWFvrKEVyT tS73KI2b8QxKPkJQQp0GEggTGzojq2IW6bDENGrQ6+t4ZicueRvx8S2hN2Ip0flqe0NB VqOebi2u58Ano9NqszbjubWYeVraqaiY0AHZPbnkraMX4KyJ96dZg5XGbZpE5u6mVNln XNczvn+zZKCwVPwVChZiGVR0KofErbx5LKBrkPZb97r4qAYKBeSwbpbs73jHvJlZZNQm RreQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IvY3uqKs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v4si352040edj.103.2021.07.26.09.07.52; Mon, 26 Jul 2021 09:08:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IvY3uqKs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S237333AbhGZPW2 (ORCPT + 99 others); Mon, 26 Jul 2021 11:22:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237408AbhGZPPo (ORCPT ); Mon, 26 Jul 2021 11:15:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8C0CB6101C; Mon, 26 Jul 2021 15:54:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314872; bh=O3bklign98ABGAFKWn6e8vbnjb9JvA5CRHH5nI+k1Bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IvY3uqKs0wVwOrBKP2bezyuPjEjCmxygPGc400tol9wNB9V2IKGNz157m6q7y2uRt pTe3ZOqZ367lCURyQb0Ac672s9X9wIWD/SXHlmHgSSHjk2m1XDB32D77ndjXi1x6Fd 5Z8QpjbohdIUmJdS0ekFgdfZy9I90X14x7VYES1c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Markus Boehme , Tony Brelinski , Tony Nguyen , "David S. Miller" Subject: [PATCH 4.19 107/120] ixgbe: Fix packet corruption due to missing DMA sync Date: Mon, 26 Jul 2021 17:39:19 +0200 Message-Id: <20210726153835.885170431@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153832.339431936@linuxfoundation.org> References: <20210726153832.339431936@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Boehme commit 09cfae9f13d51700b0fecf591dcd658fc5375428 upstream. When receiving a packet with multiple fragments, hardware may still touch the first fragment until the entire packet has been received. The driver therefore keeps the first fragment mapped for DMA until end of packet has been asserted, and delays its dma_sync call until then. The driver tries to fit multiple receive buffers on one page. When using 3K receive buffers (e.g. using Jumbo frames and legacy-rx is turned off/build_skb is being used) on an architecture with 4K pages, the driver allocates an order 1 compound page and uses one page per receive buffer. To determine the correct offset for a delayed DMA sync of the first fragment of a multi-fragment packet, the driver then cannot just use PAGE_MASK on the DMA address but has to construct a mask based on the actual size of the backing page. Using PAGE_MASK in the 3K RX buffer/4K page architecture configuration will always sync the first page of a compound page. With the SWIOTLB enabled this can lead to corrupted packets (zeroed out first fragment, re-used garbage from another packet) and various consequences, such as slow/stalling data transfers and connection resets. For example, testing on a link with MTU exceeding 3058 bytes on a host with SWIOTLB enabled (e.g. "iommu=soft swiotlb=262144,force") TCP transfers quickly fizzle out without this patch. Cc: stable@vger.kernel.org Fixes: 0c5661ecc5dd7 ("ixgbe: fix crash in build_skb Rx code path") Signed-off-by: Markus Boehme Tested-by: Tony Brelinski Signed-off-by: Tony Nguyen Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1823,7 +1823,8 @@ static void ixgbe_dma_sync_frag(struct i struct sk_buff *skb) { if (ring_uses_build_skb(rx_ring)) { - unsigned long offset = (unsigned long)(skb->data) & ~PAGE_MASK; + unsigned long mask = (unsigned long)ixgbe_rx_pg_size(rx_ring) - 1; + unsigned long offset = (unsigned long)(skb->data) & mask; dma_sync_single_range_for_cpu(rx_ring->dev, IXGBE_CB(skb)->dma,