ext2: check xattr name_len before acquiring xattr_sem in ext2_xattr_get
In ext2_xattr_get(), the code will acquire xattr_sem first, later checks the length of xattr name_len > 255. It's unnecessarily time consuming and also ext2_xattr_set() checks the length before other checks. So move the check before acquiring xattr_sem to make these two functions consistent. Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
c878c73f8d
commit
03b5bb3429
|
@ -161,6 +161,10 @@ ext2_xattr_get(struct inode *inode, int name_index, const char *name,
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
name_len = strlen(name);
|
||||||
|
if (name_len > 255)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
down_read(&EXT2_I(inode)->xattr_sem);
|
down_read(&EXT2_I(inode)->xattr_sem);
|
||||||
error = -ENODATA;
|
error = -ENODATA;
|
||||||
if (!EXT2_I(inode)->i_file_acl)
|
if (!EXT2_I(inode)->i_file_acl)
|
||||||
|
@ -181,12 +185,8 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
|
||||||
error = -EIO;
|
error = -EIO;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
/* find named attribute */
|
|
||||||
name_len = strlen(name);
|
|
||||||
|
|
||||||
error = -ERANGE;
|
/* find named attribute */
|
||||||
if (name_len > 255)
|
|
||||||
goto cleanup;
|
|
||||||
entry = FIRST_ENTRY(bh);
|
entry = FIRST_ENTRY(bh);
|
||||||
while (!IS_LAST_ENTRY(entry)) {
|
while (!IS_LAST_ENTRY(entry)) {
|
||||||
struct ext2_xattr_entry *next =
|
struct ext2_xattr_entry *next =
|
||||||
|
|
Loading…
Reference in New Issue