]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs: sanity check directory inode di_size
authorAmir Goldstein <amir73il@gmail.com>
Thu, 26 Jan 2017 02:02:41 +0000 (20:02 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 26 Jan 2017 02:02:41 +0000 (20:02 -0600)
commit3cfabff69732ab5407bba7e5d3079b7338d2bddb
tree4bbe21e29d6e8d0f2396a20510fc49acc198907f
parent29043c6ccd49ce852fb438f2c5147f6a7f80fa97
xfs: sanity check directory inode di_size

Source kernel commit: 3c6f46eacd876bd723a9bad3c6882714c052fd8e

This changes fixes an assertion hit when fuzzing on-disk
i_mode values.

The easy case to fix is when changing an empty file
i_mode to S_IFDIR. In this case, xfs_dinode_verify()
detects an illegal zero size for directory and fails
to load the inode structure from disk.

For the case of non empty file whose i_mode is changed
to S_IFDIR, the ASSERT() statement in xfs_dir2_isblock()
is replaced with return -EFSCORRUPTED, to avoid interacting
with corrupted jusk also when XFS_DEBUG is disabled.

Suggested-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_dir2.c
libxfs/xfs_inode_buf.c