From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Brauner Subject: Re: [PATCH v3 2/4] pid: Add PIDFD_IOCTL_GETFD to fetch file descriptors from processes Date: Tue, 17 Dec 2019 04:00:22 +0100 Message-ID: <20191217030021.noeo3clkkz33ucuz@wittgenstein> References: <20191217010001.GA14461@ircssh-2.c.rugged-nimbus-611.internal> <20191217015001.sp6mrhuiqrivkq3u@wittgenstein> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Sargun Dhillon Cc: LKML , Linux Containers , Linux API , linux-fsdevel@vger.kernel.org, Tycho Andersen , Jann Horn , cyphar@cyphar.com, oleg@redhat.com, Andy Lutomirski , viro@zeniv.linux.org.uk, gpascutto@mozilla.com, ealvarez@mozilla.com, fweimer@redhat.com, jld@mozilla.com, Arnd Bergmann List-Id: linux-api@vger.kernel.org On Mon, Dec 16, 2019 at 06:49:37PM -0800, Sargun Dhillon wrote: > On Mon, Dec 16, 2019 at 5:50 PM Christian Brauner > wrote: > > > > [Cc Arnd since he fiddled with ioctl()s quite a bit recently.] > > > > > > That should be pidfd.h and the resulting new file be placed under the > > pidfd entry in maintainers: > > +F: include/uapi/linux/pidfd.h > > > > > > > > enum pid_type > > > { > > > diff --git a/include/uapi/linux/pid.h b/include/uapi/linux/pid.h > > > new file mode 100644 > > > index 000000000000..4ec02ed8b39a > > > --- /dev/null > > > +++ b/include/uapi/linux/pid.h > > > @@ -0,0 +1,26 @@ > > > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > > > +#ifndef _UAPI_LINUX_PID_H > > > +#define _UAPI_LINUX_PID_H > > > + > > > +#include > > > +#include > > > + > > > +/* options to pass in to pidfd_getfd_args flags */ > > > +#define PIDFD_GETFD_CLOEXEC (1 << 0) /* open the fd with cloexec */ > > > > Please, make them cloexec by default unless there's a very good reason > > not to. > > > For now then, should I have flags, and just say "reserved for future usage", > or would you prefer that I drop flags entirely? Hm, you can leave the flags argument imho but maybe someone else has stronger opinions about this. > > > > + > > > +struct pidfd_getfd_args { > > > + __u32 size; /* sizeof(pidfd_getfd_args) */ > > > + __u32 fd; /* the tracee's file descriptor to get */ > > > + __u32 flags; > > > +}; > > > > I think you want to either want to pad this > > > > +struct pidfd_getfd_args { > > + __u32 size; /* sizeof(pidfd_getfd_args) */ > > + __u32 fd; /* the tracee's file descriptor to get */ > > + __u32 flags; > > __u32 reserved; > > +}; > > > > or use __aligned_u64 everywhere which I'd personally prefer instead of > > this manual padding everywhere. > > > Wouldn't __attribute__((packed)) achieve a similar thing of making sure > the struct is a constant size across all compilers? > > I'll go with __aligned_u64 instead of packed, if you don't want to use packed. We had a discussion about this in relation to the openat2() patchset just recently. Florian and a few others raised good points why we might not want to use packed: https://lore.kernel.org/lkml/87o8w9bcaf.fsf@mid.deneb.enyo.de/ https://lore.kernel.org/lkml/a328b91d-fd8f-4f27-b3c2-91a9c45f18c0@rasmusvillemoes.dk/ Christian