From mboxrd@z Thu Jan 1 00:00:00 1970 From: serge@hallyn.com (Serge E. Hallyn) Date: Thu, 5 Oct 2017 01:48:26 -0500 Subject: [PATCH] selinux: check CAP_SETFCAP for a particular inode & mapped user In-Reply-To: <20171005061611.6649-1-lkundrak@v3.sk> References: <20171005061611.6649-1-lkundrak@v3.sk> Message-ID: <20171005064826.GA11630@mail.hallyn.com> To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org On Thu, Oct 05, 2017 at 08:16:11AM +0200, Lubomir Rintel wrote: > This allows setting "security.capability" xattr by a user that has > CAP_SETFCAP in an userns with SELinux. Namespaced capabilities are > supported, as of commit 8db6c34f1dbc ("Introduce v3 namespaced file > capabilities"). > > Signed-off-by: Lubomir Rintel The fix is already on its way into the kernel - see the thread at https://marc.info/?l=selinux&m=150713903925728&w=2 Thanks though :) -serge > --- > A casual warning: Please not assume I know what I'm really doing. I can now > install iputils and /bin/ping in a LXC container, which is great, but I > typically wouldn't be allowed anywhere near anything security related. > > Thank you! > > security/selinux/hooks.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index f5d304736852..7bc5f4ffb4e0 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -3127,11 +3127,12 @@ static int selinux_inode_getattr(const struct path *path) > static int selinux_inode_setotherxattr(struct dentry *dentry, const char *name) > { > const struct cred *cred = current_cred(); > + struct inode *inode = d_backing_inode(dentry); > > if (!strncmp(name, XATTR_SECURITY_PREFIX, > sizeof XATTR_SECURITY_PREFIX - 1)) { > if (!strcmp(name, XATTR_NAME_CAPS)) { > - if (!capable(CAP_SETFCAP)) > + if (!capable_wrt_inode_uidgid(inode, CAP_SETFCAP)) > return -EPERM; > } else if (!capable(CAP_SYS_ADMIN)) { > /* A different attribute in the security namespace. > -- > 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751434AbdJEGs3 (ORCPT ); Thu, 5 Oct 2017 02:48:29 -0400 Received: from h2.hallyn.com ([78.46.35.8]:57406 "EHLO h2.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751273AbdJEGs2 (ORCPT ); Thu, 5 Oct 2017 02:48:28 -0400 Date: Thu, 5 Oct 2017 01:48:26 -0500 From: "Serge E. Hallyn" To: Lubomir Rintel Cc: linux-security-module@vger.kernel.org, "Serge E . Hallyn" , "Eric W . Biederman" , linux-kernel@vger.kernel.org, Paul Moore , Stephen Smalley , Eric Paris Subject: Re: [PATCH] selinux: check CAP_SETFCAP for a particular inode & mapped user Message-ID: <20171005064826.GA11630@mail.hallyn.com> References: <20171005061611.6649-1-lkundrak@v3.sk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171005061611.6649-1-lkundrak@v3.sk> 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 On Thu, Oct 05, 2017 at 08:16:11AM +0200, Lubomir Rintel wrote: > This allows setting "security.capability" xattr by a user that has > CAP_SETFCAP in an userns with SELinux. Namespaced capabilities are > supported, as of commit 8db6c34f1dbc ("Introduce v3 namespaced file > capabilities"). > > Signed-off-by: Lubomir Rintel The fix is already on its way into the kernel - see the thread at https://marc.info/?l=selinux&m=150713903925728&w=2 Thanks though :) -serge > --- > A casual warning: Please not assume I know what I'm really doing. I can now > install iputils and /bin/ping in a LXC container, which is great, but I > typically wouldn't be allowed anywhere near anything security related. > > Thank you! > > security/selinux/hooks.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index f5d304736852..7bc5f4ffb4e0 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -3127,11 +3127,12 @@ static int selinux_inode_getattr(const struct path *path) > static int selinux_inode_setotherxattr(struct dentry *dentry, const char *name) > { > const struct cred *cred = current_cred(); > + struct inode *inode = d_backing_inode(dentry); > > if (!strncmp(name, XATTR_SECURITY_PREFIX, > sizeof XATTR_SECURITY_PREFIX - 1)) { > if (!strcmp(name, XATTR_NAME_CAPS)) { > - if (!capable(CAP_SETFCAP)) > + if (!capable_wrt_inode_uidgid(inode, CAP_SETFCAP)) > return -EPERM; > } else if (!capable(CAP_SYS_ADMIN)) { > /* A different attribute in the security namespace. > -- > 2.13.6