diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-11-15 22:03:12 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-18 20:33:37 -0500 |
commit | 3594698a1fb8e5ae60a92c72ce9ca280256939a7 (patch) | |
tree | 54360b8a85136ebfeb10f76cfa207a23fb6035e9 /net/ipv4 | |
parent | b51642f6d77b131dc85d1d71029c3cbb5b07c262 (diff) |
net: Make CAP_NET_BIND_SERVICE per user namespace
Allow privileged users in any user namespace to bind to
privileged sockets in network namespaces they control.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/af_inet.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 4f5f22061e1c..24b384b7903e 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -474,6 +474,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
474 | struct sockaddr_in *addr = (struct sockaddr_in *)uaddr; | 474 | struct sockaddr_in *addr = (struct sockaddr_in *)uaddr; |
475 | struct sock *sk = sock->sk; | 475 | struct sock *sk = sock->sk; |
476 | struct inet_sock *inet = inet_sk(sk); | 476 | struct inet_sock *inet = inet_sk(sk); |
477 | struct net *net = sock_net(sk); | ||
477 | unsigned short snum; | 478 | unsigned short snum; |
478 | int chk_addr_ret; | 479 | int chk_addr_ret; |
479 | int err; | 480 | int err; |
@@ -497,7 +498,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
497 | goto out; | 498 | goto out; |
498 | } | 499 | } |
499 | 500 | ||
500 | chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); | 501 | chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr); |
501 | 502 | ||
502 | /* Not specified by any standard per-se, however it breaks too | 503 | /* Not specified by any standard per-se, however it breaks too |
503 | * many applications when removed. It is unfortunate since | 504 | * many applications when removed. It is unfortunate since |
@@ -517,7 +518,8 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
517 | 518 | ||
518 | snum = ntohs(addr->sin_port); | 519 | snum = ntohs(addr->sin_port); |
519 | err = -EACCES; | 520 | err = -EACCES; |
520 | if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) | 521 | if (snum && snum < PROT_SOCK && |
522 | !ns_capable(net->user_ns, CAP_NET_BIND_SERVICE)) | ||
521 | goto out; | 523 | goto out; |
522 | 524 | ||
523 | /* We keep a pair of addresses. rcv_saddr is the one | 525 | /* We keep a pair of addresses. rcv_saddr is the one |