Commit 8ebfb6db authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

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: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 10bbf165
...@@ -1126,6 +1126,15 @@ int sk_setsockopt(struct sock *sk, int level, int optname, ...@@ -1126,6 +1126,15 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
return 0; return 0;
} }
return -EPERM; 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); sockopt_lock_sock(sk);
...@@ -1248,14 +1257,6 @@ int sk_setsockopt(struct sock *sk, int level, int optname, ...@@ -1248,14 +1257,6 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
case SO_BSDCOMPAT: case SO_BSDCOMPAT:
break; 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_OLD:
case SO_TIMESTAMP_NEW: case SO_TIMESTAMP_NEW:
case SO_TIMESTAMPNS_OLD: case SO_TIMESTAMPNS_OLD:
...@@ -1361,9 +1362,6 @@ int sk_setsockopt(struct sock *sk, int level, int optname, ...@@ -1361,9 +1362,6 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
sock_valbool_flag(sk, SOCK_FILTER_LOCKED, valbool); sock_valbool_flag(sk, SOCK_FILTER_LOCKED, valbool);
break; break;
case SO_PASSSEC:
assign_bit(SOCK_PASSSEC, &sock->flags, valbool);
break;
case SO_MARK: case SO_MARK:
if (!sockopt_ns_capable(sock_net(sk)->user_ns, CAP_NET_RAW) && if (!sockopt_ns_capable(sock_net(sk)->user_ns, CAP_NET_RAW) &&
!sockopt_ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) { !sockopt_ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment