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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 27, 2019 at 06:21:24PM +0100, Yann Droneaud wrote:
> Le mercredi 27 mars 2019 à 17:21 +0100, Christian Brauner a écrit :
> 
> > diff --git a/kernel/pid.c b/kernel/pid.c
> > index 20881598bdfa..c9e24e726aba 100644
> > --- a/kernel/pid.c
> > +++ b/kernel/pid.c
> > @@ -26,8 +26,10 @@
> > +SYSCALL_DEFINE4(pidfd_open, pid_t, pid, int, procfd, int, pidfd,
> > unsigned int,
> > +		flags)
> > +{
> > +	long fd = -EINVAL;
> > +
> > +	if (flags & ~(PIDFD_TO_PROCFD | PROCFD_TO_PIDFD))
> > +		return -EINVAL;
> > +
> > +	if (!flags) {
> > +		struct pid *pidfd_pid;
> > +
> > +		if (pid <= 0)
> > +			return -EINVAL;
> > +
> > +		if (procfd != -1 || pidfd != -1)
> > +			return -EINVAL;
> > +
> > +		rcu_read_lock();
> > +		pidfd_pid = get_pid(find_pid_ns(pid, task_active_pid_ns(current)));
> > +		rcu_read_unlock();
> > +
> > +		fd = pidfd_create_fd(pidfd_pid, O_CLOEXEC);
> > +		put_pid(pidfd_pid);
> > +	} else if (flags & PIDFD_TO_PROCFD) {
> 
> [...]
> 
> > +	} else if (flags & PROCFD_TO_PIDFD) {
> > +		if (flags & ~PROCFD_TO_PIDFD)
> > +			return -EINVAL;
> > +
> > +		if (pid != -1)
> > +			return -EINVAL;
> > +
> > +		if (pidfd >= 0)
> > 
> 
> I think it can be stricter with:
> 
>                 if (pidfd != -1)

Yes.

> 
> (and match the check done for flag == 0).
> 
> Regards.
> 
> -- 
> Yann Droneaud
> OPTEYA
> 
> 



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux