From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934263AbcKIQtD (ORCPT ); Wed, 9 Nov 2016 11:49:03 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:47267 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754357AbcKIQtB (ORCPT ); Wed, 9 Nov 2016 11:49:01 -0500 Date: Wed, 9 Nov 2016 08:48:54 -0800 From: Christoph Hellwig To: David Graziano Cc: golbi@mat.uni.torun.pl, michal.wronski@gmail.com, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, sds@tycho.nsa.gov, seth.forshee@canonical.com, ebiederm@xmission.com, agruenba@redhat.com Subject: Re: [PATCH 1/1 V2] mqueue: Implment generic xattr support Message-ID: <20161109164854.GA27562@infradead.org> References: <1478551587-33892-1-git-send-email-david.graziano@rockwellcollins.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1478551587-33892-1-git-send-email-david.graziano@rockwellcollins.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +/* > + * Callback for security_inode_init_security() for acquiring xattrs. > + */ > +static int mqueue_initxattrs(struct inode *inode, > + const struct xattr *xattr_array, > + void *fs_info) > +{ > + struct mqueue_inode_info *info = MQUEUE_I(inode); > + const struct xattr *xattr; > + struct simple_xattr *new_xattr; > + size_t len; > + > + for (xattr = xattr_array; xattr->name != NULL; xattr++) { > + new_xattr = simple_xattr_alloc(xattr->value, xattr->value_len); > + if (!new_xattr) > + return -ENOMEM; > + len = strlen(xattr->name) + 1; > + new_xattr->name = kmalloc(XATTR_SECURITY_PREFIX_LEN + len, > + GFP_KERNEL); > + if (!new_xattr->name) { > + kfree(new_xattr); > + return -ENOMEM; > + } > + > + memcpy(new_xattr->name, XATTR_SECURITY_PREFIX, > + XATTR_SECURITY_PREFIX_LEN); > + memcpy(new_xattr->name + XATTR_SECURITY_PREFIX_LEN, > + xattr->name, len); > + > + simple_xattr_list_add(&info->xattrs, new_xattr); > + } > + > + return 0; > +} This is a 1:1 copy of the shmem code, we rally should consolidate it into a single place first, as people will want it for whatever virtual fs they care about sooner or later.