Re: [BUG] With size > XATTR_SIZE_MAX, getxattr(2) always returnsE2BIG

From: Andreas Gruenbacher
Date: Sun Feb 08 2004 - 21:44:43 EST


On Mon, 2004-02-09 at 02:26, Nathan Scott wrote:
> On Tue, Feb 03, 2004 at 01:52:19PM +0100, Andreas Gruenbacher wrote:
> > Hello,
> >
> > here is a fix for the getxattr and listxattr syscall. Explanation in the
> > patch. Could you please apply? Thanks.
>
> Our regression tests tripped a couple of problems with this;
> here's a patch on top of yours (which is now 2.6.3-rc1).

Indeed, I got that case wrong. The patch looks correct. Thanks!

I would move the missing test right before the copy_to_user as below,
which is slightly better.


Index: linux-2.6.3-rc1.orig/fs/xattr.c
===================================================================
--- linux-2.6.3-rc1.orig.orig/fs/xattr.c
+++ linux-2.6.3-rc1.orig/fs/xattr.c
@@ -140,7 +140,7 @@ getxattr(struct dentry *d, char __user *
goto out;
error = d->d_inode->i_op->getxattr(d, kname, kvalue, size);
if (error > 0) {
- if (copy_to_user(value, kvalue, error))
+ if (size && copy_to_user(value, kvalue, error))
error = -EFAULT;
} else if (error == -ERANGE && size >= XATTR_SIZE_MAX) {
/* The file system tried to returned a value bigger
@@ -222,7 +222,7 @@ listxattr(struct dentry *d, char __user
goto out;
error = d->d_inode->i_op->listxattr(d, klist, size);
if (error > 0) {
- if (copy_to_user(list, klist, error))
+ if (size && copy_to_user(list, klist, error))
error = -EFAULT;
} else if (error == -ERANGE && size >= XATTR_LIST_MAX) {
/* The file system tried to returned a list bigger

> cheers.
--
Andreas Gruenbacher <agruen@xxxxxxx>
SUSE Labs, SUSE LINUX AG

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/