[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231017085146.GL1751252@kernel.org>
Date: Tue, 17 Oct 2023 10:51:46 +0200
From: Simon Horman <horms@...nel.org>
To: Jiri Pirko <jiri@...nulli.us>
Cc: netdev@...r.kernel.org, kuba@...nel.org, pabeni@...hat.com,
davem@...emloft.net, edumazet@...gle.com
Subject: Re: [patch net-next v3 4/7] devlink: don't take instance lock for
nested handle put
On Fri, Oct 13, 2023 at 02:10:26PM +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@...dia.com>
>
> Lockdep reports following issue:
>
> WARNING: possible circular locking dependency detected
> ------------------------------------------------------
> devlink/8191 is trying to acquire lock:
> ffff88813f32c250 (&devlink->lock_key#14){+.+.}-{3:3}, at: devlink_rel_devlink_handle_put+0x11e/0x2d0
>
> but task is already holding lock:
> ffffffff8511eca8 (rtnl_mutex){+.+.}-{3:3}, at: unregister_netdev+0xe/0x20
>
> which lock already depends on the new lock.
>
> the existing dependency chain (in reverse order) is:
>
> -> #3 (rtnl_mutex){+.+.}-{3:3}:
...
> Possible unsafe locking scenario:
>
> CPU0 CPU1
> ---- ----
> lock(rtnl_mutex);
> lock(mlx5_intf_mutex);
> lock(rtnl_mutex);
> lock(&devlink->lock_key#14);
>
> Problem is taking the devlink instance lock of nested instance when RTNL
> is already held.
>
> To fix this, don't take the devlink instance lock when putting nested
> handle. Instead, rely on the preparations done by previous two patches
> to be able to access device pointer and obtain netns id without devlink
> instance lock held.
>
> Fixes: c137743bce02 ("devlink: introduce object and nested devlink relationship infra")
> Signed-off-by: Jiri Pirko <jiri@...dia.com>
Reviewed-by: Simon Horman <horms@...nel.org>
Powered by blists - more mailing lists