Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp4826596ybn; Sat, 28 Sep 2019 08:06:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZ2u2QXkLhyVzIqqG5wDAnMq4QMnQwSgMrKY1vXk3NbW6PxmQeBnlVtbFCGgXghz/oYHfe X-Received: by 2002:a17:906:34d0:: with SMTP id h16mr12465651ejb.190.1569683193604; Sat, 28 Sep 2019 08:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569683193; cv=none; d=google.com; s=arc-20160816; b=D21EUiSzHdn4HdtN2RpSnGQgTJ0KoKS/sk1IjsIShTcSKajNzysqtYkM1sjdKShDB+ dAsR91uHINWQrfMvVlIBWNa0cc/ZpjxUIycJirFG4KlJ+2uK865iR2Q8r94AwZ3azscr Lal1jjMzJHzDU+gkGFKmqM/rqHQatkrommmyeKPbjkb1M74c1U4bhGvEKgSScbhB+wlq OSRFqPWuzQiJqMNzyZXBfv9tZITGPJWgXHYPiSYZnygLdOGPfrlLanCgmZfFx0DTDodp xYAlIORhMAC1bqmazSr5l3NGE2MUtbtez7UqqbRcjmkl4rfvthoauHFjgR0igUVUnv+K E2tg== 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:to:subject:cc:dkim-signature; bh=r5btYe583WbPnImhcgeJ0qi2pxEd3RParWXVD2UqrQs=; b=DvA14fuQolhgqfGG1WkmeoEh7GY1PB0velxQZXU50CKQcHctiQ0AQ1+fOxJXOvYW3Y MZWmusv0w3lBJjd+p3dYwR4JXA6/LCX+bWZs7JHrgZEyONSdNAwumB3F8HF2nMQTLZJU GXRA8+tInulnSdhIrPvKsP0ur6FP6E0qloEtD+xEWDdVNyP7/mAyffNKazJ+6rWtGM6t pzpGQbgmHgDIVGjagr+tgMEgXV56XEq/OsIh3MM3IA2M6I2yiHxqNeCFKiFBvbgetRNc HaYOv45gh+2qNPJNGvNMoOb4NSiOEOIdyL4WBKawXlV5XFYXl05T5OMXUC1XcPkr9023 47Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vWUmqXJg; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si4287531eji.137.2019.09.28.08.05.38; Sat, 28 Sep 2019 08:06:33 -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=@gmail.com header.s=20161025 header.b=vWUmqXJg; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726940AbfI1PFe (ORCPT + 99 others); Sat, 28 Sep 2019 11:05:34 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37214 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbfI1PFd (ORCPT ); Sat, 28 Sep 2019 11:05:33 -0400 Received: by mail-wr1-f68.google.com with SMTP id i1so6253782wro.4; Sat, 28 Sep 2019 08:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=r5btYe583WbPnImhcgeJ0qi2pxEd3RParWXVD2UqrQs=; b=vWUmqXJgTwhj+v/R+jwW2Db9/tPVKPHoBnbE/OT99WSQFQNM77KQ8C+lDtnmiMG/Cg NDKehlIZ3CJ/UL9740j+iH9pV3TPnMxJ2mMazqVilMO+ZlGzLulZ0muSxt4QCHAfHkwU DyaPrWxf3Fg+W4DlH04oSpfOo3tPqNZRMNqHNw3opL8tHwGO57S0voqvtMcE+o/btXsL IpsgPJAIW3yfWD/4QYmc7zeiirB5pBkGKbvh4aWZv7da7OtvbsHyXK6dOB06NAua8Pf5 CjZY0M4q+eL6SFTITkRpFXvNgwVsUW8/aPBMt0m5k20oZn/2+/iqSqShGl5WXweFFh9D aIGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=r5btYe583WbPnImhcgeJ0qi2pxEd3RParWXVD2UqrQs=; b=hzwHqwyLFcM4dCZr9mY3agkXM5NEMxlEytgIwyfPKPIvzkcqcQ2XncfkmIH/FDwYBK fwY7yE+sFnOhCsLpPFOMViGkea8F2I7iPpfQhrvIneIKSXHqC6fG7Ufv3bzq04eLAZlv I/lhKSA+6jk26RXmkGksLy139wvrdvES0FzuYe4w8S34Y7B7qFRJTBEp7nX6a/JM+mU6 uIa6JgAToDN5u/xcac5lOrozZXh6UZoaLFOVPavwG3InCmgg4nhgZ5fUALkNWzjEo07Z zbCoAOnEazjz3Ek77UppuZmUYwoHUzXqR1PggYmQAQE2zMhHqDprvRt2hDhjL0zJIcxm L47g== X-Gm-Message-State: APjAAAX5A9eJPdpXVf07Dpkm1sZPbAhV46v+GzIt+RurcSYRS4hKks8B AHIT1eL4FWV4Gm2+kVdHI08= X-Received: by 2002:adf:e988:: with SMTP id h8mr6836693wrm.354.1569683131250; Sat, 28 Sep 2019 08:05:31 -0700 (PDT) Received: from [10.0.20.253] ([95.157.63.22]) by smtp.gmail.com with ESMTPSA id f143sm22561378wme.40.2019.09.28.08.05.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 28 Sep 2019 08:05:30 -0700 (PDT) Cc: mtk.manpages@gmail.com, Christian Brauner , linux-man , Containers , lkml , Andy Lutomirski , Jordan Ogas , werner@almesberger.net, Al Viro Subject: Re: pivot_root(".", ".") and the fchdir() dance To: "Eric W. Biederman" References: <20190805103630.tu4kytsbi5evfrhi@mikami> <3a96c631-6595-b75e-f6a7-db703bf89bcf@gmail.com> <87r24piwhm.fsf@x220.int.ebiederm.org> <87ftl5donm.fsf@x220.int.ebiederm.org> <20190910111551.scam5payogqqvlri@wittgenstein> <30545c5c-ff4c-8b87-e591-40cc0a631304@gmail.com> <871rwnda47.fsf@x220.int.ebiederm.org> <448138b8-0d0c-5eb3-d5e5-04a26912d3a8@gmail.com> <87ef0hbezt.fsf@x220.int.ebiederm.org> From: "Michael Kerrisk (man-pages)" Message-ID: <71cad40b-0f9f-24de-b650-8bc4fce78fa8@gmail.com> Date: Sat, 28 Sep 2019 17:05:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Eric, A ping on my question below. Could you take a look please? Thanks, Michael >>>> The concern from our conversation at the container mini-summit was that >>>> there is a pathology if in your initial mount namespace all of the >>>> mounts are marked MS_SHARED like systemd does (and is almost necessary >>>> if you are going to use mount propagation), that if new_root itself >>>> is MS_SHARED then unmounting the old_root could propagate. >>>> >>>> So I believe the desired sequence is: >>>> >>>>>>> chdir(new_root); >>>> +++ mount("", ".", MS_SLAVE | MS_REC, NULL); >>>>>>> pivot_root(".", "."); >>>>>>> umount2(".", MNT_DETACH); >>>> >>>> The change to new new_root could be either MS_SLAVE or MS_PRIVATE. So >>>> long as it is not MS_SHARED the mount won't propagate back to the >>>> parent mount namespace. >>> >>> Thanks. I made that change. >> >> For what it is worth. The sequence above without the change in mount >> attributes will fail if it is necessary to change the mount attributes >> as "." is both put_old as well as new_root. >> >> When I initially suggested the change I saw "." was new_root and forgot >> "." was also put_old. So I thought there was a silent danger without >> that sequence. > > So, now I am a little confused by the comments you added here. Do you > now mean that the > > mount("", ".", MS_SLAVE | MS_REC, NULL); > > call is not actually necessary? > > Thanks, > > Michael > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/