Commit a6d3c332 authored by Martin Brandenburg's avatar Martin Brandenburg Committed by Greg Kroah-Hartman

orangefs: clean up oversize xattr validation

commit e675c5ec upstream.

Also don't check flags as this has been validated by the VFS already.

Fix an off-by-one error in the max size checking.

Stop logging just because userspace wants to write attributes which do
not fit.

This and the previous commit fix xfstests generic/020.
Signed-off-by: default avatarMartin Brandenburg <martin@omnibond.com>
Signed-off-by: default avatarMike Marshall <hubcap@omnibond.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7adb1503
...@@ -76,11 +76,8 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name, ...@@ -76,11 +76,8 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
if (S_ISLNK(inode->i_mode)) if (S_ISLNK(inode->i_mode))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN) { if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN)
gossip_err("Invalid key length (%d)\n",
(int)strlen(name));
return -EINVAL; return -EINVAL;
}
fsuid = from_kuid(&init_user_ns, current_fsuid()); fsuid = from_kuid(&init_user_ns, current_fsuid());
fsgid = from_kgid(&init_user_ns, current_fsgid()); fsgid = from_kgid(&init_user_ns, current_fsgid());
...@@ -172,6 +169,9 @@ static int orangefs_inode_removexattr(struct inode *inode, const char *name, ...@@ -172,6 +169,9 @@ static int orangefs_inode_removexattr(struct inode *inode, const char *name,
struct orangefs_kernel_op_s *new_op = NULL; struct orangefs_kernel_op_s *new_op = NULL;
int ret = -ENOMEM; int ret = -ENOMEM;
if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN)
return -EINVAL;
down_write(&orangefs_inode->xattr_sem); down_write(&orangefs_inode->xattr_sem);
new_op = op_alloc(ORANGEFS_VFS_OP_REMOVEXATTR); new_op = op_alloc(ORANGEFS_VFS_OP_REMOVEXATTR);
if (!new_op) if (!new_op)
...@@ -231,23 +231,13 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name, ...@@ -231,23 +231,13 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name,
"%s: name %s, buffer_size %zd\n", "%s: name %s, buffer_size %zd\n",
__func__, name, size); __func__, name, size);
if (size >= ORANGEFS_MAX_XATTR_VALUELEN || if (size > ORANGEFS_MAX_XATTR_VALUELEN)
flags < 0) { return -EINVAL;
gossip_err("orangefs_inode_setxattr: bogus values of size(%d), flags(%d)\n", if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN)
(int)size,
flags);
return -EINVAL; return -EINVAL;
}
internal_flag = convert_to_internal_xattr_flags(flags); internal_flag = convert_to_internal_xattr_flags(flags);
if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN) {
gossip_err
("orangefs_inode_setxattr: bogus key size (%d)\n",
(int)(strlen(name)));
return -EINVAL;
}
/* This is equivalent to a removexattr */ /* This is equivalent to a removexattr */
if (size == 0 && value == NULL) { if (size == 0 && value == NULL) {
gossip_debug(GOSSIP_XATTR_DEBUG, gossip_debug(GOSSIP_XATTR_DEBUG,
......
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