Commit c591d1c5 authored by Nathan Scott's avatar Nathan Scott Committed by Linus Torvalds

[PATCH] xattr updates (minor, 1/4)

This first patch fixes the copying in of extended attribute
names from userspace in the extended attribute syscalls (a
problem found when using electric fence on the user tools).

Nathan
parent 887ea10a
...@@ -67,9 +67,11 @@ setxattr(struct dentry *d, char *name, void *value, size_t size, int flags) ...@@ -67,9 +67,11 @@ setxattr(struct dentry *d, char *name, void *value, size_t size, int flags)
if (flags & ~(XATTR_CREATE|XATTR_REPLACE)) if (flags & ~(XATTR_CREATE|XATTR_REPLACE))
return -EINVAL; return -EINVAL;
if (copy_from_user(kname, name, XATTR_NAME_MAX)) error = strncpy_from_user(kname, name, sizeof(kname));
return -EFAULT; if (error == 0 || error == sizeof(kname))
kname[XATTR_NAME_MAX] = '\0'; error = -ERANGE;
if (error < 0)
return error;
kvalue = xattr_alloc(size, XATTR_SIZE_MAX); kvalue = xattr_alloc(size, XATTR_SIZE_MAX);
if (IS_ERR(kvalue)) if (IS_ERR(kvalue))
...@@ -143,9 +145,11 @@ getxattr(struct dentry *d, char *name, void *value, size_t size) ...@@ -143,9 +145,11 @@ getxattr(struct dentry *d, char *name, void *value, size_t size)
void *kvalue; void *kvalue;
char kname[XATTR_NAME_MAX + 1]; char kname[XATTR_NAME_MAX + 1];
if (copy_from_user(kname, name, XATTR_NAME_MAX)) error = strncpy_from_user(kname, name, sizeof(kname));
return -EFAULT; if (error == 0 || error == sizeof(kname))
kname[XATTR_NAME_MAX] = '\0'; error = -ERANGE;
if (error < 0)
return error;
kvalue = xattr_alloc(size, XATTR_SIZE_MAX); kvalue = xattr_alloc(size, XATTR_SIZE_MAX);
if (IS_ERR(kvalue)) if (IS_ERR(kvalue))
...@@ -285,9 +289,11 @@ removexattr(struct dentry *d, char *name) ...@@ -285,9 +289,11 @@ removexattr(struct dentry *d, char *name)
int error; int error;
char kname[XATTR_NAME_MAX + 1]; char kname[XATTR_NAME_MAX + 1];
if (copy_from_user(kname, name, XATTR_NAME_MAX)) error = strncpy_from_user(kname, name, sizeof(kname));
return -EFAULT; if (error == 0 || error == sizeof(kname))
kname[XATTR_NAME_MAX] = '\0'; error = -ERANGE;
if (error < 0)
return error;
error = -EOPNOTSUPP; error = -EOPNOTSUPP;
if (d->d_inode->i_op && d->d_inode->i_op->removexattr) { if (d->d_inode->i_op && d->d_inode->i_op->removexattr) {
......
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