# Re: \[PATCH v4 net-next 6/9\] af\_unix: Move SOCK\_PASS{CRED,PIDFD,SEC} to struct sock.

- From: Willem de Bruijn \<willemdebruijn.kernel@gmail.com\>
- Date: 2025-05-16 16:29:31 
- List: netdev
- Page: https://ratatoskr.run/netdev/2025/05/11327488
- Thread: https://ratatoskr.run/netdev/2025/05/11327390/t.md

```text
Kuniyuki Iwashima wrote:
> 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.
> 
> Note that assign_bit() was atomic, so the writer side is moved down
> after lock_sock() in setsockopt(), but the bit is only read once
> in sendmsg() and recvmsg(), so lock_sock() is not needed there.
> 
> Signed-off-by: Kuniyuki Iwashima <redacted>

Reviewed-by: Willem de Bruijn <willemb@google.com>
```
