All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] alx: acquire mutex for alx_reinit in alx_change_mtu
@ 2022-03-10 23:27 Niels Dossche
  2022-03-12  7:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Niels Dossche @ 2022-03-10 23:27 UTC (permalink / raw)
  To: netdev
  Cc: Chris Snook, David S. Miller, Jakub Kicinski, Johannes Berg,
	Niels Dossche

alx_reinit has a lockdep assertion that the alx->mtx mutex must be held.
alx_reinit is called from two places: alx_reset and alx_change_mtu.
alx_reset does acquire alx->mtx before calling alx_reinit.
alx_change_mtu does not acquire this mutex, nor do its callers or any
path towards alx_change_mtu.
Acquire the mutex in alx_change_mtu.

The issue was introduced when the fine-grained locking was introduced
to the code to replace the RTNL. The same commit also introduced the
lockdep assertion.

Fixes: 4a5fe57e7751 ("alx: use fine-grained locking instead of RTNL")
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
---

Changes in v2:
 - Added Fixes tag and explainer

 drivers/net/ethernet/atheros/alx/main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index 4ad3fc72e74e..a89b93cb4e26 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -1181,8 +1181,11 @@ static int alx_change_mtu(struct net_device *netdev, int mtu)
 	alx->hw.mtu = mtu;
 	alx->rxbuf_size = max(max_frame, ALX_DEF_RXBUF_SIZE);
 	netdev_update_features(netdev);
-	if (netif_running(netdev))
+	if (netif_running(netdev)) {
+		mutex_lock(&alx->mtx);
 		alx_reinit(alx);
+		mutex_unlock(&alx->mtx);
+	}
 	return 0;
 }
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] alx: acquire mutex for alx_reinit in alx_change_mtu
  2022-03-10 23:27 [PATCH v2] alx: acquire mutex for alx_reinit in alx_change_mtu Niels Dossche
@ 2022-03-12  7:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-12  7:00 UTC (permalink / raw)
  To: Niels Dossche; +Cc: netdev, chris.snook, davem, kuba, johannes

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 11 Mar 2022 00:27:08 +0100 you wrote:
> alx_reinit has a lockdep assertion that the alx->mtx mutex must be held.
> alx_reinit is called from two places: alx_reset and alx_change_mtu.
> alx_reset does acquire alx->mtx before calling alx_reinit.
> alx_change_mtu does not acquire this mutex, nor do its callers or any
> path towards alx_change_mtu.
> Acquire the mutex in alx_change_mtu.
> 
> [...]

Here is the summary with links:
  - [v2] alx: acquire mutex for alx_reinit in alx_change_mtu
    https://git.kernel.org/netdev/net/c/46b348fd2d81

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-12  7:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 23:27 [PATCH v2] alx: acquire mutex for alx_reinit in alx_change_mtu Niels Dossche
2022-03-12  7:00 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.