Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4572003ybg; Tue, 29 Oct 2019 09:07:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1e/KDnjCChku79pQfhLVaS/r4UACjXVADHJ2kFeDGk18SJkt5HzKP8UpeDckmy4bCbkc6 X-Received: by 2002:a17:906:73d4:: with SMTP id n20mr4146009ejl.45.1572365269706; Tue, 29 Oct 2019 09:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572365269; cv=none; d=google.com; s=arc-20160816; b=EtcTBlJoEuD/Nh39ua2xWBTlGrgeJx4IwGasqgBRxFapGhOA2fNJY1Zxt1NoYYA6v6 b9kY58Py7fMJrrz1+Efd1RM58OgukZ/2O7tRw9gG3lY3XkvQCT37Z703u2Q0R9ZvA1js zXVAghNJGJJSxmyyEtMqMcLaIcZUIWILO4BRZ3XO+Weq33NcDoJnpCxs1zTZStNdyslc fipzmgtJ7jFar11eWePmEcvizSrtr5e++vlXzj58sIpyd5sV3fuDjmhQX0QuOB/ywyLH Eatmm99b4zWv9Zh6i2YanKbND8snWsdsTdE58J/DZyuxMXak+ItvVGjYnJJ9btoRg90l Eicg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=4qRyfND3Bi7XnLFG5zTwiENEO4NE6+kjeNPG8GBG1FE=; b=KCsIYk2hm4eA01mAJdyorsltu1+hHJ7K+cm8obMYR/GH6JhGPZMzp8nRUNFGmMKf77 szlfOUkWtBn96imb/Ep1Rsu40faQfoJjkHyfAz8kXMg5KMpFg2fXUIlENzanvOiPFlj9 eYZ854wVIBNTq6LB0ITPSFk9/2LF0AuPXndbcdX6s47aRQd7QgIs6717uMXtwI/8OEXE kbPFCXdOWTbIdcyIkMhSHHa7HNCYfiE5upw5v0VuBEnMb3E2peUvbPGCHaHmuklMcwYL jm5NKhQ9Osm9AzB+wuTB8WNh6DCPKkUMakC1eJe6NLR6iZEO5yiYDmEcz3nhp6H4yN/U 7lNQ== ARC-Authentication-Results: i=1; mx.google.com; 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 s19si8465747ejr.279.2019.10.29.09.07.18; Tue, 29 Oct 2019 09:07:49 -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; 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 S2390292AbfJ2QFc (ORCPT + 99 others); Tue, 29 Oct 2019 12:05:32 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45836 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389902AbfJ2QFb (ORCPT ); Tue, 29 Oct 2019 12:05:31 -0400 Received: from [91.217.168.176] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iPTzr-0008CT-3h; Tue, 29 Oct 2019 16:05:27 +0000 Date: Tue, 29 Oct 2019 17:05:26 +0100 From: Christian Brauner To: Jann Horn 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 Subject: Re: For review: documentation of clone3() system call Message-ID: <20191029160525.2zn6vnnyai5ahdj3@wittgenstein> References: <20191028172143.4vnnjpdljfnexaq5@wittgenstein> <20191029112706.p5dd5yzpcgouo6n5@wittgenstein> <20191029142622.jxmssu4s4ndui7bw@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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 04:20:37PM +0100, Jann Horn wrote: > 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? Yes, that would be my preferred approach. As I said doing it this way is pretty common. A recent example where we did this is the file_max sysctl. Christian