| To: | Dave Chinner <david@xxxxxxxxxxxxx> |
|---|---|
| Subject: | [PATCH] xfs: don't perform lookups on zero-height btrees |
| From: | "Darrick J. Wong" <darrick.wong@xxxxxxxxxx> |
| Date: | Fri, 19 Aug 2016 13:30:22 -0700 |
| Cc: | linux-xfs@xxxxxxxxxxxxxxx, xfs@xxxxxxxxxxx |
| Delivered-to: | xfs@xxxxxxxxxxx |
| User-agent: | Mutt/1.5.24 (2015-08-30) |
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@xxxxxxxxxx>
---
fs/xfs/libxfs/xfs_btree.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 64fd847..4bffea4 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -1814,6 +1814,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;
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCH 2/2] fstests: xfs EIO error handling test, Zorro Lang |
|---|---|
| Next by Date: | [PATCH] xfs: disallow mounting of realtime + rmap filesystems, Darrick J. Wong |
| Previous by Thread: | [PATCH 1/2] xfs/006: move code about resetting error handling to common/rc, Zorro Lang |
| Next by Thread: | Re: [PATCH] xfs: don't perform lookups on zero-height btrees, Brian Foster |
| Indexes: | [Date] [Thread] [Top] [All Lists] |