ext4: don't read out of bounds when checking for in-inode xattrs
authorEric Biggers <ebiggers@google.com>
Thu, 1 Dec 2016 19:51:58 +0000 (14:51 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 1 Dec 2016 19:51:58 +0000 (14:51 -0500)
commit290ab230016f187c3551d8380ea742889276d03a
tree051138c85bb6f7d8ac52513ecfb510832cee9220
parent2dc8d9e19b0d891b0d3675b5ac82be9be3875e36
ext4: don't read out of bounds when checking for in-inode xattrs

With i_extra_isize equal to or close to the available space, it was
possible for us to read past the end of the inode when trying to detect
or validate in-inode xattrs.  Fix this by checking for the needed extra
space first.

This patch shouldn't have any noticeable effect on
non-corrupted/non-malicious filesystems.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
fs/ext4/inode.c
fs/ext4/xattr.c