Skip to content

Commit 7e01c8e

Browse files
Tiger Yangtorvalds
authored andcommitted
ext3/4: fix uninitialized bs in ext3/4_xattr_set_handle()
This fix the uninitialized bs when we try to replace a xattr entry in ibody with the new value which require more than free space. This situation only happens we format ext3/4 with inode size more than 128 and we have put xattr entries both in ibody and block. The consequences about this bug is we will lost the xattr block which pointed by i_file_acl with all xattr entires in it. We will alloc a new xattr block and put that large value entry in it. The old xattr block will become orphan block. Signed-off-by: Tiger Yang <tiger.yang@oracle.com> Cc: <linux-ext4@vger.kernel.org> Cc: Andreas Gruenbacher <agruen@suse.de> Acked-by: Andreas Dilger <adilger@sun.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0c70814 commit 7e01c8e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

fs/ext3/xattr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,11 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
10001000
i.value = NULL;
10011001
error = ext3_xattr_block_set(handle, inode, &i, &bs);
10021002
} else if (error == -ENOSPC) {
1003+
if (EXT3_I(inode)->i_file_acl && !bs.s.base) {
1004+
error = ext3_xattr_block_find(inode, &i, &bs);
1005+
if (error)
1006+
goto cleanup;
1007+
}
10031008
error = ext3_xattr_block_set(handle, inode, &i, &bs);
10041009
if (error)
10051010
goto cleanup;

fs/ext4/xattr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,11 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
10091009
i.value = NULL;
10101010
error = ext4_xattr_block_set(handle, inode, &i, &bs);
10111011
} else if (error == -ENOSPC) {
1012+
if (EXT4_I(inode)->i_file_acl && !bs.s.base) {
1013+
error = ext4_xattr_block_find(inode, &i, &bs);
1014+
if (error)
1015+
goto cleanup;
1016+
}
10121017
error = ext4_xattr_block_set(handle, inode, &i, &bs);
10131018
if (error)
10141019
goto cleanup;

0 commit comments

Comments
 (0)