lkml.org 
[lkml]   [2019]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH 2/4] pid: add pidfd_open()
    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)

    (and match the check done for flag == 0).

    Regards.

    --
    Yann Droneaud
    OPTEYA


    \
     
     \ /
      Last update: 2019-03-27 18:46    [W:5.399 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site