diff options
author | Eric Dumazet <edumazet@google.com> | 2023-09-21 20:28:12 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-10-01 19:09:54 +0100 |
commit | 8ebfb6db5a01f16cd37254bfad7145204e4bf6f2 (patch) | |
tree | ad41953d493e47f197307217f211816ac47d095e /net/core | |
parent | 10bbf1652c1cca9819e98d56f3432c56d7a2d229 (diff) | |
download | lwn-8ebfb6db5a01f16cd37254bfad7145204e4bf6f2.tar.gz lwn-8ebfb6db5a01f16cd37254bfad7145204e4bf6f2.zip |
net: lockless SO_PASSCRED, SO_PASSPIDFD and SO_PASSSEC
sock->flags are atomic, no need to hold the socket lock
in sk_setsockopt() for SO_PASSCRED, SO_PASSPIDFD and SO_PASSSEC.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/sock.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 1fdc0a0d8ff2..f01c75724568 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1126,6 +1126,15 @@ int sk_setsockopt(struct sock *sk, int level, int optname, return 0; } return -EPERM; + case SO_PASSSEC: + assign_bit(SOCK_PASSSEC, &sock->flags, valbool); + return 0; + case SO_PASSCRED: + assign_bit(SOCK_PASSCRED, &sock->flags, valbool); + return 0; + case SO_PASSPIDFD: + assign_bit(SOCK_PASSPIDFD, &sock->flags, valbool); + return 0; } sockopt_lock_sock(sk); @@ -1248,14 +1257,6 @@ set_sndbuf: case SO_BSDCOMPAT: break; - case SO_PASSCRED: - assign_bit(SOCK_PASSCRED, &sock->flags, valbool); - break; - - case SO_PASSPIDFD: - assign_bit(SOCK_PASSPIDFD, &sock->flags, valbool); - break; - case SO_TIMESTAMP_OLD: case SO_TIMESTAMP_NEW: case SO_TIMESTAMPNS_OLD: @@ -1361,9 +1362,6 @@ set_sndbuf: sock_valbool_flag(sk, SOCK_FILTER_LOCKED, valbool); break; - case SO_PASSSEC: - assign_bit(SOCK_PASSSEC, &sock->flags, valbool); - break; case SO_MARK: if (!sockopt_ns_capable(sock_net(sk)->user_ns, CAP_NET_RAW) && !sockopt_ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) { |