[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMp4zn9ivYPP1Sfu48EX897M4JAVXvK+NQB4NZ5=XPM_saJu+g@mail.gmail.com>
Date: Fri, 20 Dec 2019 17:45:34 -0800
From: Sargun Dhillon <sargun@...gun.me>
To: Aleksa Sarai <asarai@...e.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
Linux Containers <containers@...ts.linux-foundation.org>,
Linux API <linux-api@...r.kernel.org>,
Linux FS-devel Mailing List <linux-fsdevel@...r.kernel.org>,
Emilio Cobos Álvarez <ealvarez@...illa.com>,
Arnd Bergmann <arnd@...db.de>, Jann Horn <jannh@...gle.com>,
Gian-Carlo Pascutto <gpascutto@...illa.com>,
Jed Davis <jld@...illa.com>, Oleg Nesterov <oleg@...hat.com>,
Andy Lutomirski <luto@...capital.net>,
Al Viro <viro@...iv.linux.org.uk>,
Christian Brauner <christian.brauner@...ntu.com>
Subject: Re: [PATCH v5 2/3] pid: Introduce pidfd_getfd syscall
On Fri, Dec 20, 2019 at 4:27 PM Aleksa Sarai <asarai@...e.de> wrote:
>
> On 2019-12-20, Sargun Dhillon <sargun@...gun.me> wrote:
> > diff --git a/include/uapi/linux/pidfd.h b/include/uapi/linux/pidfd.h
> > new file mode 100644
> > index 000000000000..0a3fc922661d
> > --- /dev/null
> > +++ b/include/uapi/linux/pidfd.h
> > @@ -0,0 +1,10 @@
> > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> > +#ifndef _UAPI_LINUX_PIDFD_H
> > +#define _UAPI_LINUX_PIDFD_H
> > +
> > +struct pidfd_getfd_options {};
>
> Are empty structs well-defined in C (from memory, some compilers make
> them non-zero in size)? Since we probably plan to add a flags field in
> the future anyway, why not just have a __u64 flags which must be zeroed?
>
It's allowed in GCC:
https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Empty-Structures.html
I can add an __aligned_u64 flags for now, and just say something like
"reserved". This will also solve the latter issue, and I'll just use
copy_struct_from_user,
as long as Christian is okay with having an unused (reserved) flag member.
> > + f = fdget(pidfd);
> > + if (!f.file)
> > + return -EBADF;
> > +
> > + pid = pidfd_pid(f.file);
> > + if (IS_ERR(pid)) {
> > + ret = PTR_ERR(pid);
> > + goto out;
> > + }
> > +
> > + ret = pidfd_getfd(pid, fd);
> > +
> > +out:
> > + fdput(f);
> > + return ret;
> > +}
> > --
> > 2.20.1
>
> --
> Aleksa Sarai
> Senior Software Engineer (Containers)
> SUSE Linux GmbH
> <https://www.cyphar.com/>
Powered by blists - more mailing lists