The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH net] af_unix: Inherit SO_INQ in unix_stream_connect()
@ 2026-11-11  2:32 Wenbo Sun
  2026-11-12  6:19 ` Kuniyuki Iwashima
  2026-11-12 18:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Wenbo Sun @ 2026-11-11  2:32 UTC (permalink / raw)
  To: kuniyu, davem, edumazet, kuba, pabeni
  Cc: horms, willemb, netdev, linux-kernel, sunwenbo, 1342116488

When SO_INQ is enabled on a listening AF_UNIX SOCK_STREAM socket,
accepted sockets created by unix_stream_connect() do not inherit
u->recvmsg_inq from the listener, unlike TCP_INQ, AF_VSOCK SO_INQ,
and AF_UNIX SO_RIGHTS_NOTRUNC. As a result, recvmsg() on the
accepted socket never puts an SCM_INQ control message unless SO_INQ
is set again after accept().

Copy otheru->recvmsg_inq to newu->recvmsg_inq in
unix_stream_connect() using READ_ONCE() to pair with the lockless
WRITE_ONCE() in unix_setsockopt().

Found during LLM-assisted code review of unix_stream_connect() while
comparing option inheritance between SO_INQ and SO_RIGHTS_NOTRUNC.

Confirmed on UML (x86_64) by enabling SO_INQ on a listening AF_UNIX
SOCK_STREAM socket before listen() and accept(), sending data from a
connected client, and observing that recvmsg() on the accepted socket
returned no SCM_INQ control message.

Tested on UML (x86_64) against the reproducer, verifying that
recvmsg() on the accepted socket now returns the expected SCM_INQ
control message, and ran the tools/testing/selftests/net/af_unix/scm_inq
selftest (all 6 test cases passed).

Fixes: df30285b3670 ("af_unix: Introduce SO_INQ.")
Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
---
 net/unix/af_unix.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 98fcfd7301f6..f847cf1fbeaf 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1750,6 +1750,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr_unsized *uad
 	newu = unix_sk(newsk);
 	otheru = unix_sk(other);
 	newu->listener = other;
+	newu->recvmsg_inq = READ_ONCE(otheru->recvmsg_inq);
 	newu->scm_rights_notrunc = READ_ONCE(otheru->scm_rights_notrunc);
 	RCU_INIT_POINTER(newsk->sk_wq, &newu->peer_wq);
 
-- 
2.33.0




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

* Re: [PATCH net] af_unix: Inherit SO_INQ in unix_stream_connect()
  2026-11-11  2:32 [PATCH net] af_unix: Inherit SO_INQ in unix_stream_connect() Wenbo Sun
@ 2026-11-12  6:19 ` Kuniyuki Iwashima
  2026-11-12 18:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Kuniyuki Iwashima @ 2026-11-12  6:19 UTC (permalink / raw)
  To: Wenbo Sun
  Cc: davem, edumazet, kuba, pabeni, horms, willemb, netdev,
	linux-kernel, 1342116488

On Wed, 11 Nov 2026 10:32:22 +0800, Wenbo Sun wrote:
> When SO_INQ is enabled on a listening AF_UNIX SOCK_STREAM socket,
> accepted sockets created by unix_stream_connect() do not inherit
> u->recvmsg_inq from the listener, unlike TCP_INQ, AF_VSOCK SO_INQ,
> and AF_UNIX SO_RIGHTS_NOTRUNC. As a result, recvmsg() on the
> accepted socket never puts an SCM_INQ control message unless SO_INQ
> is set again after accept().
> 
> Copy otheru->recvmsg_inq to newu->recvmsg_inq in
> unix_stream_connect() using READ_ONCE() to pair with the lockless
> WRITE_ONCE() in unix_setsockopt().
> 
> Found during LLM-assisted code review of unix_stream_connect() while
> comparing option inheritance between SO_INQ and SO_RIGHTS_NOTRUNC.
> 
> Confirmed on UML (x86_64) by enabling SO_INQ on a listening AF_UNIX
> SOCK_STREAM socket before listen() and accept(), sending data from a
> connected client, and observing that recvmsg() on the accepted socket
> returned no SCM_INQ control message.
> 
> Tested on UML (x86_64) against the reproducer, verifying that
> recvmsg() on the accepted socket now returns the expected SCM_INQ
> control message, and ran the tools/testing/selftests/net/af_unix/scm_inq
> selftest (all 6 test cases passed).
> 
> Fixes: df30285b3670 ("af_unix: Introduce SO_INQ.")
> Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>

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

Thanks

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

* Re: [PATCH net] af_unix: Inherit SO_INQ in unix_stream_connect()
  2026-11-11  2:32 [PATCH net] af_unix: Inherit SO_INQ in unix_stream_connect() Wenbo Sun
  2026-11-12  6:19 ` Kuniyuki Iwashima
@ 2026-11-12 18:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-12 18:50 UTC (permalink / raw)
  To: Wenbo Sun
  Cc: kuniyu, davem, edumazet, kuba, pabeni, horms, willemb, netdev,
	linux-kernel, 1342116488

Hello:

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

On Wed, 11 Nov 2026 10:32:22 +0800 you wrote:
> When SO_INQ is enabled on a listening AF_UNIX SOCK_STREAM socket,
> accepted sockets created by unix_stream_connect() do not inherit
> u->recvmsg_inq from the listener, unlike TCP_INQ, AF_VSOCK SO_INQ,
> and AF_UNIX SO_RIGHTS_NOTRUNC. As a result, recvmsg() on the
> accepted socket never puts an SCM_INQ control message unless SO_INQ
> is set again after accept().
> 
> [...]

Here is the summary with links:
  - [net] af_unix: Inherit SO_INQ in unix_stream_connect()
    https://git.kernel.org/netdev/net/c/0359338fd8cf

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 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11  2:32 [PATCH net] af_unix: Inherit SO_INQ in unix_stream_connect() Wenbo Sun
2026-11-12  6:19 ` Kuniyuki Iwashima
2026-11-12 18:50 ` 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