Re: [syzbot] Re: [syzbot] [net?] possible deadlock in team_device_event (3)

From: syzbot
Date: Wed Jul 31 2024 - 08:18:55 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: Re: [syzbot] [net?] possible deadlock in team_device_event (3)
Author: aha310510@xxxxxxxxx

#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

---
drivers/net/team/team_core.c | 5 ++++-
include/linux/if_team.h | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
index ab1935a4aa2c..963c8311694f 100644
--- a/drivers/net/team/team_core.c
+++ b/drivers/net/team/team_core.c
@@ -1621,6 +1621,7 @@ static int team_init(struct net_device *dev)
team->dev = dev;
team_set_no_mode(team);
team->notifier_ctx = false;
+ team->nested_depth = 1;

team->pcpu_stats = netdev_alloc_pcpu_stats(struct team_pcpu_stats);
if (!team->pcpu_stats)
@@ -2947,8 +2948,10 @@ static void team_port_change_check(struct team_port *port, bool linkup)
{
struct team *team = port->team;

- mutex_lock(&team->lock);
+ mutex_lock_nested(&team->lock, team->nested_depth);
+ team->nested_depth++;
__team_port_change_check(port, linkup);
+ team->nested_depth--;
mutex_unlock(&team->lock);
}

diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index cdc684e04a2f..f8b4e3ed4b44 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -225,6 +225,7 @@ struct team {
} mcast_rejoin;
struct lock_class_key team_lock_key;
long mode_priv[TEAM_MODE_PRIV_LONGS];
+ unsigned int nested_depth;
};

static inline int team_dev_queue_xmit(struct team *team, struct team_port *port,
--