Update more fixes from crafted images
[ext4-patch-queue.git] / never-move-system.data-out-of-the-inode-body
blob58f6e96a65f7b0fb58f4b4afe6349ec436c38ddc
1 ext4: never move the system.data xattr out of the inode body
3 When expanding the extra isize space, we must never move the
4 system.data xattr out of the inode body.  For performance reasons, it
5 doesn't make any sense, and the inline data implementation assumes
6 that system.data xattr is never in the external xattr block.
8 https://bugzilla.kernel.org/show_bug.cgi?id=200005
10 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
11 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
12 index 0263692979ec..72377b77fbd7 100644
13 --- a/fs/ext4/xattr.c
14 +++ b/fs/ext4/xattr.c
15 @@ -2657,6 +2657,11 @@ static int ext4_xattr_make_inode_space(handle_t *handle, struct inode *inode,
16                 last = IFIRST(header);
17                 /* Find the entry best suited to be pushed into EA block */
18                 for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
19 +                       /* never move system.data out of the inode */
20 +                       if ((last->e_name_len == 4) &&
21 +                           (last->e_name_index == EXT4_XATTR_INDEX_SYSTEM) &&
22 +                           !memcmp(last->e_name, "data", 4))
23 +                               continue;
24                         total_size = EXT4_XATTR_LEN(last->e_name_len);
25                         if (!last->e_value_inum)
26                                 total_size += EXT4_XATTR_SIZE(