]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
ext4: fix xattr shifting when expanding inodes
authorJan Kara <jack@suse.cz>
Thu, 11 Aug 2016 15:50:30 +0000 (11:50 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Aug 2016 15:50:30 +0000 (11:50 -0400)
commitd0141191a20289f8955c1e03dad08e42e6f71ca9
tree07f9a745bb20947ff3625d2a9ca71d7ae21dc492
parent829fa70dddadf9dd041d62b82cd7cea63943899d
ext4: fix xattr shifting when expanding inodes

The code in ext4_expand_extra_isize_ea() treated new_extra_isize
argument sometimes as the desired target i_extra_isize and sometimes as
the amount by which we need to grow current i_extra_isize. These happen
to coincide when i_extra_isize is 0 which used to be the common case and
so nobody noticed this until recently when we added i_projid to the
inode and so i_extra_isize now needs to grow from 28 to 32 bytes.

The result of these bugs was that we sometimes unnecessarily decided to
move xattrs out of inode even if there was enough space and we often
ended up corrupting in-inode xattrs because arguments to
ext4_xattr_shift_entries() were just wrong. This could demonstrate
itself as BUG_ON in ext4_xattr_shift_entries() triggering.

Fix the problem by introducing new isize_diff variable and use it where
appropriate.

CC: stable@vger.kernel.org # 4.4.x
Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/xattr.c