From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [RFC][v5][PATCH 8/8]: Define clone_with_pids() syscall Date: Wed, 9 Sep 2009 14:19:50 +0200 Message-ID: <200909091419.50496.arnd@arndb.de> References: <20090907211302.GA5892@us.ibm.com> <20090907211700.GH6685@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Nathan Lynch Cc: Containers , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Eric W. Biederman" , hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org, mingo-X9Un+BFzKDI@public.gmane.org, Sukadev Bhattiprolu , torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, Alexey Dobriyan , Pavel Emelyanov List-Id: containers.vger.kernel.org On Tuesday 08 September 2009, Nathan Lynch wrote: > This doesn't work on a 64-bit kernel when the process is 32-bit and uses > the definition of struct pid_set provided in types.h: > > +struct pid_set { > + int num_pids; > + pid_t *pids; > +}; > > Shouldn't the pids field be u64 or some other type of fixed size? This is a complex problem. The structure above would need a conversion for the pointer size that you can avoid by using a u64, but that introduces another problem: struct pid_set { int num_pids; u64 pidp; }; Has implicit padding between the two members on all 64 bit architectures, but not on i386, so you would still need a conversion (not for s390, power, mips, sparc or parisc though, only for x86). I can see two solutions for this: 1. use separate system call arguments for num_pids and pidp. This avoids the data structure and saves one copy_from_user call, at the cost of adding another argument to the syscall. syscalls with more than 6 arguments are somewhat problematic as well. 2. use a single pointer, with variable length data structures: struct pid_set { int num_pids; pid_t pids[0]; }; Since pid_t is always an int, you have no problem with padding or incompatible types, but rely on a data structure definition that is not in C89 (not sure about C99). Arnd <><