Commit 6cc7a765 authored by Maciej Żenczykowski's avatar Maciej Żenczykowski Committed by David S. Miller

net: allow CAP_NET_RAW to set socket options IP{,V6}_TRANSPARENT

Up till now the IP{,V6}_TRANSPARENT socket options (which actually set
the same bit in the socket struct) have required CAP_NET_ADMIN
privileges to set or clear the option.

- we make clearing the bit not require any privileges.
- we allow CAP_NET_ADMIN to set the bit (as before this change)
- we allow CAP_NET_RAW to set this bit, because raw
  sockets already pretty much effectively allow you
  to emulate socket transparency.
Signed-off-by: default avatarMaciej Żenczykowski <maze@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 05bdd2f1
...@@ -198,7 +198,7 @@ struct cpu_vfs_cap_data { ...@@ -198,7 +198,7 @@ struct cpu_vfs_cap_data {
/* Allow modification of routing tables */ /* Allow modification of routing tables */
/* Allow setting arbitrary process / process group ownership on /* Allow setting arbitrary process / process group ownership on
sockets */ sockets */
/* Allow binding to any address for transparent proxying */ /* Allow binding to any address for transparent proxying (also via NET_RAW) */
/* Allow setting TOS (type of service) */ /* Allow setting TOS (type of service) */
/* Allow setting promiscuous mode */ /* Allow setting promiscuous mode */
/* Allow clearing driver statistics */ /* Allow clearing driver statistics */
...@@ -210,6 +210,7 @@ struct cpu_vfs_cap_data { ...@@ -210,6 +210,7 @@ struct cpu_vfs_cap_data {
/* Allow use of RAW sockets */ /* Allow use of RAW sockets */
/* Allow use of PACKET sockets */ /* Allow use of PACKET sockets */
/* Allow binding to any address for transparent proxying (also via NET_ADMIN) */
#define CAP_NET_RAW 13 #define CAP_NET_RAW 13
......
...@@ -961,7 +961,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -961,7 +961,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
break; break;
case IP_TRANSPARENT: case IP_TRANSPARENT:
if (!capable(CAP_NET_ADMIN)) { if (!!val && !capable(CAP_NET_RAW) && !capable(CAP_NET_ADMIN)) {
err = -EPERM; err = -EPERM;
break; break;
} }
......
...@@ -343,7 +343,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -343,7 +343,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
break; break;
case IPV6_TRANSPARENT: case IPV6_TRANSPARENT:
if (!capable(CAP_NET_ADMIN)) { if (valbool && !capable(CAP_NET_ADMIN) && !capable(CAP_NET_RAW)) {
retv = -EPERM; retv = -EPERM;
break; break;
} }
......
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