From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754828AbdBGQh2 (ORCPT ); Tue, 7 Feb 2017 11:37:28 -0500 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:56822 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753866AbdBGQhZ (ORCPT ); Tue, 7 Feb 2017 11:37:25 -0500 Message-ID: <1486485440.2488.15.camel@HansenPartnership.com> Subject: Re: [RFC 1/1] shiftfs: uid/gid shifting bind mount From: James Bottomley To: Christoph Hellwig Cc: Djalal Harouni , Chris Mason , Theodore Tso , Josh Triplett , "Eric W. Biederman" , Andy Lutomirski , Seth Forshee , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Dongsu Park , David Herrmann , Miklos Szeredi , Alban Crequy , Al Viro , "Serge E. Hallyn" , Phil Estes Date: Tue, 07 Feb 2017 08:37:20 -0800 In-Reply-To: <20170207091924.GA13995@infradead.org> References: <1486235880.2484.17.camel@HansenPartnership.com> <1486235972.2484.19.camel@HansenPartnership.com> <20170207091924.GA13995@infradead.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2017-02-07 at 01:19 -0800, Christoph Hellwig wrote: > On Sat, Feb 04, 2017 at 11:19:32AM -0800, James Bottomley wrote: > > This allows any subtree to be uid/gid shifted and bound elsewhere. > > It does this by operating simlarly to overlayfs. Its primary use > > is for shifting the underlying uids of filesystems used to support > > unpriviliged (uid shifted) containers. The usual use case here is > > that the container is operating with an uid shifted unprivileged > > root but sometimes needs to make use of or work with a filesystem > > image that has root at real uid 0. > > > > The mechanism is to allow any subordinate mount namespace to mount > > a shiftfs filesystem (by marking it FS_USERNS_MOUNT) but only > > allowing it to mount marked subtrees (using the -o mark option as > > root). Once mounted, the subtree is mapped via the super block > > user namespace so that the interior ids of the mounting user > > namespace are the ids written to the filesystem. > > Please move this into VFS instead of a stackable fs. We might need > addtional parameters to getattr/setattr to specify the ID > translation, but that's why better than a horrible hack like this. I would need a lot more than that: getattr controls the cosmetic permission display to the user, but enforcement is done in the core permission checks which are inode based. To make this a real bind mount, the core permission checks will have to become subtree aware because knowledge of whether we need a uid shift in the permission check becomes a subtree property. Effectively inode_permission would become dentry_permission and generic_permission would take a dentry instead of an inode. This will be a huge amount of VFS and underlying filesystem churn, since the permissions calls are threaded through a huge chunk of code. Is this the approach that you really want? I suppose I could see the security people linking it because all the security hooks in the permission code become path aware. James