From owner-svn-src-all@freebsd.org Tue Mar 8 15:52:39 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E96F8AC3E91; Tue, 8 Mar 2016 15:52:38 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 91B158B9; Tue, 8 Mar 2016 15:52:38 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm0-x234.google.com with SMTP id l68so33530945wml.1; Tue, 08 Mar 2016 07:52:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=TqWCDsREgrqHUDCZdqjWpgTJ4sfhlngQjzn4O3/ylk8=; b=dmbAWF+NrcVr0dEWjFIWdE2hzAAH7Dbeo01KXxnd08+VMbbG8ylH+6ac9zdhNMQzSj JxifvNCBHP740+HlBT3uhdGBUzwTWpde5R/xH25pg5aYWA4HKSM9+CyUr0ZOpHpE/jTa xAB1U66gDhZQ62BRQ7Pa0NINMd5QeL+PaLMvKBh7A7Tryl3CWzuW5AtpFccusfUbVleW rJz8Mt+RcYTwCJxmgpGh/FVFt205SmB74dC5QfCAhc6H2fFAfubpnWdNE6oixRbHP5pV kleWZBWjTRo0VxG/nmAEaBR9T56T8oIvY0VFm4UX9kqdIUcpXM9gf/OESr82Ra6IwUfW LTqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=TqWCDsREgrqHUDCZdqjWpgTJ4sfhlngQjzn4O3/ylk8=; b=Cw/fecBlNn9cFRBsHUrpIVA3j8XmQty3Yal3B+RDia20QOKxkCoBlkSTC3CEkpqUTI l+BHQX6gb1rfzwkk5GktKKlQfBIOH4PpTPRsGscAJhCeGktrYa199xvEKSu5r13C033r CfeCo3ziaUT6WQWPOyB2NDiR+OJu5xHZ2527uObLFqLhcQ6IVwBtsjH9VijxEgmVbNg0 lyz1p/DJwqEpolVmor3OvGqwRM9FeUHPfWjMQJnv8DVgx/cXviiM2+my5xLqe+dKkXGq p1RlO4VYBFddPC2oEptqkGjUcrVjeHPpvJuDvjoL2eJ2EUZ19hPbe6fl/id2iyUCs4rh V0ig== X-Gm-Message-State: AD7BkJLfPjQ3JBb/vhQmFHp4OdaFlqxReYeoWvoNnIbUclL5LkqJkNpqxqiLlv8oMupRqg== X-Received: by 10.28.5.203 with SMTP id 194mr21340282wmf.101.1457452356819; Tue, 08 Mar 2016 07:52:36 -0800 (PST) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by smtp.gmail.com with ESMTPSA id js8sm3560324wjc.37.2016.03.08.07.52.35 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 08 Mar 2016 07:52:35 -0800 (PST) Date: Tue, 8 Mar 2016 16:52:33 +0100 From: Mateusz Guzik To: Dmitry Chagin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r296501 - head/sys/compat/linux Message-ID: <20160308155233.GA7447@dft-labs.eu> References: <201603081508.u28F8Mtq005783@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201603081508.u28F8Mtq005783@repo.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Mar 2016 15:52:39 -0000 On Tue, Mar 08, 2016 at 03:08:22PM +0000, Dmitry Chagin wrote: > Author: dchagin > Date: Tue Mar 8 15:08:22 2016 > New Revision: 296501 > URL: https://svnweb.freebsd.org/changeset/base/296501 > > Log: > Link the newly created process to the corresponding parent as > if CLONE_PARENT is set, then the parent of the new process will > be the same as that of the calling process. > > MFC after: 1 week > > Modified: > head/sys/compat/linux/linux_fork.c > > Modified: head/sys/compat/linux/linux_fork.c > ============================================================================== > --- head/sys/compat/linux/linux_fork.c Tue Mar 8 14:55:50 2016 (r296500) > +++ head/sys/compat/linux/linux_fork.c Tue Mar 8 15:08:22 2016 (r296501) > @@ -222,6 +222,18 @@ linux_clone_proc(struct thread *td, stru > if (args->flags & LINUX_CLONE_SETTLS) > linux_set_cloned_tls(td2, args->tls); > > + /* > + * If CLONE_PARENT is set, then the parent of the new process will be > + * the same as that of the calling process. > + */ > + if (args->flags & LINUX_CLONE_PARENT) { > + sx_xlock(&proctree_lock); > + PROC_LOCK(p2); > + proc_reparent(p2, td->td_proc->p_pptr); > + PROC_UNLOCK(p2); > + sx_xunlock(&proctree_lock); > + } > + > #ifdef DEBUG > if (ldebug(clone)) > printf(LMSG("clone: successful rfork to %d, " > What is the reason to support this flag? It is questionable at best since it gives surprise children to unsuspecting processes. The patch looks wrong. By the time this is executed the child could have been attached to with ptrace, which reparents it. If the flag really needs to be supported (why?), it should make sure the parent is a linux process and also should fix the race with ptrace. Maybe a "fork completed" or something of the sort flag could be introduced, or PRS_NEW state modified later. -- Mateusz Guzik