diff options
author | Martin Brandenburg <martin@omnibond.com> | 2017-04-25 15:37:57 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-20 08:28:39 -0400 |
commit | 59f496104112ccea4e55ad10e248301460054cc8 (patch) | |
tree | 85c03a819856a257e73352bf2851dbbbaea1ae57 /fs | |
parent | 127adc188c62ffd3d3e78e1f057ab7669b37c10f (diff) |
orangefs: clean up oversize xattr validation
commit e675c5ec51fe2554719a7b6bcdbef0a770f2c19b 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: Martin Brandenburg <martin@omnibond.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/orangefs/xattr.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c index fba4db7d0512..237c9c04dc3b 100644 --- a/fs/orangefs/xattr.c +++ b/fs/orangefs/xattr.c | |||
@@ -76,11 +76,8 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name, | |||
76 | if (S_ISLNK(inode->i_mode)) | 76 | if (S_ISLNK(inode->i_mode)) |
77 | return -EOPNOTSUPP; | 77 | return -EOPNOTSUPP; |
78 | 78 | ||
79 | if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN) { | 79 | if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) |
80 | gossip_err("Invalid key length (%d)\n", | ||
81 | (int)strlen(name)); | ||
82 | return -EINVAL; | 80 | return -EINVAL; |
83 | } | ||
84 | 81 | ||
85 | fsuid = from_kuid(&init_user_ns, current_fsuid()); | 82 | fsuid = from_kuid(&init_user_ns, current_fsuid()); |
86 | fsgid = from_kgid(&init_user_ns, current_fsgid()); | 83 | fsgid = from_kgid(&init_user_ns, current_fsgid()); |
@@ -172,6 +169,9 @@ static int orangefs_inode_removexattr(struct inode *inode, const char *name, | |||
172 | struct orangefs_kernel_op_s *new_op = NULL; | 169 | struct orangefs_kernel_op_s *new_op = NULL; |
173 | int ret = -ENOMEM; | 170 | int ret = -ENOMEM; |
174 | 171 | ||
172 | if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) | ||
173 | return -EINVAL; | ||
174 | |||
175 | down_write(&orangefs_inode->xattr_sem); | 175 | down_write(&orangefs_inode->xattr_sem); |
176 | new_op = op_alloc(ORANGEFS_VFS_OP_REMOVEXATTR); | 176 | new_op = op_alloc(ORANGEFS_VFS_OP_REMOVEXATTR); |
177 | if (!new_op) | 177 | if (!new_op) |
@@ -231,23 +231,13 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name, | |||
231 | "%s: name %s, buffer_size %zd\n", | 231 | "%s: name %s, buffer_size %zd\n", |
232 | __func__, name, size); | 232 | __func__, name, size); |
233 | 233 | ||
234 | if (size >= ORANGEFS_MAX_XATTR_VALUELEN || | 234 | if (size > ORANGEFS_MAX_XATTR_VALUELEN) |
235 | flags < 0) { | 235 | return -EINVAL; |
236 | gossip_err("orangefs_inode_setxattr: bogus values of size(%d), flags(%d)\n", | 236 | if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) |
237 | (int)size, | ||
238 | flags); | ||
239 | return -EINVAL; | 237 | return -EINVAL; |
240 | } | ||
241 | 238 | ||
242 | internal_flag = convert_to_internal_xattr_flags(flags); | 239 | internal_flag = convert_to_internal_xattr_flags(flags); |
243 | 240 | ||
244 | if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN) { | ||
245 | gossip_err | ||
246 | ("orangefs_inode_setxattr: bogus key size (%d)\n", | ||
247 | (int)(strlen(name))); | ||
248 | return -EINVAL; | ||
249 | } | ||
250 | |||
251 | /* This is equivalent to a removexattr */ | 241 | /* This is equivalent to a removexattr */ |
252 | if (size == 0 && value == NULL) { | 242 | if (size == 0 && value == NULL) { |
253 | gossip_debug(GOSSIP_XATTR_DEBUG, | 243 | gossip_debug(GOSSIP_XATTR_DEBUG, |