git: 5c50e93e6ce4 - stable/13 - ext2fs: check for eh_depth in ext4_ext_check_header()

From: Neel Chauhan <nc_at_FreeBSD.org>
Date: Mon, 29 Nov 2021 17:56:51 UTC
The branch stable/13 has been updated by nc (ports committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=5c50e93e6ce43e8558e043de0745bad889c3a77f

commit 5c50e93e6ce43e8558e043de0745bad889c3a77f
Author:     Neel Chauhan <nc@FreeBSD.org>
AuthorDate: 2021-11-17 00:25:04 +0000
Commit:     Neel Chauhan <nc@FreeBSD.org>
CommitDate: 2021-11-29 17:56:42 +0000

    ext2fs: check for eh_depth in ext4_ext_check_header()
    
    PR:                     259112
    Reported by:            Robert Morris <rtm@lcs.mit.edu>
    Reviewed by:            fsu (src)
    Differential Revision:  https://reviews.freebsd.org/D33030
    
    (cherry picked from commit be60d8f276fa20fc11ad814e54c9c2540f79c7da)
---
 sys/fs/ext2fs/ext2_extents.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/fs/ext2fs/ext2_extents.c b/sys/fs/ext2fs/ext2_extents.c
index 1a5dca66dd76..b33ff9fa8a1a 100644
--- a/sys/fs/ext2fs/ext2_extents.c
+++ b/sys/fs/ext2fs/ext2_extents.c
@@ -251,6 +251,10 @@ ext4_ext_check_header(struct inode *ip, struct ext4_extent_header *eh)
 		error_msg = "header: invalid eh_entries";
 		goto corrupted;
 	}
+	if (eh->eh_depth > 5) {
+		error_msg = "header: invalid eh_depth";
+		goto corrupted;
+	}
 
 	return (0);