Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp532251ybv; Wed, 19 Feb 2020 04:28:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzdiXW6l2MhSVG7ItU0gp85e1Xy6543mxcqR7iaIMM5UgQoaz5Oih6YZuxrwpXw+zSsFSNe X-Received: by 2002:a05:6808:50:: with SMTP id v16mr4176370oic.133.1582115305895; Wed, 19 Feb 2020 04:28:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582115305; cv=none; d=google.com; s=arc-20160816; b=BbIW+oRfeNwEh19qzwTDcJL1XAbgX3jNqCAK24yft3Fko9t953dnFABOLUBgA/F3kZ 5n+rDVMN+xGMLxNU15/v3DdkkJzD2HD21I0IXE1EvrAzHHpVOPUTdxEhS5JFognWtplx lZoXJAnixmrcM5IWFR6CeCkyqkgGe3IQKD5I22bQWne7ebXltBglX+muPekdmZlFTs2t mZ0nMUlJee2Yt28mnrWgHPTSafb44q8dBiTHcQMViyPbBJpKJFAl44tEpl4yc682Rxiy TTjP83K3pqnNPgX/xaEoYRQECyUf2/mQgC1SBWGyIMYnOPuUpcX0hy07P7iHjNAtO5f4 D7Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=RCReAU96zwhxODFtBgK4YUbS1t2pp4JVLZj+SIErYnU=; b=q/2chdYjeaVlcjtepPdhzaGDaet+RWb33GnivSKJ1mvJoqDonzAWDklxAKrIVLlpdh eIKKVsloFeIbjSqazd7ZhXM1lsOkG/7IHtxF3RzgEwb3c028CDz8IZRl5l0I3vpIhPnc ZmSWgZ6lE3wiAn6xr83xSY8eDVvixFw422A8kbLgnMAfB1hgA27s4lfYKNxSbUYZ4qvn VKO9CEjHXcEaGXW/+XqdfNJib1Jk2+1SdrhBsz+mrOddDxfbDO0qLi8WFZhdRn/C59mI lk26GDGqIlV0IW80CKj8Rcuojmbcm/YSuJGi4KONqXSaDyG1ljnb3d923A+nmgcVxLPP cc4w== 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 f23si1001865oto.205.2020.02.19.04.28.12; Wed, 19 Feb 2020 04:28:25 -0800 (PST) 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 S1727082AbgBSM2I (ORCPT + 99 others); Wed, 19 Feb 2020 07:28:08 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:58298 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbgBSM2I (ORCPT ); Wed, 19 Feb 2020 07:28:08 -0500 Received: from ip5f5bf7ec.dynamic.kabel-deutschland.de ([95.91.247.236] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1j4OSH-0003l8-Ra; Wed, 19 Feb 2020 12:27:53 +0000 Date: Wed, 19 Feb 2020 13:27:52 +0100 From: Christian Brauner To: James Bottomley Cc: =?utf-8?B?U3TDqXBoYW5l?= Graber , "Eric W. Biederman" , Aleksa Sarai , Jann Horn , Kees Cook , Jonathan Corbet , linux-api@vger.kernel.org, containers@lists.linux-foundation.org, linux-kernel@vger.kernel.org, smbarber@chromium.org, Seth Forshee , linux-security-module@vger.kernel.org, Alexander Viro , linux-fsdevel@vger.kernel.org, Alexey Dobriyan Subject: Re: [PATCH v3 00/25] user_namespace: introduce fsid mappings Message-ID: <20200219122752.jalnsmsotigwxwsw@wittgenstein> References: <20200218143411.2389182-1-christian.brauner@ubuntu.com> <1582069856.16681.59.camel@HansenPartnership.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1582069856.16681.59.camel@HansenPartnership.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 18, 2020 at 03:50:56PM -0800, James Bottomley wrote: > On Tue, 2020-02-18 at 15:33 +0100, Christian Brauner wrote: > > In the usual case of running an unprivileged container we will have > > setup an id mapping, e.g. 0 100000 100000. The on-disk mapping will > > correspond to this id mapping, i.e. all files which we want to appear > > as 0:0 inside the user namespace will be chowned to 100000:100000 on > > the host. This works, because whenever the kernel needs to do a > > filesystem access it will lookup the corresponding uid and gid in the > > idmapping tables of the container. Now think about the case where we > > want to have an id mapping of 0 100000 100000 but an on-disk mapping > > of 0 300000 100000 which is needed to e.g. share a single on-disk > > mapping with multiple containers that all have different id mappings. > > This will be problematic. Whenever a filesystem access is requested, > > the kernel will now try to lookup a mapping for 300000 in the id > > mapping tables of the user namespace but since there is none the > > files will appear to be owned by the overflow id, i.e. usually > > 65534:65534 or nobody:nogroup. > > > > With fsid mappings we can solve this by writing an id mapping of 0 > > 100000 100000 and an fsid mapping of 0 300000 100000. On filesystem > > access the kernel will now lookup the mapping for 300000 in the fsid > > mapping tables of the user namespace. And since such a mapping > > exists, the corresponding files will have correct ownership. > > So I did compile this up in order to run the shiftfs tests over it to > see how it coped with the various corner cases. However, what I find > is it simply fails the fsid reverse mapping in the setup. Trying to > use a simple uid of 0 100000 1000 and a fsid of 100000 0 1000 fails the > entry setuid(0) call because of this code: This is easy to fix. But what's the exact use-case?