[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211119081758.399167-1-zhangyue1@kylinos.cn>
Date: Fri, 19 Nov 2021 16:17:58 +0800
From: zhangyue <zhangyue1@...inos.cn>
To: darrick.wong@...cle.com, linux-xfs@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] xfs: fix the problem that the array may be out of bound
In function 'xfs_btree_delrec()', if all data in array
'cur->bc_ptrs[level]' is 0, the 'level' may be greater than
or equal to 'XFS_BTREE_MAXLEVELS'.
At this time, the array may be out of bound.
Signed-off-by: zhangyue <zhangyue1@...inos.cn>
---
fs/xfs/libxfs/xfs_btree.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index bbdae2b4559f..fe66d1adc169 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -3694,6 +3694,9 @@ xfs_btree_delrec(
tcur = NULL;
/* Get the index of the entry being deleted, check for nothing there. */
+ if (level >= XFS_BTREE_MAXLEVELS)
+ return -EFSCORRUPTED;
+
ptr = cur->bc_ptrs[level];
if (ptr == 0) {
*stat = 0;
--
2.30.0
Powered by blists - more mailing lists