Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754817AbdFWXJn (ORCPT ); Fri, 23 Jun 2017 19:09:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58329 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754118AbdFWXJk (ORCPT ); Fri, 23 Jun 2017 19:09:40 -0400 Subject: Re: [PATCH 0/3] Enable namespaced file capabilities To: "Serge E. Hallyn" References: <1498157989-11814-1-git-send-email-stefanb@linux.vnet.ibm.com> <20170623160026.GA18257@mail.hallyn.com> <3404c486-c848-3283-50f7-2283cb631e8e@linux.vnet.ibm.com> <20170623183520.GC21137@mail.hallyn.com> Cc: Casey Schaufler , Amir Goldstein , "Eric W. Biederman" , Linux Containers , lkp@01.org, xiaolong.ye@intel.com, linux-kernel , Mimi Zohar , Tycho Andersen , James Bottomley , christian.brauner@mailbox.org, Vivek Goyal , LSM List From: Stefan Berger Date: Fri, 23 Jun 2017 19:09:23 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170623183520.GC21137@mail.hallyn.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17062323-0028-0000-0000-000007E085C1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007279; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00878879; UDB=6.00437974; IPR=6.00659031; BA=6.00005438; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015946; XFM=3.00000015; UTC=2017-06-23 23:09:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17062323-0029-0000-0000-0000365CA106 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-23_15:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706230393 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2560 Lines: 50 On 06/23/2017 02:35 PM, Serge E. Hallyn wrote: > Quoting Stefan Berger (stefanb@linux.vnet.ibm.com): >> On 06/23/2017 12:16 PM, Casey Schaufler wrote: >>> On 6/23/2017 9:00 AM, Serge E. Hallyn wrote: >>>> Quoting Amir Goldstein (amir73il@gmail.com): >>>>> On Thu, Jun 22, 2017 at 9:59 PM, Stefan Berger >>>>> wrote: >>>>>> This series of patches primary goal is to enable file capabilities >>>>>> in user namespaces without affecting the file capabilities that are >>>>>> effective on the host. This is to prevent that any unprivileged user >>>>>> on the host maps his own uid to root in a private namespace, writes >>>>>> the xattr, and executes the file with privilege on the host. >>>>>> >>>>>> We achieve this goal by writing extended attributes with a different >>>>>> name when a user namespace is used. If for example the root user >>>>>> in a user namespace writes the security.capability xattr, the name >>>>>> of the xattr that is actually written is encoded as >>>>>> security.capability@uid=1000 for root mapped to uid 1000 on the host. >>>>>> When listing the xattrs on the host, the existing security.capability >>>>>> as well as the security.capability@uid=1000 will be shown. Inside the >>>>>> namespace only 'security.capability', with the value of >>>>>> security.capability@uid=1000, is visible. >>>>>> >>>>> Am I the only one who thinks that suffix is perhaps not the best grammar >>>>> to use for this namespace? >>>> You're the only one to have mentioned it so far. >>>> >>>>> xattrs are clearly namespaced by prefix, so it seems right to me to keep >>>>> it that way - define a new special xattr namespace "ns" and only if that >>>>> prefix exists, the @uid suffix will be parsed. >>>>> This could be either ns.security.capability@uid=1000 or >>>>> ns@uid=1000.security.capability. The latter seems more correct to me, >>>>> because then we will be able to namespace any xattr without having to >>>>> protect from "unprivileged xattr injection", i.e.: >>>>> setfattr -n "user.whatever.foo@uid=0" >>>> I like it for simplifying the parser code. One concern I have is that, >>>> since ns.* is currently not gated, one could write ns.* on an older >>>> kernel and then exploit it on a newer one. >>> security.ns.capability@uid=1000, then? >> Imo, '.ns' is redundant and 'encoded' in the '@'. > So how about > security.@uid=1000@@capability ? Ouch. > Maybe it's not worth it. So the .ns is there to be able to possibly extend it in another dimension in the future, like have '.foo' there at some point? >