Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4248863ybg; Tue, 29 Oct 2019 04:28:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyn8rkWMp3Lu4h375wS1bLvr+QAzLFrtMwzwpy7SOiTaAAb6blYDjm/yWEO1CSW+syR7a6 X-Received: by 2002:a17:906:4b16:: with SMTP id y22mr2782637eju.56.1572348517166; Tue, 29 Oct 2019 04:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572348517; cv=none; d=google.com; s=arc-20160816; b=Q8mpdUxOqFNMlT3oa/uCXagG9T/qwr47h/Rc044HPY8ZfRq6XHMpgpxr00FkfyZajP WVROKMr3Xqj7RqhZ0/7pmKa6VqpwiwV+0w7DNy3ZAzxT0eFJDoXOeKXUznorVKkT5eQq Eu3PSgR1xdKxGOwqtjkHeMaWds9HtgJv9psL+44o79AeisNWAPBehIZDWML9QhQZzN38 HkwTIGuYySVEOHTmu6J81sv9H8J6vVks2WtL4j+uXTyr7k5NZfcsoSUli7zTwm0+RXRa T4oDRqZeeuwHDFkA4R5vcsWfXTEHM8dWxU9JknljI+AaADu2WWcEU4+AXEbB6jcNDPxj 22hw== 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=qz3hA8yA0+w6FLnqnoognKYGH59lxjIAxcP+YbKv5TY=; b=esYN8YSCUP5Rl4td4P9Yb8Tnh/wer5SoR0vFiwgc2ZVLfnfE4Xf47ETMb0uGZ4T5vK GjhXC8iyfBpAblhTAWm7uA+4Wcco1CdMWjcsxmHqsE0v3qv5gg4b1Z44wF/3lP04Y00Q 6PMwSb0bCC8/9Hy6bxifEYCKuemFTvi7/Q5pkgsIGZVeWNDWImbzyLMl8SHZqcID14Ot bi1OTTBt1SU0BLf6CsORjspkrUpWQ4wVxDauZ0By3ldfABE/huOAPY5MqXp8Ufm63cxC zVjRqljK531i7z4MOH+A8czfPzVVADzH7QnUJCtWCFz31tgLKnOFNoHpYAAoW04GRk2I +5hg== 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 d24si9881717eda.162.2019.10.29.04.28.13; Tue, 29 Oct 2019 04:28:37 -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 S1728148AbfJ2L1L (ORCPT + 99 others); Tue, 29 Oct 2019 07:27:11 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:37084 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbfJ2L1K (ORCPT ); Tue, 29 Oct 2019 07:27:10 -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 1iPPeW-0005r1-8D; Tue, 29 Oct 2019 11:27:08 +0000 Date: Tue, 29 Oct 2019 12:27:07 +0100 From: Christian Brauner To: Jann Horn Cc: Michael Kerrisk-manpages , lkml , linux-man , Kees Cook , Florian Weimer , 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: <20191029112706.p5dd5yzpcgouo6n5@wittgenstein> References: <20191028172143.4vnnjpdljfnexaq5@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 Mon, Oct 28, 2019 at 08:09:13PM +0100, Jann Horn wrote: > On Mon, Oct 28, 2019 at 6:21 PM Christian Brauner > wrote: > > On Mon, Oct 28, 2019 at 04:12:09PM +0100, Jann Horn wrote: > > > On Fri, Oct 25, 2019 at 6:59 PM Michael Kerrisk (man-pages) > > > wrote: > > > > I've made a first shot at adding documentation for clone3(). You can > > > > see the diff here: > > > > https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=faa0e55ae9e490d71c826546bbdef954a1800969 > [...] > > > You might want to note somewhere that its flags can't be > > > seccomp-filtered because they're stored in memory, making it > > > inappropriate to use in heavily sandboxed processes. > > > > Hm, I don't think that belongs on the clone manpage. Granted that > > process creation is an important syscall but so are a bunch of others > > that aren't filterable because of pointer arguments. > > We can probably mention on the seccomp manpage that seccomp can't filter > > on pointer arguments and then provide a list of examples. If you setup a > > seccomp filter and don't know that you can't filter syscalls with > > pointer args that seems pretty bad to begin with. > > Fair enough. > > [...] > > One thing I never liked about clone() was that userspace had to know > > about stack direction. And there is a lot of ugly code in userspace that > > has nasty clone() wrappers like: > [...] > > 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]). But I don't think it will a big deal. First, we haven't documented how stack needs to be passed so who knows what people currently do. Second, clone3() has not been out for a long time and currently does _not_ provide features that legacy clone() does not provide apart from a cleaner interface. So userspace has no incentive to use clone3() over clone() right now. That'll change latest with v5.5 where we have new features on top of clone3() (CLONE_CLEAR_SIGHAND). So let's just try and fix it. [1]: This is basically what Linus has repeatedly said: it's not about never breaking api in principle but rather about whether this breaks someones usecase. And if it does break, we need to revert. Christian