Commit 95baae33 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] getxattr error checking fix

From: Nathan Scott <nathans@sgi.com>,
      Andreas Gruenbacher <agruen@suse.de>

XFS regression tests tripped a couple of problems with the recent xattr fix.

When a size of 0 is passed in, the getxattr and listxattr syscalls return the
size that would be required for the value or list of names, without actually
returning the value.  The previous patch accidentally removed this test, and
so querying the required size broke.
parent 4243eb72
......@@ -140,7 +140,7 @@ getxattr(struct dentry *d, char __user *name, void __user *value, size_t size)
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 *list, size_t size)
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment