linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: Stephen Smalley <sds@tycho.nsa.gov>,
	ebiederm@xmission.com, containers@lists.linux-foundation.org
Cc: lkp@01.org, xiaolong.ye@intel.com, linux-kernel@vger.kernel.org,
	zohar@linux.vnet.ibm.com, serge@hallyn.com, tycho@docker.com,
	James.Bottomley@HansenPartnership.com,
	christian.brauner@mailbox.org, vgoyal@redhat.com,
	amir73il@gmail.com, linux-security-module@vger.kernel.org,
	Paul Moore <paul@paul-moore.com>,
	selinux@tycho.nsa.gov
Subject: Re: [PATCH 3/3] Enable security.selinux in user namespaces
Date: Fri, 23 Jun 2017 19:41:52 -0400	[thread overview]
Message-ID: <f477e588-a557-65ae-13db-8e8a87955b7f@linux.vnet.ibm.com> (raw)
In-Reply-To: <1498249800.2063.9.camel@tycho.nsa.gov>

On 06/23/2017 04:30 PM, Stephen Smalley wrote:
> On Thu, 2017-06-22 at 14:59 -0400, Stefan Berger wrote:
>> Before the current modifications, SELinux extended attributes were
>> visible inside the user namespace but changes in patch 1 hid them.
>> This patch enables security.selinux in user namespaces and allows
>> them to be written to in the same way as security.capability.
>>
>> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
>> ---
>>   fs/xattr.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/fs/xattr.c b/fs/xattr.c
>> index 045be85..37686ee 100644
>> --- a/fs/xattr.c
>> +++ b/fs/xattr.c
>> @@ -138,6 +138,7 @@ xattr_permission(struct inode *inode, const char
>> *name, int mask)
>>    */
>>   static const char *const userns_xattrs[] = {
>>   	XATTR_NAME_CAPS,
>> +	XATTR_NAME_SELINUX,
>>   	NULL
>>   };
>>   
> (cc SELinux maintainers, curiously omitted from these patches)
>
> I don't think this works for SELinux. You don't deal with actually
> supporting multiple security.selinux attributes within SELinux itself
> (and I'm not asking you to do so), and without such support, this can't
> operate as intended. With these patches applied, IIUC, a setxattr() of
> security.selinux within a userns will end up setting only security.seli
> nux@uid=1000 on disk, but will then tell SELinux to update its in-core
> security label to the new value (via security_inode_post_setxattr).
> Meanwhile, on a subsequent getxattr(), you'll call
> security_inode_getsecurity() with the security.selinux@uid=1000 name,
> which will always fail because SELinux doesn't know anything about your
> new scheme, and then you'll call the filesystem handler and returns its
> value, which is no longer connected in any way to the actual label
> being used by SELinux.  Also, SELinux itself makes calls to
> __vfs_getxattr() and __vfs_setxattr_noperm(), and I don't think your
> name remapping is correct in those cases.
>
> You also can't hide security.selinux within user namespaces.  Today
> userspace can get and set security.selinux attributes within user
> namespaces (if allowed by policy), and further can specify the label to
> use for new files via /proc/self/attr/fscreate, which unsurprisingly
> isn't addressed by your changes.  Changing that would be a userspace
> break.

I modified the 1st patch now in such a way that only security.capability 
is rewritten, security.selinux and all other ones remain untouched.

https://github.com/stefanberger/linux/commits/xattr_for_userns.v2

    Stefan

  reply	other threads:[~2017-06-23 23:42 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-22 18:59 [PATCH 0/3] Enable namespaced file capabilities Stefan Berger
2017-06-22 18:59 ` [PATCH 1/3] xattr: Enable security.capability in user namespaces Stefan Berger
2017-06-24 21:02   ` kbuild test robot
2017-06-24 21:02   ` [PATCH] xattr: fix kstrdup.cocci warnings kbuild test robot
2017-06-22 18:59 ` [PATCH 2/3] Enable capabilities of files from shared filesystem Stefan Berger
2017-06-22 18:59 ` [PATCH 3/3] Enable security.selinux in user namespaces Stefan Berger
2017-06-23 20:30   ` Stephen Smalley
2017-06-23 23:41     ` Stefan Berger [this message]
2017-06-22 19:59 ` [PATCH 0/3] Enable namespaced file capabilities Casey Schaufler
2017-06-22 20:12   ` Stefan Berger
2017-06-22 20:33     ` Casey Schaufler
2017-06-22 21:03       ` Stefan Berger
2017-06-22 21:09       ` Serge E. Hallyn
2017-06-22 22:40         ` Casey Schaufler
2017-06-22 23:07           ` Serge E. Hallyn
2017-06-22 23:29 ` James Bottomley
2017-06-22 23:32   ` Serge E. Hallyn
2017-06-22 23:36   ` Serge E. Hallyn
2017-06-23  0:13     ` James Bottomley
2017-06-23  1:19       ` Serge E. Hallyn
2017-06-23 17:37       ` Eric W. Biederman
2017-06-23 18:39         ` Serge E. Hallyn
2017-06-23  7:01 ` Amir Goldstein
2017-06-23 16:00   ` Serge E. Hallyn
2017-06-23 16:16     ` Casey Schaufler
2017-06-23 16:30       ` Serge E. Hallyn
2017-06-23 16:53         ` Casey Schaufler
2017-06-23 17:01           ` Serge E. Hallyn
2017-06-23 17:49             ` Eric W. Biederman
2017-06-23 18:32               ` Serge E. Hallyn
2017-06-23 17:07         ` James Bottomley
2017-06-23 17:20           ` Serge E. Hallyn
2017-06-23 17:38           ` Stefan Berger
2017-06-23 18:34             ` Serge E. Hallyn
2017-06-23 18:08       ` Stefan Berger
2017-06-23 18:35         ` Serge E. Hallyn
2017-06-23 20:30           ` Casey Schaufler
2017-06-23 23:09           ` Stefan Berger
2017-06-23 23:51             ` Casey Schaufler
2017-06-28  5:41   ` Serge E. Hallyn
2017-06-28  7:18     ` Amir Goldstein
2017-06-28 14:04       ` Stefan Berger
2017-06-28 14:28       ` Serge E. Hallyn
2017-06-23 20:09 ` Vivek Goyal
2017-06-23 20:17   ` Serge E. Hallyn
2017-06-23 20:36     ` Vivek Goyal
2017-06-23 20:51       ` Serge E. Hallyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f477e588-a557-65ae-13db-8e8a87955b7f@linux.vnet.ibm.com \
    --to=stefanb@linux.vnet.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=amir73il@gmail.com \
    --cc=christian.brauner@mailbox.org \
    --cc=containers@lists.linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=lkp@01.org \
    --cc=paul@paul-moore.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=serge@hallyn.com \
    --cc=tycho@docker.com \
    --cc=vgoyal@redhat.com \
    --cc=xiaolong.ye@intel.com \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).