Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp774700ybn; Wed, 25 Sep 2019 07:33:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJWSrFz4I0uap1D8sBY6Ssl5HXf9JxEDHAAOe3si/Pc4ZOsLRNLI5NeiDGkPRbXLAfTxrv X-Received: by 2002:a17:906:d92c:: with SMTP id rn12mr4382841ejb.16.1569421994744; Wed, 25 Sep 2019 07:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569421994; cv=none; d=google.com; s=arc-20160816; b=QUaU1ES/AjukO4EJt3aDmF+2RGw71On7Qusz/PCYXeqNvwkgGnCEm/lbHDtV9tBd6I +RISqm+15YmMp4iOtXirijEWz4dchrH7en/KP/rAwiknI82nGWZrKpLco5qMWX/Qtj+4 JXbAukJ1KSQWAbPwvL5IsNMTaC+lA87M+PqpwMjh2Xg7tnZFc2Kce4qeVfP4M2tddWv2 8PAb6x0lZgJET6hi7VVqCgIpdOBh1KlCbJjW+OK9R8AM7kI52tVUnLU9t+qUbugB9RyM vStgdbIgfKt3xc0m9s9bVFmjm5yjhp+LsC9dIVT+q2UtdguOK6AUummhxyt5+2RXZ7uM Ezig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=LW9MOLNkhuQA7V3h/TyL3XL/obHHYH5vxgY6oe+tnqY=; b=BdIauneA8hpzyLVvnAsEOW41rKXLGkf/XFkHIwDiYkYdK6IjicJ4TIYVXp3lDdsJqF Zi7I/HCXNihZYq8Qa/fX4IAwx2uWSkRSNUacl0B1n/Nlz1VZBqcYAPUscoJ7y6aTZHPP Mj8pLaFGeeD+cHpUpJU+DlvgezNxC98NCnxtIdjCGQKGp0wHpqKv1pflhsh5iG9OSkGC x3taHSFGULqfUD7FrY5MjjFkr+TOjJ81GG4ST6QY0qgDBRyCsbCxqno/4hW1jwvf/v2V fSiV+nqXSowgRP7DFxsNT5X5jIAEBmsxv4W1Eo4YnvXzO/jIV/hJ6o9W1kZr2jwsxLxn +YMw== 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 be24si3262866edb.120.2019.09.25.07.32.47; Wed, 25 Sep 2019 07:33:14 -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 S2408002AbfIWNu4 (ORCPT + 99 others); Mon, 23 Sep 2019 09:50:56 -0400 Received: from ngcobalt01.manitu.net ([217.11.48.101]:45108 "EHLO ngcobalt01.manitu.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407710AbfIWNu4 (ORCPT ); Mon, 23 Sep 2019 09:50:56 -0400 X-Greylist: delayed 434 seconds by postgrey-1.27 at vger.kernel.org; Mon, 23 Sep 2019 09:50:55 EDT Received: from server.passau (ipbcc3eb9d.dynamic.kabel-deutschland.de [188.195.235.157]) (Authenticated sender: smtp-send) by ngcobalt01.manitu.net (Postfix) with ESMTPSA id A4F2033E076A; Mon, 23 Sep 2019 15:43:39 +0200 (CEST) Received: from [172.18.159.113] (unknown [46.183.103.17]) by server.passau (Postfix) with ESMTPSA id E6E0F814C1; Mon, 23 Sep 2019 15:43:10 +0200 (CEST) Subject: Re: For review: rewritten pivot_root(2) manual page To: "Michael Kerrisk (man-pages)" , "Eric W. Biederman" , "Serge E. Hallyn" , Christian Brauner , Aleksa Sarai , Reid Priedhorsky , Andy Lutomirski , Yang Bo , Jakub Wilk , Joseph Sible , Al Viro , werner@almesberger.net Cc: linux-man , lkml , Containers , =?UTF-8?Q?St=c3=a9phane_Graber?= References: <620c691a-065e-b894-4f06-7453012bc8d3@gmail.com> From: Philipp Wendler Message-ID: Date: Mon, 23 Sep 2019 15:42:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <620c691a-065e-b894-4f06-7453012bc8d3@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Michael, Am 23.09.19 um 14:04 schrieb Michael Kerrisk (man-pages): > I'm considering to rewrite these pieces to exactly > describe what the system call does (which I already > do in the third paragraph) and remove the "may or may not" > pieces in the second paragraph. I'd welcome comments > on making that change. I think that it would make the man page significantly easier to understand if if the vague wording and the meta discussion about it are removed. > DESCRIPTION [...]> pivot_root() changes the > root directory and the current working directory of each process > or thread in the same mount namespace to new_root if they point to > the old root directory. (See also NOTES.) On the other hand, > pivot_root() does not change the caller's current working direc‐ > tory (unless it is on the old root directory), and thus it should > be followed by a chdir("/") call. There is a contradiction here with the NOTES (cf. below). > The following restrictions apply: > > - new_root and put_old must be directories. > > - new_root and put_old must not be on the same filesystem as the > current root. In particular, new_root can't be "/" (but can be > a bind mounted directory on the current root filesystem). Wouldn't "must not be on the same mountpoint" or something similar be more clear, at least for new_root? The note in parentheses indicates that new_root can actually be on the same filesystem as the current note. However, ... > - put_old must be at or underneath new_root; that is, adding a > nonnegative number of /.. to the string pointed to by put_old > must yield the same directory as new_root. > > - new_root must be a mount point. (If it is not otherwise a > mount point, it suffices to bind mount new_root on top of > itself.) ... this item actually makes the above item almost redundant regarding new_root (except for the "/") case. So one could replace this item with something like this: - new_root must be a mount point different from "/". (If it is not otherwise a mount point, it suffices to bind mount new_root on top of itself.) The above item would then only mention put_old (and maybe use clarified wording on whether actually a different file system is necessary for put_old or whether a different mount point is enough). > NOTES [...] > pivot_root() allows the caller to switch to a new root filesystem > while at the same time placing the old root mount at a location > under new_root from where it can subsequently be unmounted. (The > fact that it moves all processes that have a root directory or > current working directory on the old root filesystem to the new > root filesystem frees the old root filesystem of users, allowing > it to be unmounted more easily.) Here is the contradiction: The DESCRIPTION says that root and current working dir are only changed "if they point to the old root directory". Here in the NOTES it says that any root or working directories on the old root file system (i.e., even if somewhere below the root) are changed. Which is correct? If it indeed affects all processes with root and/or current working directory below the old root, the text here does not clearly state what the new root/current working directory of theses processes is. E.g., if a process is at /foo and we pivot to /bar, will the process be moved to /bar (i.e., at / after pivot_root), or will the kernel attempt to move it to some location like /bar/foo? Because the latter might not even exist, I suspect that everything is just moved to new_root, but this could be stated explicitly by replacing "to the new root filesystem" in the above paragraph with "to the new root directory" (after checking whether this is true). > EXAMPLE> The program below demonstrates the use of pivot_root() inside a > mount namespace that is created using clone(2). After pivoting to > the root directory named in the program's first command-line argu‐ > ment, the child created by clone(2) then executes the program > named in the remaining command-line arguments. Why not use the pivot_root(".", ".") in the example program? It would make the example shorter, and also works if the process cannot write to new_root (e..g., in a user namespace). Regards, Philipp