From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43038C433E6 for ; Thu, 14 Jan 2021 17:56:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D53423A57 for ; Thu, 14 Jan 2021 17:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729490AbhANRzm (ORCPT ); Thu, 14 Jan 2021 12:55:42 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:38811 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729326AbhANRzl (ORCPT ); Thu, 14 Jan 2021 12:55:41 -0500 Received: from ip5f5af0a0.dynamic.kabel-deutschland.de ([95.90.240.160] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l06pa-0006dG-Cq; Thu, 14 Jan 2021 17:54:46 +0000 Date: Thu, 14 Jan 2021 18:54:41 +0100 From: Christian Brauner To: "Darrick J. Wong" Cc: Alexander Viro , Christoph Hellwig , linux-fsdevel@vger.kernel.org, John Johansen , James Morris , Mimi Zohar , Dmitry Kasatkin , Stephen Smalley , Casey Schaufler , Arnd Bergmann , Andreas Dilger , OGAWA Hirofumi , Geoffrey Thomas , Mrunal Patel , Josh Triplett , Andy Lutomirski , Theodore Tso , Alban Crequy , Tycho Andersen , David Howells , James Bottomley , Seth Forshee , =?utf-8?B?U3TDqXBoYW5l?= Graber , Linus Torvalds , Aleksa Sarai , Lennart Poettering , "Eric W. Biederman" , smbarber@chromium.org, Phil Estes , Serge Hallyn , Kees Cook , Todd Kjos , Paul Moore , Jonathan Corbet , containers@lists.linux-foundation.org, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-integrity@vger.kernel.org, selinux@vger.kernel.org Subject: Re: [PATCH v5 00/42] idmapped mounts Message-ID: <20210114175441.v5cbtzad3ejjcjsw@wittgenstein> References: <20210112220124.837960-1-christian.brauner@ubuntu.com> <20210114171241.GA1164240@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210114171241.GA1164240@magnolia> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org On Thu, Jan 14, 2021 at 09:12:41AM -0800, Darrick J. Wong wrote: > On Tue, Jan 12, 2021 at 11:00:42PM +0100, Christian Brauner wrote: > > Hey everyone, > > > > The only major change is the inclusion of hch's patch to port XFS to > > support idmapped mounts. Thanks to Christoph for doing that work. > > Yay :) > > > (For a full list of major changes between versions see the end of this > > cover letter. > > Please also note the large xfstests testsuite in patch 42 that has been > > kept as part of this series. It verifies correct vfs behavior with and > > without idmapped mounts including covering newer vfs features such as > > io_uring. > > I currently still plan to target the v5.12 merge window.) > > > > With this patchset we make it possible to attach idmappings to mounts, > > i.e. simply put different bind mounts can expose the same file or > > directory with different ownership. > > Shifting of ownership on a per-mount basis handles a wide range of > > long standing use-cases. Here are just a few: > > - Shifting of a subset of ownership-less filesystems (vfat) for use by > > multiple users, effectively allowing for DAC on such devices > > (systemd, Android, ...) > > - Allow remapping uid/gid on external filesystems or paths (USB sticks, > > network filesystem, ...) to match the local system's user and groups. > > (David Howells intends to port AFS as a first candidate.) > > - Shifting of a container rootfs or base image without having to mangle > > every file (runc, Docker, containerd, k8s, LXD, systemd ...) > > - Sharing of data between host or privileged containers with > > unprivileged containers (runC, Docker, containerd, k8s, LXD, ...) > > - Data sharing between multiple user namespaces with incompatible maps > > (LXD, k8s, ...) > > That sounds neat. AFAICT, the VFS passes the filesystem a mount userns > structure, which is then carried down the call stack to whatever > functions actually care about mapping kernel [ug]ids to their ondisk > versions? Yes. This requires not too many changes to the actual filesystems as you can see from the xfs conversion that Christoph has done. > > Does quota still work after this patchset is applied? There isn't any > mention of that in the cover letter and I don't see a code patch, so > does that mean everything just works? I'm particularly curious about The most interesting quota codepaths I audited are dquot_transfer that transfers quota from one inode to another one during setattr. That happens via a struct iattr which will already contain correctly translated ia_uid and ia_gid values according to the mount the caller is coming from. I'll take another close look at that now and add tests for that if I can find some in xfstests. > whether there can exist processes with CAP_SYS_ADMIN and an idmapped > mount? Syscalls like bulkstat and quotactl present file [ug]ids to Yes, that should be possible. > programs, but afaict there won't be any translating going on? quotactl operates on the superblock. So the caller would need a mapping in the user namespace of the superblock. That doesn't need to change. But we could in the future extend this to be on a per-mount basis if this was a desired use-case. I don't think it needs to happen right now though. > > (To be fair, bulkstat is an xfs-only thing, but quota control isn't.) I'm certain we'll find more things to cover after the first version has landed. :) We for sure won't cover it all in the first iteration. > > I'll start skimming the patchset... Thanks! Christian