Re: [PATCH 1/2] pid: add pidfd_open()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Christian Brauner <christian@xxxxxxxxxx>
- Subject: Re: [PATCH 1/2] pid: add pidfd_open()
- From: Oleg Nesterov <oleg@xxxxxxxxxx>
- Date: Wed, 15 May 2019 17:35:15 +0200
- Cc: jannh@xxxxxxxxxx, viro@xxxxxxxxxxxxxxxxxx, torvalds@xxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, arnd@xxxxxxxx, dhowells@xxxxxxxxxx, akpm@xxxxxxxxxxxxxxxxxxxx, cyphar@xxxxxxxxxx, ebiederm@xxxxxxxxxxxx, elena.reshetova@xxxxxxxxx, keescook@xxxxxxxxxxxx, luto@xxxxxxxxxxxxxx, luto@xxxxxxxxxx, tglx@xxxxxxxxxxxxx, linux-alpha@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-ia64@xxxxxxxxxxxxxxx, linux-m68k@xxxxxxxxxxxxxxx, linux-mips@xxxxxxxxxxxxxxx, linux-parisc@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, linux-sh@xxxxxxxxxxxxxxx, sparclinux@xxxxxxxxxxxxxxx, linux-xtensa@xxxxxxxxxxxxxxxx, linux-api@xxxxxxxxxxxxxxx, linux-arch@xxxxxxxxxxxxxxx, linux-kselftest@xxxxxxxxxxxxxxx
- In-reply-to: <20190515143857.GB18892@redhat.com>
- References: <20190515100400.3450-1-christian@brauner.io> <20190515143857.GB18892@redhat.com>
- User-agent: Mutt/1.5.24 (2015-08-30)
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 (pid <= 0)
> > + return -EINVAL;
> > +
> > + p = find_get_pid(pid);
> > + if (!p)
> > + return -ESRCH;
> > +
> > + rcu_read_lock();
> > + tsk = pid_task(p, PIDTYPE_PID);
>
> You do not need find_get_pid() before rcu_lock and put_pid() at the end.
> You can just do find_vpid() under rcu_read_lock().
Ah, sorry. Somehow I forgot you need to call pidfd_create(pid), you can't
do this under rcu_read_lock().
So I was wrong, you can't avoid get/put_pid.
Oleg.
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]