The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH,net-next,v2] af_unix: Fix wrong socket tested in the symmetric half of unix_state_lock_cmp_fn().
@ 2026-11-09  9:20 lirongqing
  2026-11-10  6:21 ` Kuniyuki Iwashima
  2026-11-12  2:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: lirongqing @ 2026-11-09  9:20 UTC (permalink / raw)
  To: Kuniyuki Iwashima, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, netdev, linux-kernel
  Cc: Li RongQing

From: Li RongQing <lirongqing@baidu.com>

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@baidu.com>
---
Diff with v1: target to net-next, and drop fix tag

 net/unix/af_unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index e7a0582..501e693 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -163,7 +163,7 @@ static int unix_state_lock_cmp_fn(const struct lockdep_map *_a,
 
 	/* Should never happen.  Just to be symmetric. */
 	if (b->sk.sk_state == TCP_LISTEN) {
-		switch (b->sk.sk_state) {
+		switch (a->sk.sk_state) {
 		case TCP_CLOSE:
 		case TCP_ESTABLISHED:
 			return 1;
-- 
2.9.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH,net-next,v2] af_unix: Fix wrong socket tested in the symmetric half of unix_state_lock_cmp_fn().
  2026-11-09  9:20 [PATCH,net-next,v2] af_unix: Fix wrong socket tested in the symmetric half of unix_state_lock_cmp_fn() lirongqing
@ 2026-11-10  6:21 ` Kuniyuki Iwashima
  2026-11-12  2:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Kuniyuki Iwashima @ 2026-11-10  6:21 UTC (permalink / raw)
  To: lirongqing
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, netdev, linux-kernel

On Mon, 09 Nov 2026 17:20:16 +0800, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
> 
> 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@baidu.com>

Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>

Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH,net-next,v2] af_unix: Fix wrong socket tested in the symmetric half of unix_state_lock_cmp_fn().
  2026-11-09  9:20 [PATCH,net-next,v2] af_unix: Fix wrong socket tested in the symmetric half of unix_state_lock_cmp_fn() lirongqing
  2026-11-10  6:21 ` Kuniyuki Iwashima
@ 2026-11-12  2:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-12  2:00 UTC (permalink / raw)
  To: Li, Rongqing
  Cc: kuniyu, davem, edumazet, kuba, pabeni, horms, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 9 Nov 2026 17:20:16 +0800 you wrote:
> From: Li RongQing <lirongqing@baidu.com>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] af_unix: Fix wrong socket tested in the symmetric half of unix_state_lock_cmp_fn().
    https://git.kernel.org/netdev/net-next/c/96750c67eda8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-12  2:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09  9:20 [PATCH,net-next,v2] af_unix: Fix wrong socket tested in the symmetric half of unix_state_lock_cmp_fn() lirongqing
2026-11-10  6:21 ` Kuniyuki Iwashima
2026-11-12  2:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox