aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2017-01-09 10:38:52 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-12 05:39:43 -0500
commit4bb31bccea381ebadf0e1bc4433026613c15ce68 (patch)
tree0485caecde31b9080b42a2e414d11c4f26f0d45a /fs
parentb85f32481d93a23488d208fca4558e84515dc0f4 (diff)
xfs: check for bogus values in btree block headers
commit bb3be7e7c1c18e1b141d4cadeb98cc89ecf78099 upstream. When we're reading a btree block, make sure that what we retrieved matches the owner and level; and has a plausible number of records. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_btree.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 0e80993c8a59..21e6a6ab6b9a 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -1769,8 +1769,28 @@ xfs_btree_lookup_get_block(
1769 if (error) 1769 if (error)
1770 return error; 1770 return error;
1771 1771
1772 /* Check the inode owner since the verifiers don't. */
1773 if (xfs_sb_version_hascrc(&cur->bc_mp->m_sb) &&
1774 (cur->bc_flags & XFS_BTREE_LONG_PTRS) &&
1775 be64_to_cpu((*blkp)->bb_u.l.bb_owner) !=
1776 cur->bc_private.b.ip->i_ino)
1777 goto out_bad;
1778
1779 /* Did we get the level we were looking for? */
1780 if (be16_to_cpu((*blkp)->bb_level) != level)
1781 goto out_bad;
1782
1783 /* Check that internal nodes have at least one record. */
1784 if (level != 0 && be16_to_cpu((*blkp)->bb_numrecs) == 0)
1785 goto out_bad;
1786
1772 xfs_btree_setbuf(cur, level, bp); 1787 xfs_btree_setbuf(cur, level, bp);
1773 return 0; 1788 return 0;
1789
1790out_bad:
1791 *blkp = NULL;
1792 xfs_trans_brelse(cur->bc_tp, bp);
1793 return -EFSCORRUPTED;
1774} 1794}
1775 1795
1776/* 1796/*