[PATCH] xfs: add bounds checking to xlog_recover_process_ophdr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make sure xlog_op_header don't stray beyond valid memory region.
Check if there is enough space for the fixed members of each
xlog_op_header before visiting.

Signed-off-by: lei lu <llfamsec@xxxxxxxxx>
---
 fs/xfs/xfs_log_recover.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 1251c81e55f9..660e79a07ce6 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2361,6 +2361,11 @@ xlog_recover_process_ophdr(
 	unsigned int		len;
 	int			error;
 
+	if (dp > end) {
+		xfs_warn(log->l_mp, "%s: op header overrun", __func__);
+		return -EFSCORRUPTED;
+	}
+
 	/* Do we understand who wrote this op? */
 	if (ohead->oh_clientid != XFS_TRANSACTION &&
 	    ohead->oh_clientid != XFS_LOG) {
@@ -2456,7 +2461,6 @@ xlog_recover_process_data(
 
 		ohead = (struct xlog_op_header *)dp;
 		dp += sizeof(*ohead);
-		ASSERT(dp <= end);
 
 		/* errors will abort recovery */
 		error = xlog_recover_process_ophdr(log, rhash, rhead, ohead,
-- 
2.34.1





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux