From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752807AbbDFIa2 (ORCPT ); Mon, 6 Apr 2015 04:30:28 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35366 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751948AbbDFIaZ (ORCPT ); Mon, 6 Apr 2015 04:30:25 -0400 Date: Mon, 6 Apr 2015 17:30:35 +0900 From: Sergey Senozhatsky To: Josh Triplett Cc: Al Viro , Andrew Morton , Andy Lutomirski , Ingo Molnar , Kees Cook , Oleg Nesterov , "Paul E. McKenney" , "H. Peter Anvin" , Rik van Riel , Thomas Gleixner , Michael Kerrisk , Thiago Macieira , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v2 7/7] clone4: Add a CLONE_FD flag to get task exit notification via fd Message-ID: <20150406083035.GA16373@swordfish> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (03/15/15 01:00), Josh Triplett wrote: [..] > + > +/* Handle the CLONE_FD case for copy_process. */ > +int clonefd_do_clone(u64 clone_flags, struct task_struct *p, > + struct clone4_args *args, struct clonefd_setup *setup) > +{ > + int flags; > + struct file *file; > + int fd; > + > + p->clonefd = !!(clone_flags & CLONE_FD); > + if (!p->clonefd) > + return 0; > + > + if (args->clonefd_flags & ~(O_CLOEXEC | O_NONBLOCK)) > + return -EINVAL; > + > + init_waitqueue_head(&p->clonefd_wqh); > + > + get_task_struct(p); > + flags = O_RDONLY | FMODE_ATOMIC_POS | args->clonefd_flags; > + file = anon_inode_getfile("[process]", &clonefd_fops, p, flags); > + if (IS_ERR(file)) { > + put_task_struct(p); > + return PTR_ERR(file); > + } > + > + fd = get_unused_fd_flags(flags); > + if (fd < 0) { + put_task_struct(p); ? > + fput(file); > + return fd; > + } > + > + setup->fd = fd; > + setup->file = file; > + return 0; > +} [..] -ss