Re: [PATCH net,v2] team: Fix ABBA deadlock caused by race in team_del_slave
From: Stephen Hemminger
Date: Sat Jul 06 2024 - 11:01:13 EST
On Sat, 6 Jul 2024 13:13:29 +0900
Jeongjun Park <aha310510@xxxxxxxxx> wrote:
> CPU0 CPU1
> ---- ----
> lock(&rdev->wiphy.mtx);
> lock(team->team_lock_key#4);
> lock(&rdev->wiphy.mtx);
> lock(team->team_lock_key#4);
>
> Deadlock occurs due to the above scenario. Therefore, you can prevent
> deadlock by briefly releasing the lock before calling dev_open() in
> team_port_add() and locking it again after it returns.
>
> Reported-and-tested-by: syzbot+705c61d60b091ef42c04@xxxxxxxxxxxxxxxxxxxxxxxxx
> Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
> Signed-off-by: Jeongjun Park <aha310510@xxxxxxxxx>
> ---
But if you drop the lock the actual data structures might have changed.
Usually not a good idea,