lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210329090248.4209-1-lyl2019@mail.ustc.edu.cn>
Date:   Mon, 29 Mar 2021 02:02:48 -0700
From:   Lv Yunlong <lyl2019@...l.ustc.edu.cn>
To:     hkallweit1@...il.com, nic_swsd@...ltek.com, kuba@...nel.org
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        Lv Yunlong <lyl2019@...l.ustc.edu.cn>
Subject: [PATCH] ethernet/realtek/r8169: Fix a double free in rtl8169_start_xmit

In rtl8169_start_xmit, it calls rtl8169_tso_csum_v2(tp, skb, opts) and
rtl8169_tso_csum_v2() calls __skb_put_padto(skb, padto, false). If
__skb_put_padto() failed, it will free the skb in the first time and
return error. Then rtl8169_start_xmit will goto err_dma_0.

But in err_dma_0 label, the skb is freed by dev_kfree_skb_any(skb) in
the second time.

My patch adds a new label inside the old err_dma_0 label to avoid the
double free and renames the error labels to keep the origin function
unchanged.

Fixes: b8447abc4c8fb ("r8169: factor out rtl8169_tx_map")
Signed-off-by: Lv Yunlong <lyl2019@...l.ustc.edu.cn>
---
 drivers/net/ethernet/realtek/r8169_main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index f704da3f214c..91c43399712b 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -4217,13 +4217,13 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
 
 	if (unlikely(rtl8169_tx_map(tp, opts, skb_headlen(skb), skb->data,
 				    entry, false)))
-		goto err_dma_0;
+		goto err_dma_1;
 
 	txd_first = tp->TxDescArray + entry;
 
 	if (frags) {
 		if (rtl8169_xmit_frags(tp, skb, opts, entry))
-			goto err_dma_1;
+			goto err_dma_2;
 		entry = (entry + frags) % NUM_TX_DESC;
 	}
 
@@ -4270,10 +4270,11 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
 
 	return NETDEV_TX_OK;
 
-err_dma_1:
+err_dma_2:
 	rtl8169_unmap_tx_skb(tp, entry);
-err_dma_0:
+err_dma_1:
 	dev_kfree_skb_any(skb);
+err_dma_0:
 	dev->stats.tx_dropped++;
 	return NETDEV_TX_OK;
 
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ