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>] [day] [month] [year] [list]
Message-Id: <20210625212628.14514-1-paskripkin@gmail.com>
Date:   Sat, 26 Jun 2021 00:26:28 +0300
From:   Pavel Skripkin <paskripkin@...il.com>
To:     davem@...emloft.net, kuba@...nel.org
Cc:     linux-kernel@...r.kernel.org,
        linux-kernel-mentees@...ts.linuxfoundation.org,
        Pavel Skripkin <paskripkin@...il.com>
Subject: [PATCH] net: ethernet: fix UAF in ltq_etop_init

In ltq_etop_init() netdev was used after free_netdev():

err_netdev:
	unregister_netdev(dev);
	free_netdev(dev);
err_hw:
	ltq_etop_hw_exit(dev);
	return err;

It causes use-after-free read/write in ltq_etop_hw_exit().
Fix it by rewriting error handling path in this function. No logic
changes, only small refactoring.

Fixes: ("MIPS: Lantiq: Add ethernet driver")
Signed-off-by: Pavel Skripkin <paskripkin@...il.com>
---
 drivers/net/ethernet/lantiq_etop.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 2d0c52f7106b..807a671ebcf8 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -553,8 +553,10 @@ ltq_etop_init(struct net_device *dev)
 
 	dev->watchdog_timeo = 10 * HZ;
 	err = ltq_etop_hw_init(dev);
-	if (err)
-		goto err_hw;
+	if (err) {
+		ltq_etop_hw_exit(dev);
+		return err;
+	}
 	ltq_etop_change_mtu(dev, 1500);
 
 	memcpy(&mac, &priv->pldata->mac, sizeof(struct sockaddr));
@@ -580,9 +582,8 @@ ltq_etop_init(struct net_device *dev)
 
 err_netdev:
 	unregister_netdev(dev);
-	free_netdev(dev);
-err_hw:
 	ltq_etop_hw_exit(dev);
+	free_netdev(dev);
 	return err;
 }
 
-- 
2.32.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ