]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: don't perform lookups on zero-height btrees
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 26 Aug 2016 01:16:41 +0000 (11:16 +1000)
committerDave Chinner <david@fromorbit.com>
Fri, 26 Aug 2016 01:16:41 +0000 (11:16 +1000)
If the caller passes in a cursor to a zero-height btree (which is
impossible), we never set block to anything but NULL, which causes the
later dereference of it to crash.  Instead, just return -EFSCORRUPTED.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
libxfs/xfs_btree.c

index 8391078f34ef8d6ad7e454ccf71c444b34a99ab5..cb671f6541b673e6514629a0017f317badb76444 100644 (file)
@@ -1810,6 +1810,10 @@ xfs_btree_lookup(
 
        XFS_BTREE_STATS_INC(cur, lookup);
 
+       /* No such thing as a zero-level tree. */
+       if (cur->bc_nlevels == 0)
+               return -EFSCORRUPTED;
+
        block = NULL;
        keyno = 0;