Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3663497pxv; Mon, 26 Jul 2021 08:58:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8udA4fTte63Nyyy2aTJf7NcLHmON56XnoASKPfChxUJKD3O5sctaCBZYHHab5a2L2/Ag9 X-Received: by 2002:a17:906:2f15:: with SMTP id v21mr17328563eji.220.1627315134783; Mon, 26 Jul 2021 08:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315134; cv=none; d=google.com; s=arc-20160816; b=d8+alZ1EHDpzL5w521RhTRD6bay8BA4Hu4hi8asiTE/L9DRViiwrjwm5leKpdWWlbD nCxSwwdrv6VtNZtqo758eTLK9xDMITa027Njd3vy2FR5/Q8dHl13INlx14o6lyqR6BJT kPv6q1QCTkysnOBeJOx2zdI+prHGnThv1BdK4vQaddypjiw0bw3LZ0D0DpRIS9NYDLs1 MVpFcr1Q5VWRPvWre6mfyG8HbGXzzcLuP264qmHE8dWD+WoLxMH3emAfDNXn8RzCJ+5k U0y4i39c2OSzPKX7/fQFkfeZl4b618WaxvIZyn2y4TR4ZAP3YLM6k2llSVUmluuqI07d UpCQ== 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=K1+Dho59OxDW32TMU9SR2Uc7ci0c79JkFRT26uhesi8=; b=Wslt6vXMZZii157riBDD6t9hmYT8LySSzr1YS5cUCvVzAoIhQ1BAa9YjZvXrYjfQeq ap5RgX1vNghGOJS/RlxKWt0ZS6lxKccwYMxhHPRoj1SAD3kMlWdxKSBxmiZMqQIRxytw zS6S0zKZooBvhG//UZdjZv7KSO2mMe+b2eCXGsTaB7MmPE5YncnLaK9A92bvDQe8c+ma 4HzY9IliVOZBdr0MW63qCUzsTx4jq29igUvl4BMPsV/Na1wOr/mqAekh5UHO6xD0OcZz i3YtFAKoSZFBXhOtaI0W/i58N+NTwhWGT7ZOfPaiTB0x7syf0hDoL/Yaog5cBtvr0UP1 EAtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1BVJ1RlP; 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 h14si250609ejt.392.2021.07.26.08.58.28; Mon, 26 Jul 2021 08:58:54 -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=1BVJ1RlP; 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 S237699AbhGZPQT (ORCPT + 99 others); Mon, 26 Jul 2021 11:16:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:49364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236354AbhGZPIA (ORCPT ); Mon, 26 Jul 2021 11:08:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 06E9560F9B; Mon, 26 Jul 2021 15:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314508; bh=auDwRLwTVCHo8yYe7iehfT/XxyLq4c0X3GuENH/smVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1BVJ1RlPw5zim69b/Mdr0pcW4H6I4T50QCSTA+ZMXAPrUp4Rt9fw6hqQF3U7YEulq Wgb873K+BtyctlmqAfIGTJFYL5wCDUYIQdeeXnJuofO4jDtmYGXnrvdekTF+vYfsw/ 83lDitIyNxO/282KkrbXf+ZZKsIvVu7ua9HeVN8Y= 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.14 74/82] ixgbe: Fix packet corruption due to missing DMA sync Date: Mon, 26 Jul 2021 17:39:14 +0200 Message-Id: <20210726153830.581847662@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153828.144714469@linuxfoundation.org> References: <20210726153828.144714469@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 @@ -1872,7 +1872,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,