Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-14 Thread Eric W. Biederman
Vivek Goyal writes: > On Wed, Mar 12, 2014 at 07:12:25PM -0700, Andy Lutomirski wrote: > >> I can think of at least three other ways to do this. >> >> 1. Fix Docker to use user namespaces and use the uid of the requesting >> process via SCM_CREDENTIALS. > > Using user namespaces sounds like the

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-14 Thread Eric W. Biederman
Vivek Goyal writes: > On Thu, Mar 13, 2014 at 12:58:14PM -0700, Andy Lutomirski wrote: >> On Thu, Mar 13, 2014 at 12:53 PM, Vivek Goyal wrote: >> > On Thu, Mar 13, 2014 at 10:55:16AM -0700, Andy Lutomirski wrote: >> > >> > [..] >> >> >> 2. Docker is a container system, so use the "container" (ak

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Andy Lutomirski
On Thu, Mar 13, 2014 at 1:06 PM, Vivek Goyal wrote: > On Thu, Mar 13, 2014 at 12:58:14PM -0700, Andy Lutomirski wrote: >> On Thu, Mar 13, 2014 at 12:53 PM, Vivek Goyal wrote: >> > On Thu, Mar 13, 2014 at 10:55:16AM -0700, Andy Lutomirski wrote: >> > >> > [..] >> >> >> 2. Docker is a container sys

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Vivek Goyal
On Thu, Mar 13, 2014 at 04:17:55PM -0400, Vivek Goyal wrote: > On Thu, Mar 13, 2014 at 04:06:49PM -0400, Vivek Goyal wrote: > > On Thu, Mar 13, 2014 at 12:58:14PM -0700, Andy Lutomirski wrote: > > > On Thu, Mar 13, 2014 at 12:53 PM, Vivek Goyal wrote: > > > > On Thu, Mar 13, 2014 at 10:55:16AM -07

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Vivek Goyal
On Thu, Mar 13, 2014 at 04:06:49PM -0400, Vivek Goyal wrote: > On Thu, Mar 13, 2014 at 12:58:14PM -0700, Andy Lutomirski wrote: > > On Thu, Mar 13, 2014 at 12:53 PM, Vivek Goyal wrote: > > > On Thu, Mar 13, 2014 at 10:55:16AM -0700, Andy Lutomirski wrote: > > > > > > [..] > > >> >> 2. Docker is a

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Vivek Goyal
On Thu, Mar 13, 2014 at 12:58:14PM -0700, Andy Lutomirski wrote: > On Thu, Mar 13, 2014 at 12:53 PM, Vivek Goyal wrote: > > On Thu, Mar 13, 2014 at 10:55:16AM -0700, Andy Lutomirski wrote: > > > > [..] > >> >> 2. Docker is a container system, so use the "container" (aka > >> >> namespace) APIs. T

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Andy Lutomirski
On Thu, Mar 13, 2014 at 12:53 PM, Vivek Goyal wrote: > On Thu, Mar 13, 2014 at 10:55:16AM -0700, Andy Lutomirski wrote: > > [..] >> >> 2. Docker is a container system, so use the "container" (aka >> >> namespace) APIs. There are probably several clever things that could >> >> be done with /proc//

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Vivek Goyal
On Thu, Mar 13, 2014 at 10:55:16AM -0700, Andy Lutomirski wrote: [..] > >> 2. Docker is a container system, so use the "container" (aka > >> namespace) APIs. There are probably several clever things that could > >> be done with /proc//ns. > > > > pid is racy, if it weren't I would simply go strai

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Tim Hockin
I don't buy that it is not practical. Not convenient, maybe. Not clean, sure. But it is practical - it uses mechanisms that exist on all kernels today. That is a win, to me. On Thu, Mar 13, 2014 at 10:58 AM, Simo Sorce wrote: > On Thu, 2014-03-13 at 10:55 -0700, Andy Lutomirski wrote: >> >> S

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Andy Lutomirski
On Thu, Mar 13, 2014 at 10:57 AM, Simo Sorce wrote: > On Thu, 2014-03-13 at 10:55 -0700, Andy Lutomirski wrote: >> On Thu, Mar 13, 2014 at 10:51 AM, Simo Sorce wrote: >> > On Wed, 2014-03-12 at 19:12 -0700, Andy Lutomirski wrote: >> >> On Wed, Mar 12, 2014 at 6:43 PM, Simo Sorce wrote: >> >> > O

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Vivek Goyal
On Thu, Mar 13, 2014 at 01:51:17PM -0400, Simo Sorce wrote: [..] > > 1. Fix Docker to use user namespaces and use the uid of the requesting > > process via SCM_CREDENTIALS. > > This is not practical, I have no control on what UIDs will be used > within a container, I guess uid to container mappi

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Andy Lutomirski
On Thu, Mar 13, 2014 at 10:58 AM, Simo Sorce wrote: > On Thu, 2014-03-13 at 10:55 -0700, Andy Lutomirski wrote: >> >> So give each container its own unix socket. Problem solved, no? > > Not really practical if you have hundreds of containers. I don't see the problem. Sockets are cheap. > > Sim

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Simo Sorce
On Thu, 2014-03-13 at 10:55 -0700, Andy Lutomirski wrote: > > So give each container its own unix socket. Problem solved, no? Not really practical if you have hundreds of containers. Simo. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to ma

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Simo Sorce
On Thu, 2014-03-13 at 10:55 -0700, Andy Lutomirski wrote: > On Thu, Mar 13, 2014 at 10:51 AM, Simo Sorce wrote: > > On Wed, 2014-03-12 at 19:12 -0700, Andy Lutomirski wrote: > >> On Wed, Mar 12, 2014 at 6:43 PM, Simo Sorce wrote: > >> > On Wed, 2014-03-12 at 18:21 -0700, Andy Lutomirski wrote: >

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Simo Sorce
On Thu, 2014-03-13 at 10:25 -0700, Andy Lutomirski wrote: > On Thu, Mar 13, 2014 at 9:33 AM, Simo Sorce wrote: > > On Thu, 2014-03-13 at 11:00 -0400, Vivek Goyal wrote: > >> On Thu, Mar 13, 2014 at 10:55:34AM -0400, Simo Sorce wrote: > >> > >> [..] > >> > > > This might not be quite as awful as I

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Tim Hockin
In some sense a cgroup is a pgrp that mere mortals can't escape. Why not just do something like that? root can set this "container id" or "job id" on your process when it first starts (e.g. docker sets it on your container process) or even make a cgroup that sets this for all processes in that cg

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Andy Lutomirski
On Thu, Mar 13, 2014 at 10:51 AM, Simo Sorce wrote: > On Wed, 2014-03-12 at 19:12 -0700, Andy Lutomirski wrote: >> On Wed, Mar 12, 2014 at 6:43 PM, Simo Sorce wrote: >> > On Wed, 2014-03-12 at 18:21 -0700, Andy Lutomirski wrote: >> >> On Wed, Mar 12, 2014 at 6:17 PM, Simo Sorce wrote: >> >> > On

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Simo Sorce
On Wed, 2014-03-12 at 19:12 -0700, Andy Lutomirski wrote: > On Wed, Mar 12, 2014 at 6:43 PM, Simo Sorce wrote: > > On Wed, 2014-03-12 at 18:21 -0700, Andy Lutomirski wrote: > >> On Wed, Mar 12, 2014 at 6:17 PM, Simo Sorce wrote: > >> > On Wed, 2014-03-12 at 14:19 -0700, Andy Lutomirski wrote: > >

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Andy Lutomirski
On Thu, Mar 13, 2014 at 9:33 AM, Simo Sorce wrote: > On Thu, 2014-03-13 at 11:00 -0400, Vivek Goyal wrote: >> On Thu, Mar 13, 2014 at 10:55:34AM -0400, Simo Sorce wrote: >> >> [..] >> > > > This might not be quite as awful as I thought. At least you're >> > > > looking up the cgroup at connection

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Simo Sorce
On Thu, 2014-03-13 at 11:00 -0400, Vivek Goyal wrote: > On Thu, Mar 13, 2014 at 10:55:34AM -0400, Simo Sorce wrote: > > [..] > > > > This might not be quite as awful as I thought. At least you're > > > > looking up the cgroup at connection time instead of at send time. > > > > > > > > OTOH, this

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Vivek Goyal
On Thu, Mar 13, 2014 at 10:55:34AM -0400, Simo Sorce wrote: [..] > > > This might not be quite as awful as I thought. At least you're > > > looking up the cgroup at connection time instead of at send time. > > > > > > OTOH, this is still racy -- the socket could easily outlive the cgroup > > > t

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Simo Sorce
On Thu, 2014-03-13 at 10:14 -0400, Vivek Goyal wrote: > On Wed, Mar 12, 2014 at 02:12:33PM -0700, Andy Lutomirski wrote: > > On Wed, Mar 12, 2014 at 2:00 PM, Andy Lutomirski > > wrote: > > > On 03/12/2014 01:46 PM, Vivek Goyal wrote: > > >> Implement SO_PEERCGROUP along the lines of SO_PEERCRED.

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Vivek Goyal
On Wed, Mar 12, 2014 at 07:12:25PM -0700, Andy Lutomirski wrote: [..] > >> Can you give a realistic example? > >> > >> I could say that I'd like to disclose information to processes based > >> on their rlimits at the time they connected, but I don't think that > >> would carry much weight. > > > >

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Vivek Goyal
On Wed, Mar 12, 2014 at 02:12:33PM -0700, Andy Lutomirski wrote: > On Wed, Mar 12, 2014 at 2:00 PM, Andy Lutomirski wrote: > > On 03/12/2014 01:46 PM, Vivek Goyal wrote: > >> Implement SO_PEERCGROUP along the lines of SO_PEERCRED. This returns the > >> cgroup of first mounted hierarchy of the task

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-13 Thread Vivek Goyal
On Wed, Mar 12, 2014 at 01:58:57PM -0700, Cong Wang wrote: > On Wed, Mar 12, 2014 at 1:46 PM, Vivek Goyal wrote: > > @@ -1098,6 +1135,16 @@ static int unix_stream_connect(struct socket *sock, > > struct sockaddr *uaddr, > > if (newsk == NULL) > > goto out; > > > > +

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-12 Thread Andy Lutomirski
On Wed, Mar 12, 2014 at 6:43 PM, Simo Sorce wrote: > On Wed, 2014-03-12 at 18:21 -0700, Andy Lutomirski wrote: >> On Wed, Mar 12, 2014 at 6:17 PM, Simo Sorce wrote: >> > On Wed, 2014-03-12 at 14:19 -0700, Andy Lutomirski wrote: >> >> On Wed, Mar 12, 2014 at 2:16 PM, Simo Sorce wrote: >> >> >> >>

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-12 Thread Simo Sorce
On Wed, 2014-03-12 at 18:21 -0700, Andy Lutomirski wrote: > On Wed, Mar 12, 2014 at 6:17 PM, Simo Sorce wrote: > > On Wed, 2014-03-12 at 14:19 -0700, Andy Lutomirski wrote: > >> On Wed, Mar 12, 2014 at 2:16 PM, Simo Sorce wrote: > >> > >> > > >> > Connection time is all we do and can care about.

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-12 Thread Andy Lutomirski
On Wed, Mar 12, 2014 at 6:17 PM, Simo Sorce wrote: > On Wed, 2014-03-12 at 14:19 -0700, Andy Lutomirski wrote: >> On Wed, Mar 12, 2014 at 2:16 PM, Simo Sorce wrote: >> >> > >> > Connection time is all we do and can care about. >> >> You have not answered why. > > We are going to disclose informat

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-12 Thread Simo Sorce
On Wed, 2014-03-12 at 14:19 -0700, Andy Lutomirski wrote: > On Wed, Mar 12, 2014 at 2:16 PM, Simo Sorce wrote: > > On Wed, 2014-03-12 at 14:12 -0700, Andy Lutomirski wrote: > >> On Wed, Mar 12, 2014 at 2:00 PM, Andy Lutomirski > >> wrote: > >> > On 03/12/2014 01:46 PM, Vivek Goyal wrote: > >> >>

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-12 Thread Andy Lutomirski
On Wed, Mar 12, 2014 at 2:16 PM, Simo Sorce wrote: > On Wed, 2014-03-12 at 14:12 -0700, Andy Lutomirski wrote: >> On Wed, Mar 12, 2014 at 2:00 PM, Andy Lutomirski wrote: >> > On 03/12/2014 01:46 PM, Vivek Goyal wrote: >> >> Implement SO_PEERCGROUP along the lines of SO_PEERCRED. This returns the

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-12 Thread Simo Sorce
On Wed, 2014-03-12 at 14:12 -0700, Andy Lutomirski wrote: > On Wed, Mar 12, 2014 at 2:00 PM, Andy Lutomirski wrote: > > On 03/12/2014 01:46 PM, Vivek Goyal wrote: > >> Implement SO_PEERCGROUP along the lines of SO_PEERCRED. This returns the > >> cgroup of first mounted hierarchy of the task. For t

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-12 Thread Andy Lutomirski
On Wed, Mar 12, 2014 at 2:00 PM, Andy Lutomirski wrote: > On 03/12/2014 01:46 PM, Vivek Goyal wrote: >> Implement SO_PEERCGROUP along the lines of SO_PEERCRED. This returns the >> cgroup of first mounted hierarchy of the task. For the case of client, >> it represents the cgroup of client at the ti

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-12 Thread Andy Lutomirski
On 03/12/2014 01:46 PM, Vivek Goyal wrote: > Implement SO_PEERCGROUP along the lines of SO_PEERCRED. This returns the > cgroup of first mounted hierarchy of the task. For the case of client, > it represents the cgroup of client at the time of opening the connection. > After that client cgroup might

Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

2014-03-12 Thread Cong Wang
On Wed, Mar 12, 2014 at 1:46 PM, Vivek Goyal wrote: > @@ -1098,6 +1135,16 @@ static int unix_stream_connect(struct socket *sock, > struct sockaddr *uaddr, > if (newsk == NULL) > goto out; > > + err = init_peercgroup(newsk); > + if (err) > + goto o