Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5122826yba; Tue, 30 Apr 2019 09:28:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqegfRxe5tLg/vIefsmy2yb5MR4hnnUmChbJ/qnVGTHv7a5wpaYNMdm7HtzCjPcI+bditS X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr70811895plb.190.1556641737957; Tue, 30 Apr 2019 09:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556641737; cv=none; d=google.com; s=arc-20160816; b=bDxPY1DUIioM+eQ4WTGMzraKNp8pEseiG3EthEtJXTjw9i66KUP0EcyxLOopiimj9Y BFHBdkpDIeOp1+/Mojglbwm4I0cHXKg+tceRhOru19yXrfOpBK4kOn01xSmKfbskYHgR D7BRGFybe7gI65+kSPB677OymgWDBsCKZK0Z0JjYOKyFVzWkfQVElCD0hzRo6Q5wURI/ AnBVMpLe4NJMOwHyH6ur/hPgDms1PJeSVlZ9EAqUhI9b6ERa+ZZvlsPBCaseDPS3p9HN 8LjK4QUNZYDw90vJ6mSsGFESzKazlmiuoJJyN0HpwbdIHqyrlzjmA53BYQrvtfZEz9Kf K7lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=BPJ14HI8nidtRQ09xbk5mtnZ2GEqgeW1g0o9PAYcc7E=; b=GUiftfvhZKbMBEY+OB6vLy7S/lRHtVPokXFcc5DK8m6vHfkhK4w8XMt1k8hX9bqbtV 4M1KMzqTFBMil+UPxUp1fNy603a4uiLeFd5d5Uk7XJVw60bmHZtL7LEpKCRm0td6wqiX Tfy5xcs001tz9oGoInLyzAPdpZkP6mLexDKWDEExgbjO9o8lnPUXZpdws1wuYdOPYiuO bEcOBvf4nRLtTW/r00eL5dXPBKqhMJbvR3ZZ8gAvtMlLg6RRJ7yDtvy1Qyzc/xFam93x Y9JycJrmTUTAiI+Kojt0DJClUkPNkUP3xysbmSQNIQpbVx8rcnHkZQigq3sNDqQVOglF RP/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="N71KCO/O"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e35si39188291plb.38.2019.04.30.09.28.42; Tue, 30 Apr 2019 09:28:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="N71KCO/O"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726632AbfD3Q1T (ORCPT + 99 others); Tue, 30 Apr 2019 12:27:19 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:44867 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726048AbfD3Q1T (ORCPT ); Tue, 30 Apr 2019 12:27:19 -0400 Received: by mail-lj1-f196.google.com with SMTP id c6so6882035lji.11 for ; Tue, 30 Apr 2019 09:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BPJ14HI8nidtRQ09xbk5mtnZ2GEqgeW1g0o9PAYcc7E=; b=N71KCO/OD3WVF6avSQuHQlEpn5ohk7wqryuyQsevf2srgYtCoP3CQc9ORuDKUH7RiD EFC0FLhGc/4syjSWjmKURrMQsiJDM+d2OOLgA39+/dzcTaOBbXV/QrgIAytHBe9kKjMQ lGI7zuiHf+5TrZMM5uFoPlrJcAHhz5pQPw+30= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BPJ14HI8nidtRQ09xbk5mtnZ2GEqgeW1g0o9PAYcc7E=; b=SOWWlf7uMSxGgdx1Jf10KUZxbfc3L3HQ2aKzEMU+6XktYiDA4OD+ioyO2Kmin5kXD/ 2F9wHxx3MHvRCXrUd8h/FGJ6vRLBd+77o2wOKh41xpT9ftZ9YS+Q83I7i+B8yD7hYjCK ZAfhUWPcCn/p5KnlTXZQinSZ9sXTgYTZ29rICSkb9gMUqMh829qzkWgyfEJYcnh178qB 8Ut4VIvuFeOXpPpzL53cbLoGBEqkRWjkVIS06yfvJw7dZjyqhKT9u0tvRLLYD2NvISq3 bbfuyP2qeRiV8nINLmdeO3yrgJgDkPQz5pYrgpEKC6Yg4E53lfnL3tLeYc9lzM7BdYZL kcdw== X-Gm-Message-State: APjAAAUlgkR8EBe9yg/sewec8mIBB6jHzr2yRHb2gr3YZSxf4dbq9nUv iOosJYJnGu4LHWxDMqcyzoJ7SzxGAXY= X-Received: by 2002:a2e:7c02:: with SMTP id x2mr35217641ljc.176.1556641636920; Tue, 30 Apr 2019 09:27:16 -0700 (PDT) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com. [209.85.167.54]) by smtp.gmail.com with ESMTPSA id w8sm8072449lfn.95.2019.04.30.09.27.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 09:27:14 -0700 (PDT) Received: by mail-lf1-f54.google.com with SMTP id h18so11195413lfj.11 for ; Tue, 30 Apr 2019 09:27:13 -0700 (PDT) X-Received: by 2002:ac2:4567:: with SMTP id k7mr36979375lfm.166.1556641633154; Tue, 30 Apr 2019 09:27:13 -0700 (PDT) MIME-Version: 1.0 References: <20190414201436.19502-1-christian@brauner.io> <20190415195911.z7b7miwsj67ha54y@yavin> <20190420071406.GA22257@ip-172-31-15-78> <87r29jaoov.fsf@oldenburg2.str.redhat.com> In-Reply-To: From: Linus Torvalds Date: Tue, 30 Apr 2019 09:26:57 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: RFC: on adding new CLONE_* flags [WAS Re: [PATCH 0/4] clone: add CLONE_PIDFD] To: Florian Weimer Cc: Jann Horn , Kevin Easton , Andy Lutomirski , Christian Brauner , Aleksa Sarai , "Enrico Weigelt, metux IT consult" , Al Viro , David Howells , Linux API , LKML , "Serge E. Hallyn" , Arnd Bergmann , "Eric W. Biederman" , Kees Cook , Thomas Gleixner , Michael Kerrisk , Andrew Morton , Oleg Nesterov , Joel Fernandes , Daniel Colascione Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 30, 2019 at 9:19 AM Linus Torvalds wrote: > > Of course, if you *don't* need the exact vfork() semantics, clone > itself actually very much supports a callback model with s separate > stack. You can basically do this: > > - allocate new stack for the child > - in trivial asm wrapper, do: > - push the callback address on the child stack > - clone(CLONE_VFORK|CLONE_VM|CLONE_SIGCHLD, chld_stack, NULL, NULL,NULL) > - "ret" > - free new stack > > where the "ret" in the child will just go to the callback, while the > parent (eventually) just returns from the trivial wrapper and frees > the new stack (which by definition is no longer used, since the child > has exited or execve'd. In fact, Florian, maybe this is the solution to your "I want to use vfork for posix_spawn(), but I don't know if I can trust it" problem. Just use clone() directly. On WSL it will presumably just fail, and you can then fall back on doing the slow stupid fork+pipes-to-communicate. On valgrind, I don't know what will happen. Maybe it will just do an unchecked posix_spawn() because valgrind doesn't catch it? Linus