From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754134AbbCBWZd (ORCPT ); Mon, 2 Mar 2015 17:25:33 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44879 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753097AbbCBWZc (ORCPT ); Mon, 2 Mar 2015 17:25:32 -0500 Date: Mon, 2 Mar 2015 14:25:31 -0800 From: Andrew Morton To: Fabian Frederick Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2 linux-next] FS/HFSPLUS: move xattr_name allocation in hfsplus_setxattr() Message-Id: <20150302142531.038da6eafe388aa96a83f1a3@linux-foundation.org> In-Reply-To: <1425058706-11113-1-git-send-email-fabf@skynet.be> References: <1425058706-11113-1-git-send-email-fabf@skynet.be> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 27 Feb 2015 18:38:26 +0100 Fabian Frederick wrote: > security/trusted/user/osx setxattr did the same > xattr_name initialization. Move that operation in hfsplus_setxattr(). > > Tested with security/trusted/user getfattr/setfattr > > --- a/fs/hfsplus/xattr.c > +++ b/fs/hfsplus/xattr.c > @@ -424,6 +424,28 @@ static int copy_name(char *buffer, const char *xattr_name, int name_len) > return len; > } > > +int hfsplus_setxattr(struct dentry *dentry, const char *name, > + const void *value, size_t size, int flags, > + const char *prefix, size_t prefixlen) > +{ > + char *xattr_name; > + int res; > + > + if (!strcmp(name, "")) > + return -EINVAL; > + > + xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, > + GFP_KERNEL); > + if (!xattr_name) > + return -ENOMEM; > + strcpy(xattr_name, prefix); > + strcpy(xattr_name + prefixlen, name); Can we use kasprintf(GFP_KERNEL, "%s%s", prefix, name) and zap `prefixlen'? > + res = __hfsplus_setxattr(dentry->d_inode, xattr_name, value, size, > + flags); > + kfree(xattr_name); > + return res; > +}