From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5338C19DF4D; Thu, 6 Jun 2024 14:11:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683097; cv=none; b=P2uUW2RraejS811x60ja3jMZf3ekLgj2f5wdGuUtt7QaEtU3SCv/9ioXuZ2gijkE31fsdHQlTPETJzkRiaPjYNCk+Q6mNFgjeFeLzpcqKUMqD47fPRe5gcI/AuEo8EqneIgl9Tce+yv3BqlvFJU5wW3ZP6IdqEKR7fS8WXXy8j0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683097; c=relaxed/simple; bh=E+Hl69RV2y6dtawCGtB4eYiNtjEGve/V686k+Esxjw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GdZb4LK83Q2YxSRcnGhODrOETkU6H5SYOX9rJQXNM4MY1XcGNGp32Xt9kaMbY2X866kA7IIax5uOqHjF/S/XnQAaXN9kI6dZKGSsUBl1yuKbHIN36VrxU480s6LCvn04URuB9CvZ5vuKrroEsZzkEnjSaw+i5sU7U6TE6CuWKcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vRO/EKfe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="vRO/EKfe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31FA7C2BD10; Thu, 6 Jun 2024 14:11:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1717683097; bh=E+Hl69RV2y6dtawCGtB4eYiNtjEGve/V686k+Esxjw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vRO/EKfe0jHPakVveQDPsR/qtvy87zAldm0w64Qm44lCcScIudQLuly8p3OTS6eTP TEEvvjl83jXGW39JP9R1yu/eDIrkXLsLs+Z3MYVCN+GrddL3DacRoxZLsTJfe5DLGE HTmk5useHs4LTam5ErdX5p4tf6fY1v3SsPzmzuoE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ken Milmore , Heiner Kallweit , Paolo Abeni Subject: [PATCH 6.6 012/744] r8169: Fix possible ring buffer corruption on fragmented Tx packets. Date: Thu, 6 Jun 2024 15:54:44 +0200 Message-ID: <20240606131732.843096891@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240606131732.440653204@linuxfoundation.org> References: <20240606131732.440653204@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ken Milmore commit c71e3a5cffd5309d7f84444df03d5b72600cc417 upstream. An issue was found on the RTL8125b when transmitting small fragmented packets, whereby invalid entries were inserted into the transmit ring buffer, subsequently leading to calls to dma_unmap_single() with a null address. This was caused by rtl8169_start_xmit() not noticing changes to nr_frags which may occur when small packets are padded (to work around hardware quirks) in rtl8169_tso_csum_v2(). To fix this, postpone inspecting nr_frags until after any padding has been applied. Fixes: 9020845fb5d6 ("r8169: improve rtl8169_start_xmit") Cc: stable@vger.kernel.org Signed-off-by: Ken Milmore Reviewed-by: Heiner Kallweit Link: https://lore.kernel.org/r/27ead18b-c23d-4f49-a020-1fc482c5ac95@gmail.com Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/realtek/r8169_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4246,11 +4246,11 @@ static void rtl8169_doorbell(struct rtl8 static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev) { - unsigned int frags = skb_shinfo(skb)->nr_frags; struct rtl8169_private *tp = netdev_priv(dev); unsigned int entry = tp->cur_tx % NUM_TX_DESC; struct TxDesc *txd_first, *txd_last; bool stop_queue, door_bell; + unsigned int frags; u32 opts[2]; if (unlikely(!rtl_tx_slots_avail(tp))) { @@ -4273,6 +4273,7 @@ static netdev_tx_t rtl8169_start_xmit(st txd_first = tp->TxDescArray + entry; + frags = skb_shinfo(skb)->nr_frags; if (frags) { if (rtl8169_xmit_frags(tp, skb, opts, entry)) goto err_dma_1;