Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932627AbdGLArT (ORCPT ); Tue, 11 Jul 2017 20:47:19 -0400 Received: from h2.hallyn.com ([78.46.35.8]:55480 "EHLO h2.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932365AbdGLArR (ORCPT ); Tue, 11 Jul 2017 20:47:17 -0400 Date: Tue, 11 Jul 2017 19:47:15 -0500 From: "Serge E. Hallyn" To: Stefan Berger Cc: "Serge E. Hallyn" , Stefan Berger , ebiederm@xmission.com, 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: <20170712004715.GC6436@mail.hallyn.com> References: <1499785511-17192-1-git-send-email-stefanb@linux.vnet.ibm.com> <1499785511-17192-2-git-send-email-stefanb@linux.vnet.ibm.com> <20170711171222.GB31603@mail.hallyn.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: 1477 Lines: 47 Quoting Stefan Berger (stefanb@linux.vnet.ibm.com): > On 07/11/2017 01:12 PM, Serge E. Hallyn wrote: > >>diff --git a/fs/xattr.c b/fs/xattr.c > >>index 464c94b..eacad9e 100644 > >>--- a/fs/xattr.c > >>+++ b/fs/xattr.c > >>@@ -133,20 +133,440 @@ xattr_permission(struct inode *inode, const char *name, int mask) > >> return inode_permission(inode, mask); > >> } > >>+/* > >>+ * A list of extended attributes that are supported in user namespaces > >>+ */ > >>+static const char *const userns_xattrs[] = { > >>+ XATTR_NAME_CAPS, > >>+ NULL > >>+}; > >>+ > >>+/* > >>+ * xattrs_is_userns_supported - Check whether an xattr is supported in userns > >>+ * > >>+ * @name: full name of the extended attribute > >>+ * @prefix: do a prefix match (true) or a full match (false) > >>+ * > >>+ * This function returns < 0 if not supported, an index into userns_xattrs[] > >>+ * otherwise. > >>+ */ > >>+static int > >>+xattr_is_userns_supported(const char *name, int prefix) > >>+{ > >>+ int i; > >>+ > >>+ if (!name) > >>+ return -1; > >>+ > >>+ for (i = 0; userns_xattrs[i]; i++) { > >>+ if (prefix) { > >>+ if (!strncmp(userns_xattrs[i], name, > >>+ strlen(userns_xattrs[i]))) > >>+ return i; > >I think you here need to also check that the next char is either > >'\0' or '.' (or maybe '@') > > I have the checks for '@' and '\0' done by the caller. With the > current support of only security.capability I don't think we need to > check for '.'. Ah - ok, thanks.