Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4810819ybg; Tue, 29 Oct 2019 12:44:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2QLciITB8AaIEZOFcYX18CeoDQl8PNCeiHPmg+IzCbWuZJBCbHRMUolfAxPDwPzDV9bsK X-Received: by 2002:a17:906:3e91:: with SMTP id a17mr5019654ejj.218.1572378293368; Tue, 29 Oct 2019 12:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572378293; cv=none; d=google.com; s=arc-20160816; b=ZaII8l2UoUAB8GmbZlRrEZjz/IYr1bRCgjRw1lreIcqRpm0+HA0CEUnWQABS8xQqDu ovvwSkPcfHURh9sclsMDxVfO4LCFtICmfwqf/EIMcDXUS4hkIN9+JKrHm9JyVIOj5z9r lCSHIvZUlq52yUrKKK6mkXPOCIXSaeKCP17kxC8UvFlXMWYS4wfFL7niV/P9C1b5Bufe D3tUz+zOw4ewkLlv2A/aB+cDrHCfVgl3LFQFF53gCQJI9b/5CC6gnNULkssAXnH54SKX Q9DfhCUsQkjAFwgsP6BRmkSkxJE7BaiZugbMvuRS2D6iiLMDQXnVC/B82gD1zlEqGIVQ 8lTw== 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=d/5Vy0mJdQ5sgGdR5HsDNifFZJA/55BxfkcqXxmR034=; b=Qr9kyIhO2t9sZ0RdvoM/UUqZaMguMb0bA9UQet7IT3e+65Dajwqt3ZCEx1IvQArBlP cx6gM0fJO3XwOVK58zA8cBEbfLaGXDcYLoxs++263w1eeBWH5WVUfUCqHKgM0FpdJbf8 /7OUfB4yzQX6PGmTLrEHYOJnO1eT9iFL/yXVkXW39lT8SXPM4lkZ1mCP9v7+lpWkqvRa EXjS4RfHC2f3xj0eduZ+PEKz/g6JOvDAjUvN/57ZEw8cCE4z9+pGXY/rBUnarv5f6BDZ k+gamYDu/k0c4n8UxtxaTkuSmCcB34mE6qj+8kUSMVcPPTdDJCuI+VbdzshMep1Dw52K EpMQ== 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 p48si10657738eda.348.2019.10.29.12.44.29; Tue, 29 Oct 2019 12:44:53 -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 S2390246AbfJ2QES (ORCPT + 99 others); Tue, 29 Oct 2019 12:04:18 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45794 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389940AbfJ2QES (ORCPT ); Tue, 29 Oct 2019 12:04:18 -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 1iPTyg-00083F-6G; Tue, 29 Oct 2019 16:04:14 +0000 Date: Tue, 29 Oct 2019 17:04:13 +0100 From: Christian Brauner To: Florian Weimer Cc: Jann Horn , 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: <20191029160412.jfnwlgaxhyvqpqga@wittgenstein> References: <20191028172143.4vnnjpdljfnexaq5@wittgenstein> <20191029112706.p5dd5yzpcgouo6n5@wittgenstein> <20191029142622.jxmssu4s4ndui7bw@wittgenstein> <87wocn39fu.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87wocn39fu.fsf@oldenburg2.str.redhat.com> 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 03:36:37PM +0100, Florian Weimer wrote: > * Christian Brauner: > > > @Florian, do you have an opinion about always passing the stack from the > > lowest address with clone3()? > > Do you mean that the stack extends from stack to stack_size? I guess Specifically, that userspace doesn't need to know whether it needs to pass stack or stack + stack_size. The kernel will just do the stack + stack_size if the architecture has a downwards growing stack. So for _all_ architectures, ia64 or not, you'd always pass: void *p[PAGE_SIZE]; struct clone_args args = { .stack = p, .stack_size = PAGE_SIZE, }; > that makes sense. What about architectures which need two stacks (I > think ia64 is one)? I don't think ia64 needs any special treament. ia64 requires you to pass the lowest address of the stack and the kernel does the additon to reach the top of the stack and the alignemnt too. So ia64 _in the kernel_ currently does: arch/ia64/kernel/entry.S:sys_clone2() - setup stack and stack size and call into do_fork() -> kernel/fork.c:do_fork() -> copy_thread_tls() -> arch/ia64/kernel/process.c:copy_thread(): if (user_stack_base) { child_ptregs->r12 = user_stack_base + user_stack_size - 16; child_ptregs->ar_bspstore = user_stack_base; child_ptregs->ar_rnat = 0; child_ptregs->loadrs = 0; } > There is also the matter whose responsibility is the alignment of the > initial stack pointer. Hm, probably also a detail that userspace shouldn't need to know about? Christian