From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Mon, 12 May 2025 15:20:54 -0400
Kuniyuki Iwashima wrote:
quoted
As explained in the next patch, SO_PASSRIGHTS would have a problem
if we assigned a corresponding bit to socket->flags, so it must be
managed in struct sock.
Mixing socket->flags and sk->sk_flags for similar options will look
confusing, and sk->sk_flags does not have enough space on 32bit system.
Also, as mentioned in commit 16e572626961 ("af_unix: dont send
SCM_CREDENTIALS by default"), SOCK_PASSCRED and SOCK_PASSPID handling
is known to be slow, and managing the flags in struct socket cannot
avoid that for embryo sockets.
Let's move SOCK_PASS{CRED,PIDFD,SEC} to struct sock.
While at it, other SOCK_XXX flags in net.h are grouped as enum.
Signed-off-by: Kuniyuki Iwashima <redacted>
quoted
diff --git a/net/core/sock.c b/net/core/sock.c
index 1ab59efbafc5..9540cbe3d83e 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1224,19 +1224,19 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
if (!sk_may_scm_recv(sk))
return -EOPNOTSUPP;
- assign_bit(SOCK_PASSSEC, &sock->flags, valbool);
+ sk->sk_scm_security = valbool;
Is it safe to switch from atomic to non-atomic updates?
Reads and writes can race. Especially given that these are bit stores, so RMW.
Exactly, will move them down after sockopt_lock_sock().