Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-16 Thread Aleksa Sarai
On 2019-05-16, Christian Brauner wrote: > On Wed, May 15, 2019 at 10:45:06AM -0700, Daniel Colascione wrote: > > On Wed, May 15, 2019 at 3:04 AM Christian Brauner > > wrote: > > > + if (pid <= 0) > > > + return -EINVAL; > > > > WDYT of defining pid == 0 to mean "open myself"

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-16 Thread Christian Brauner
On Thu, May 16, 2019 at 04:03:27PM +0200, Jann Horn wrote: > On Thu, May 16, 2019 at 3:08 PM Christian Brauner > wrote: > > On Wed, May 15, 2019 at 10:45:06AM -0700, Daniel Colascione wrote: > > > On Wed, May 15, 2019 at 3:04 AM Christian Brauner > > > wrote: > > > > > > > > This adds the pidfd

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-16 Thread Christian Brauner
On Wed, May 15, 2019 at 10:45:06AM -0700, Daniel Colascione wrote: > On Wed, May 15, 2019 at 3:04 AM Christian Brauner > wrote: > > > > This adds the pidfd_open() syscall. It allows a caller to retrieve pollable > > pidfds for a process which did not get created via CLONE_PIDFD, i.e. for a > > pr

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Aleksa Sarai
On 2019-05-15, Christian Brauner wrote: > On Wed, May 15, 2019 at 04:00:20PM +0200, Yann Droneaud wrote: > > Would it be possible to create file descriptor with "restricted" > > operation ? > > > > - O_RDONLY: waiting for process completion allowed (for example) > > - O_WRONLY: sending process si

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Yann Droneaud
Hi, Le mercredi 15 mai 2019 à 12:03 +0200, Christian Brauner a écrit : > > diff --git a/kernel/pid.c b/kernel/pid.c > index 20881598bdfa..237d18d6ecb8 100644 > --- a/kernel/pid.c > +++ b/kernel/pid.c > @@ -451,6 +452,53 @@ struct pid *find_ge_pid(int nr, struct > pid_namespace *ns) > return

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Yann Droneaud
Hi, Le mercredi 15 mai 2019 à 16:16 +0200, Christian Brauner a écrit : > On Wed, May 15, 2019 at 04:00:20PM +0200, Yann Droneaud wrote: > > Le mercredi 15 mai 2019 à 12:03 +0200, Christian Brauner a écrit : > > > diff --git a/kernel/pid.c b/kernel/pid.c > > > index 20881598bdfa..237d18d6ecb8 10064

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Christian Brauner
On Wed, May 15, 2019 at 05:35:15PM +0200, Oleg Nesterov wrote: > On 05/15, Oleg Nesterov wrote: > > > > On 05/15, Christian Brauner wrote: > > > > > > +SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags) > > > +{ > > > + int fd, ret; > > > + struct pid *p; > > > + struct task_struct *tsk;

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Oleg Nesterov
On 05/15, Oleg Nesterov wrote: > > On 05/15, Christian Brauner wrote: > > > > +SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags) > > +{ > > + int fd, ret; > > + struct pid *p; > > + struct task_struct *tsk; > > + > > + if (flags) > > + return -EINVAL; > > + > > + if (

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Christian Brauner
On Wed, May 15, 2019 at 05:19:13PM +0200, Oleg Nesterov wrote: > On 05/15, Christian Brauner wrote: > > > > On Wed, May 15, 2019 at 04:38:58PM +0200, Oleg Nesterov wrote: > > > > > > it seems that you can do a single check > > > > > > tsk = pid_task(p, PIDTYPE_TGID); > > > if (!tsk) > > >

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Oleg Nesterov
On 05/15, Christian Brauner wrote: > > On Wed, May 15, 2019 at 04:38:58PM +0200, Oleg Nesterov wrote: > > > > it seems that you can do a single check > > > > tsk = pid_task(p, PIDTYPE_TGID); > > if (!tsk) > > ret = -ESRCH; > > > > this even looks more correct if we race with exe

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Christian Brauner
On Wed, May 15, 2019 at 04:38:58PM +0200, Oleg Nesterov wrote: > On 05/15, Christian Brauner wrote: > > > > +SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags) > > +{ > > + int fd, ret; > > + struct pid *p; > > + struct task_struct *tsk; > > + > > + if (flags) > > + retu

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Oleg Nesterov
On 05/15, Christian Brauner wrote: > > +SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags) > +{ > + int fd, ret; > + struct pid *p; > + struct task_struct *tsk; > + > + if (flags) > + return -EINVAL; > + > + if (pid <= 0) > + return -EINVAL; > +

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Christian Brauner
On Wed, May 15, 2019 at 04:00:20PM +0200, Yann Droneaud wrote: > Hi, > > Le mercredi 15 mai 2019 à 12:03 +0200, Christian Brauner a écrit : > > > > diff --git a/kernel/pid.c b/kernel/pid.c > > index 20881598bdfa..237d18d6ecb8 100644 > > --- a/kernel/pid.c > > +++ b/kernel/pid.c > > @@ -451,6 +452

Re: [PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Geert Uytterhoeven
On Wed, May 15, 2019 at 12:04 PM Christian Brauner wrote: > This adds the pidfd_open() syscall. It allows a caller to retrieve pollable > pidfds for a process which did not get created via CLONE_PIDFD, i.e. for a > process that is created via traditional fork()/clone() calls that is only > referen

[PATCH 1/2] pid: add pidfd_open()

2019-05-15 Thread Christian Brauner
This adds the pidfd_open() syscall. It allows a caller to retrieve pollable pidfds for a process which did not get created via CLONE_PIDFD, i.e. for a process that is created via traditional fork()/clone() calls that is only referenced by a PID: int pidfd = pidfd_open(1234, 0); ret = pidfd_send_si