Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4810559ybg; Tue, 29 Oct 2019 12:44:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwB1tgbzBcvL9tUKcHNk0EjTyxl4L+bXspoe942RUwBMihccg2FydEsKYp2VpHUwzChxDVM X-Received: by 2002:a17:906:5f8a:: with SMTP id a10mr5187338eju.204.1572378276802; Tue, 29 Oct 2019 12:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572378276; cv=none; d=google.com; s=arc-20160816; b=XYH4dEd7dJ+Z5LGUNf9bdBsc4rXDl6e7tfCuWMSHY3fjn7qhALwo7IO8lj3cGTRA+E JKw6JiBQHRvr+gr/1NXHYoN2cEETEkStvoSIWiJN0+ITN/wzrDR8VcT4kmpHGIetXDhn mdftEVqaVmrueQ7bDTkV6rnd8cLyCC+92lITQg75dqFBgnKJ7O5Ht86zMV4u9K8N4pvk bLRhe5XnnmJe6IokA00rPdljfEL8zrgFnxZMmcZKlbNjqj03g0l5Z/QAkMyogN6PY/8S z2IFWx3i4U76lE3H2uSqzk8Gx80co92HdwSSWWm7b9yAaB7AZWgLQGMHVZZiC0MvjHyu DPmw== 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=Kpw6kIhG5qk5+SF1ocs8o7hmvdHB1eO67/DCJ4bRv80=; b=AHsG2VpZy4sNpbi1SSJQ3vAXCnn7f/DeX02ZRooD2cqy7hJ8mfesvgMRWm3QfDmCDT CB39/2BRG3dMBWFNuOXQPTcznjxNAaFWap7y50FrEVDeSmgAahUTOjwYpVEG67HPJTcH OTZagDXJFkrKDJKdl5P+ilqYj6LDjXHDaZ5UYFuH+8bl7ktITyCAECbwvfZtAWZc2e2v YPgGoskMQmfc4LY+24fc92vh4eqOO0ffNZAO7UI082aR8VoG+DEZ86HvR4NLnRuqhG12 jIpN/wyxVYWSdPXWLunZtvyvv3+8Wj6EaMHj7WzXwW0ZNR/vucCSVjj5KupwyhhvdhDn LAOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="JYrOuGv/"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi17si4960530edb.430.2019.10.29.12.44.13; Tue, 29 Oct 2019 12:44:36 -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=@google.com header.s=20161025 header.b="JYrOuGv/"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389781AbfJ2PVK (ORCPT + 99 others); Tue, 29 Oct 2019 11:21:10 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:44699 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389299AbfJ2PVJ (ORCPT ); Tue, 29 Oct 2019 11:21:09 -0400 Received: by mail-ot1-f66.google.com with SMTP id n48so10046053ota.11 for ; Tue, 29 Oct 2019 08:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Kpw6kIhG5qk5+SF1ocs8o7hmvdHB1eO67/DCJ4bRv80=; b=JYrOuGv/xDIu8OSupe0HmWiAxv5wEi1FCYbEN6SGbriWdCAI5idijo6yXIRBECTqhc vmtyxGKEG7XOo+BcLtqKLDYo6aFo/3btITf8S7qh/JsubrFaR487MDGa2/u61mXZGTIX 4WnHc6OUZqe/4s0b1hAjVf4D6kB2fjyGr/xK1E/XTk7mefU1Sw23dv0zN+q7DARlL/no 0D3IGwmbLnOi89eB4K4OipKyvnS18TM7a8CSYvb+68Upa3Xaimkzax2bPS9/o/2BTGYW kxT2p831P07PIW37IYxE2hXuRV16RvHwKWLPZPUkMdM/X+Af/QQsmb5wnC/B6a1/VRLs JJTw== 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=Kpw6kIhG5qk5+SF1ocs8o7hmvdHB1eO67/DCJ4bRv80=; b=W+y0KYeCxvRtXS7JovrXSog8cLOOmobfiqd1BGT5tmvh16it6sJSp14UaBr4IN3PZR o/1t+IjAnowKIl+8tnvRwsd4Ess/S9edFCGvjJogOGGfE9N5r6Lq3GeraFWptr7Q+boz YRisgxCctEPn22eTqnd2KUebO3Sqg8Pme/utpqwdg9/hbQR5VQRz16a8xKbjKFkqOHRM VsLt/+W1VhguX3vnk7V9k02BbJKPqm4/WOPSMyuumifLXQkpKwwqrBuIDTleoNNQi4rg QVhJKtgU0vfC6Y7J1EqHxTBe/s7wv7GHxAVFUHiLDS06pV3V9FNgXqkDxeQxckl1POhO gEqQ== X-Gm-Message-State: APjAAAWonq0xJ3Cv1nVo6dDjnMCLpk1bFOxQLLqawUe5TtE+k0UJgjW+ QhiOHwb1KuuvRIY/PuFiC+KQ8qAWitu4g4g86wkWBw== X-Received: by 2002:a9d:3a75:: with SMTP id j108mr10442372otc.110.1572362464482; Tue, 29 Oct 2019 08:21:04 -0700 (PDT) MIME-Version: 1.0 References: <20191028172143.4vnnjpdljfnexaq5@wittgenstein> <20191029112706.p5dd5yzpcgouo6n5@wittgenstein> <20191029142622.jxmssu4s4ndui7bw@wittgenstein> In-Reply-To: <20191029142622.jxmssu4s4ndui7bw@wittgenstein> From: Jann Horn Date: Tue, 29 Oct 2019 16:20:37 +0100 Message-ID: Subject: Re: For review: documentation of clone3() system call To: Christian Brauner Cc: Florian Weimer , Michael Kerrisk-manpages , lkml , linux-man , Kees Cook , Oleg Nesterov , Arnd Bergmann , David Howells , Pavel Emelyanov , Andrew Morton , Adrian Reber , Andrei Vagin , Linux API 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, Oct 29, 2019 at 3:26 PM Christian Brauner wrote: > On Tue, Oct 29, 2019 at 12:27:07PM +0100, Christian Brauner wrote: > > On Mon, Oct 28, 2019 at 08:09:13PM +0100, Jann Horn wrote: > > > On Mon, Oct 28, 2019 at 6:21 PM Christian Brauner > > > wrote: > > > > where stack + stack_size is addition on a void pointer which usually > > > > clang and gcc are not very happy about. > > > > I wanted to bring this up on the mailing list soon: If possible, I don't > > > > want userspace to need to know about stack direction and just have stack > > > > point to the beginning and then have the kernel do the + stack_size > > > > after the copy_clone_args_from_user() if the arch needs it. For example, > > > > by having a dumb helder similar to copy_thread_tls()/coyp_thread() that > > > > either does the + stack_size or not. Right now, clone3() is supported on > > > > parisc and afaict, the stack grows upwards for it. I'm not sure if there > > > > are obvious reasons why that won't work or it would be a bad idea... > > > > > > That would mean adding a new clone flag that redefines how those > > > parameters work and describing the current behavior in the manpage as > > > the behavior without the flag (which doesn't exist on 5.3), right? > > > > I would break API and if someone reports breakage we'll revert and go > > the more complicated route you outlined (see [1]). > > @Jann, I think the following patch might even be enough?... [...] > +static inline void clone3_prepare_stack(struct kernel_clone_args *kargs) > +{ > +#if !defined(CONFIG_STACK_GROWSUP) && !defined(CONFIG_IA64) > + kargs->stack += kargs->stack_size; > +#endif > +} I guess it might work as long as nobody is actually using clone3 yet and you can get this patch into the 5.3 stable tree and any distro kernels on 5.3 before people do start using clone3?