Kaynağa Gözat

xfs: don't perform lookups on zero-height btrees

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>
Darrick J. Wong 9 yıl önce
ebeveyn
işleme
ed150e1a5c
1 değiştirilmiş dosya ile 4 ekleme ve 0 silme
  1. 4 0
      fs/xfs/libxfs/xfs_btree.c

+ 4 - 0
fs/xfs/libxfs/xfs_btree.c

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