Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752962AbdGMVRs (ORCPT ); Thu, 13 Jul 2017 17:17:48 -0400 Received: from h2.hallyn.com ([78.46.35.8]:37316 "EHLO h2.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751295AbdGMVRq (ORCPT ); Thu, 13 Jul 2017 17:17:46 -0400 Date: Thu, 13 Jul 2017 16:17:44 -0500 From: "Serge E. Hallyn" To: "Eric W. Biederman" Cc: Stefan Berger , "Theodore Ts'o" , "Serge E. Hallyn" , containers@lists.linux-foundation.org, lkp@01.org, linux-kernel@vger.kernel.org, zohar@linux.vnet.ibm.com, tycho@docker.com, James.Bottomley@HansenPartnership.com, vgoyal@redhat.com, christian.brauner@mailbox.org, amir73il@gmail.com, linux-security-module@vger.kernel.org, casey@schaufler-ca.com Subject: Re: [PATCH v2] xattr: Enable security.capability in user namespaces Message-ID: <20170713211744.GB6167@mail.hallyn.com> References: <1499785511-17192-2-git-send-email-stefanb@linux.vnet.ibm.com> <87mv89iy7q.fsf@xmission.com> <20170712170346.GA17974@mail.hallyn.com> <877ezdgsey.fsf@xmission.com> <74664cc8-bc3e-75d6-5892-f8934404349f@linux.vnet.ibm.com> <20170713011554.xwmrgkzfwnibvgcu@thunk.org> <87y3rscz9j.fsf@xmission.com> <20170713164012.brj2flnkaaks2oci@thunk.org> <29fdda5e-ed4a-bcda-e3cc-c06ab87973ce@linux.vnet.ibm.com> <8760ew9qyp.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8760ew9qyp.fsf@xmission.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1228 Lines: 22 Quoting Eric W. Biederman (ebiederm@xmission.com): > Stefan Berger writes: > If you don't care about the ownership of the files, and read only is > acceptable, and you still don't want to give these executables > capabilities in the initial user namespace. What you can do is > make everything owned by some non-zero uid including the security > capability. Call this non-zero uid image-root. > > When the container starts it creates two nested user namespaces first > with image-root mapped to 0. Then with the containers choice of uid > mapped to 0 image-root unmapped. This will ensure the capability > attributes work for all containers that share that root image. And it > ensures the file are read-only from the container. > > So I don't think there is ever a case where we would share a filesystem > image where we would need to set multiple security attributes on a file. Neat idea. In fact, you can take it a step further and still have the files be owned by valid uids in the containers. The parent ns just needs to have its *root* map to a common kuid not mapped into the child namespaces, but the files can be owned by another kuid which *is* mapped into the child containers.