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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231127175736.5738-3-hau@realtek.com>
Date:   Tue, 28 Nov 2023 01:57:36 +0800
From:   ChunHao Lin <hau@...ltek.com>
To:     <hkallweit1@...il.com>
CC:     <nic_swsd@...ltek.com>, <davem@...emloft.net>,
        <edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.com>,
        <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <grundler@...omium.org>, ChunHao Lin <hau@...ltek.com>,
        <stable@...r.kernel.org>
Subject: [PATCH net 2/2] r8169: fix deadlock in "r8169_phylink_handler"

In "r8169_phylink_handler", for rtl8125, it will call "rtl_reset_work"->
"rtl_hw_start"->"rtl_jumbo_config"->"phy_start_aneg". When call
"r8169_phylink_handler", PHY lock is acquired. But "phy_start_aneg"
will also try to acquire PHY lock. That will cause deadlock.

In this path, use "_phy_start_aneg", unlocked version "phy_start_aneg",
to prevent deadlock in "r8169_phylink_handler".

Fixes: 453a77894efa ("r8169: don't advertise pause in jumbo mode")
Cc: stable@...r.kernel.org
Signed-off-by: ChunHao Lin <hau@...ltek.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 473b3245754f..2e3e42a98edd 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -2415,11 +2415,22 @@ static void rtl_jumbo_config(struct rtl8169_private *tp)
 
 	/* Chip doesn't support pause in jumbo mode */
 	if (jumbo) {
+		int lock;
+
 		linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT,
 				   tp->phydev->advertising);
 		linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
 				   tp->phydev->advertising);
-		phy_start_aneg(tp->phydev);
+
+		if (!mutex_trylock(&tp->phydev->lock))
+			lock = 0;
+		else
+			lock = 1;
+
+		_phy_start_aneg(tp->phydev);
+
+		if (lock)
+			mutex_unlock(&tp->phydev->lock);
 	}
 }
 
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ