From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Suchanek Subject: Re: [PATCH] tmpfs: implement generic xattr support Date: Thu, 21 Apr 2011 08:59:54 +0200 Message-ID: References: <4DA4B6A8.7030804@gmail.com> <87tydu3t4p.fsf_-_@tucsk.pomaz.szeredi.hu> <87tydtm41s.fsf@tucsk.pomaz.szeredi.hu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Phillip Lougher , Andreas Dilger , Jiri Kosina , Ric Wheeler , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, David Howells , Ian Kent , Jeff Moyer , Christoph Hellwig , Hugh Dickins , Eric Paris To: Miklos Szeredi Return-path: In-Reply-To: <87tydtm41s.fsf@tucsk.pomaz.szeredi.hu> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On 20 April 2011 15:43, Miklos Szeredi wrote: > Phillip Lougher writes: > >> On Tue, Apr 19, 2011 at 9:04 PM, Miklos Szeredi = wrote: >> >>> +static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer= , size_t size) >> >>> + =C2=A0 =C2=A0 =C2=A0 spin_lock(&dentry->d_inode->i_lock); >>> + =C2=A0 =C2=A0 =C2=A0 list_for_each_entry(xattr, &info->xattr_list= , list) { >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* skip "trusted= =2E" attributes for unprivileged callers */ >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!trusted && = xattr_is_trusted(xattr->name)) >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 continue; >>> + >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 used +=3D strlen= (xattr->name) + 1; >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (buffer) { >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 if (size < used) { >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 used =3D -ERANGE; >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break; >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 } >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 strncpy(buffer, xattr->name, strlen(xattr->name) + 1); >>>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0buffer +=3D strlen(xattr->name) + 1; >> >> Why are you doing a strncpy here? =C2=A0strcpy() isn't going to copy= more >> than strlen(xattr->name) + 1 bytes, and you know buffer is large >> enough to hold that because of the previous if (size < used) check? >> >> If you assigned the first strlen(xattr->name) + 1 to a temporary >> variable, you could use memcpy here, and avoid the 3 repeated >> strlen(xattr->name) calls. > > Yeah, makes sense. > Can you put up a branch with both overlayfs and xattrs? I would like to point people at a repo with working implementation and mirroring the kernel tree to add one patch is a bit overkill. Thanks Michal