[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANn89iL6jEVPf3=zoxZSqME6gqRPttat_bZb7yYnRYYPLUcpQw@mail.gmail.com>
Date: Tue, 30 Jan 2024 19:33:38 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org, eric.dumazet@...il.com,
syzbot <syzkaller@...glegroups.com>, Kuniyuki Iwashima <kuniyu@...zon.com>
Subject: Re: [PATCH net] af_unix: fix lockdep positive in sk_diag_dump_icons()
On Mon, Jan 29, 2024 at 8:05 PM Eric Dumazet <edumazet@...gle.com> wrote:
>
> syzbot reported a lockdep splat [1].
>
> Blamed commit hinted about the possible lockdep
> violation, and code used unix_state_lock_nested()
> in an attempt to silence lockdep.
>
> It is not sufficient, because unix_state_lock_nested()
> is already used from unix_state_double_lock().
>
> We need to use a separate subclass.
>
> This patch adds a distinct enumeration to make things
> more explicit.
>
> Also use swap() in unix_state_double_lock() as a clean up.
>
>
...
> +#define unix_state_lock(s) spin_lock(&unix_sk(s)->lock)
> +#define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock)
> +enum unix_socket_lock_class {
> + U_LOCK_NORMAL,
> + U_LOCK_SECOND, /* for double locking, see unix_state_double_lock(). */
> + U_LOCK_DIAG, /* used while dumping icons, see sk_diag_dump_icons(). */
> +};
> +
> +static void unix_state_lock_nested(struct sock *sk,
> + enum unix_socket_lock_class subclass)
I will add an inline keyword in v2. Not sure why I did not see the
compiler warning.
> +{
> + spin_lock_nested(&unix_sk(sk)->lock, subclass);
> +}
> +
> #define peer_wait peer_wq.wait
>
Powered by blists - more mailing lists