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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191218140102.11579-1-baijiaju1990@gmail.com>
Date:   Wed, 18 Dec 2019 22:01:02 +0800
From:   Jia-Ju Bai <baijiaju1990@...il.com>
To:     thomas.lendacky@....com, davem@...emloft.net
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jia-Ju Bai <baijiaju1990@...il.com>
Subject: [PATCH] net: amd: xgbe: fix possible sleep-in-atomic-context bugs in xgbe_powerdown()

The driver may sleep while holding a spinlock.
The function call path (from bottom to top) in Linux 4.19 is:

drivers/net/ethernet/amd/xgbe/xgbe-drv.c, 1261: 
	flush_workqueue in xgbe_powerdown
drivers/net/ethernet/amd/xgbe/xgbe-drv.c, 1253: 
	_raw_spin_lock_irqsave in xgbe_powerdown

drivers/net/ethernet/amd/xgbe/xgbe-drv.c, 1055: 
	napi_disable in xgbe_napi_disable
drivers/net/ethernet/amd/xgbe/xgbe-drv.c, 1266: 
	xgbe_napi_disable in xgbe_powerdown
drivers/net/ethernet/amd/xgbe/xgbe-drv.c, 1253: 
	_raw_spin_lock_irqsave in xgbe_powerdown

drivers/net/ethernet/amd/xgbe/xgbe-drv.c, 1049: 
	napi_disable in xgbe_napi_disable
drivers/net/ethernet/amd/xgbe/xgbe-drv.c, 1266: 
	xgbe_napi_disable in xgbe_powerdown
drivers/net/ethernet/amd/xgbe/xgbe-drv.c, 1253: 
	_raw_spin_lock_irqsave in xgbe_powerdown

flush_workqueue() and napi_disable() can sleep at runtime.

To fix these bugs, flush_workqueue() and xgbe_napi_disable() are called
without holding the spinlock.

These bugs are found by a static analysis tool STCheck written by
myself.

Signed-off-by: Jia-Ju Bai <baijiaju1990@...il.com>
---
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 98f8f2033154..328361d0e190 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -1257,17 +1257,18 @@ int xgbe_powerdown(struct net_device *netdev, unsigned int caller)
 	netif_tx_stop_all_queues(netdev);
 
 	xgbe_stop_timers(pdata);
-	flush_workqueue(pdata->dev_workqueue);
 
 	hw_if->powerdown_tx(pdata);
 	hw_if->powerdown_rx(pdata);
 
-	xgbe_napi_disable(pdata, 0);
-
 	pdata->power_down = 1;
 
 	spin_unlock_irqrestore(&pdata->lock, flags);
 
+	flush_workqueue(pdata->dev_workqueue);
+
+	xgbe_napi_disable(pdata, 0);
+
 	DBGPR("<--xgbe_powerdown\n");
 
 	return 0;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ