Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp935515pxx; Thu, 29 Oct 2020 19:19:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0ltgDggMdAxzklbsiXXZ9N//bhBSm4fCAeNwpgap0h/8IQk0LwkGLZg5FE8g5NcMhDhHU X-Received: by 2002:a17:906:fb86:: with SMTP id lr6mr298671ejb.510.1604024368995; Thu, 29 Oct 2020 19:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604024368; cv=none; d=google.com; s=arc-20160816; b=BiRUgDwvAmzEfUrM32AJi3u/uOJ46TeGuH7nAa3CFtOqpsVjro45reiXj9vOEnzDLB 2SRH3uJrmolvpFBDQIpqmJd5+XLx/snQ/LHfX44f+O8uKSum2wt2SyXDSoWkdA+eYUmW s0CdomO/zvcvQKYe6BEhAvkIc849ig5jIc/lgce0iQDSh+UG/m9wRgDtGk7RQtz5kGfc rUA/hNKZkeNDmWPhBEw3cu8VjBIny1qrZrMxagL0ZagK8byvTgNhtNyzTk5UL1ysuMBa NjpqrQ3hfnvDPFlvvfUFLXzyj3T3/GO4FhWF1qoQ4ncqm9ibOnn4qV5Knth8IAdMyEn1 jGkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=hNvtYcFZkamkhZLf+F3Rv+SYwzt3iwquAlS+jHpkVgQ=; b=ImB+NGRfMl3vYprBnNxNGiMF3SVcBZs+7fbEEwFnad0dfw4gHmuKub1gHA2Cgukg/F W8HKAgmpq6+/zjp7zHj3v2jxp1YHbq26DmxZFQVl8fMG/13EX53wbEe2SVQd0BSEV9id LdSqfTDjgNDBGAq80V1qrWyePU/GfX5XJJgWSUuQzwgAgvoDW+/6FLj+8yZ1ac8DW0A7 1BiUJoPFNlc0REN0G9fqROEX3gPXiDtSdZcwb7Nwnk7Ctqf1/mIvZS4pKM21zFOdABzQ Wb637ZaeO6ZV58/xi/rLu3ipHYovjMC+UBFGR9zKGMt/O42f8jxinw2AwkjiCv266jX/ n7tw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si3055238eja.345.2020.10.29.19.19.02; Thu, 29 Oct 2020 19:19:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725815AbgJ3CSJ (ORCPT + 99 others); Thu, 29 Oct 2020 22:18:09 -0400 Received: from mail.hallyn.com ([178.63.66.53]:38118 "EHLO mail.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgJ3CSJ (ORCPT ); Thu, 29 Oct 2020 22:18:09 -0400 Received: by mail.hallyn.com (Postfix, from userid 1001) id 027D69B4; Thu, 29 Oct 2020 21:18:05 -0500 (CDT) Date: Thu, 29 Oct 2020 21:18:05 -0500 From: "Serge E. Hallyn" To: "Eric W. Biederman" Cc: Aleksa Sarai , Christian Brauner , 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 , Amir Goldstein , Miklos Szeredi , Theodore Tso , Alban Crequy , Tycho Andersen , David Howells , James Bottomley , Jann Horn , Seth Forshee , =?iso-8859-1?Q?St=E9phane?= Graber , Lennart Poettering , smbarber@chromium.org, Phil Estes , Serge Hallyn , Kees Cook , Todd Kjos , Jonathan Corbet , containers@lists.linux-foundation.org, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-audit@redhat.com, linux-integrity@vger.kernel.org, selinux@vger.kernel.org Subject: Re: [PATCH 00/34] fs: idmapped mounts Message-ID: <20201030021805.GA20489@mail.hallyn.com> References: <20201029003252.2128653-1-christian.brauner@ubuntu.com> <87pn51ghju.fsf@x220.int.ebiederm.org> <20201029155148.5odu4j2kt62ahcxq@yavin.dot.cyphar.com> <87361xdm4c.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87361xdm4c.fsf@x220.int.ebiederm.org> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Oct 29, 2020 at 11:37:23AM -0500, Eric W. Biederman wrote: > Aleksa Sarai writes: > > > On 2020-10-29, Eric W. Biederman wrote: > >> Christian Brauner writes: > >> > >> > Hey everyone, > >> > > >> > I vanished for a little while to focus on this work here so sorry for > >> > not being available by mail for a while. > >> > > >> > Since quite a long time we have issues with sharing mounts between > >> > multiple unprivileged containers with different id mappings, sharing a > >> > rootfs between multiple containers with different id mappings, and also > >> > sharing regular directories and filesystems between users with different > >> > uids and gids. The latter use-cases have become even more important with > >> > the availability and adoption of systemd-homed (cf. [1]) to implement > >> > portable home directories. > >> > >> Can you walk us through the motivating use case? > >> > >> As of this year's LPC I had the distinct impression that the primary use > >> case for such a feature was due to the RLIMIT_NPROC problem where two > >> containers with the same users still wanted different uid mappings to > >> the disk because the users were conflicting with each other because of > >> the per user rlimits. > >> > >> Fixing rlimits is straight forward to implement, and easier to manage > >> for implementations and administrators. > > > > This is separate to the question of "isolated user namespaces" and > > managing different mappings between containers. This patchset is solving > > the same problem that shiftfs solved -- sharing a single directory tree > > between containers that have different ID mappings. rlimits (nor any of > > the other proposals we discussed at LPC) will help with this problem. > > First and foremost: A uid shift on write to a filesystem is a security > bug waiting to happen. This is especially in the context of facilities > like iouring, that play very agressive games with how process context > makes it to system calls. > > The only reason containers were not immediately exploitable when iouring > was introduced is because the mechanisms are built so that even if > something escapes containment the security properties still apply. > Changes to the uid when writing to the filesystem does not have that > property. The tiniest slip in containment will be a security issue. > > This is not even the least bit theoretical. I have seem reports of how > shitfs+overlayfs created a situation where anyone could read > /etc/shadow. > > If you are going to write using the same uid to disk from different > containers the question becomes why can't those containers configure > those users to use the same kuid? Because if user 'myapp' in two otherwise isolated containers both have the same kuid, so that they can write to a shared directory, then root in container 1 has privilege over all files owned by 'myapp' in container 2. Whereas if they can each have distinct kuids, but when writing to the shared fs have a shared uid not otherwise belonging to either container, their rootfs's can remain completely off limits to each other. > What fixing rlimits does is it fixes one of the reasons that different > containers could not share the same kuid for users that want to write to > disk with the same uid. > > > I humbly suggest that it will be more secure, and easier to maintain for > both developers and users if we fix the reasons people want different > containers to have the same user running with different kuids. > > If not what are the reasons we fundamentally need the same on-disk user > using multiple kuids in the kernel? > > Eric