Re: [PATCH,net-next,v2] af_unix: Fix wrong socket tested in the symmetric half of unix_state_lock_cmp_fn().
From: Kuniyuki Iwashima
Date: Tue Nov 10 2026 - 01:21:48 EST
On Mon, 09 Nov 2026 17:20:16 +0800, lirongqing wrote:
> From: Li RongQing <lirongqing@xxxxxxxxx>
>
> The second half of unix_state_lock_cmp_fn() mirrors the first with a and b
> swapped, but it tests b->sk.sk_state again. Since b is already known to be
> TCP_LISTEN, the switch only hits default and always returns 0 ("no order
> known") instead of 1. Test a's state instead, as the first half does.
>
> This code is only built with CONFIG_PROVE_LOCKING, so the impact is limited
> to lockdep failing to validate this unix_state_lock() nesting order.
>
> Found by AI.
>
> Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx>
Reviewed-by: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx>
Thanks