git: 8facf7082d49 - stable/12 - ext2fs: check for eh_depth in ext4_ext_check_header()

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

URL: https://cgit.FreeBSD.org/src/commit/?id=8facf7082d4973aedc30cdd8e90fbd33beb17d7f

commit 8facf7082d4973aedc30cdd8e90fbd33beb17d7f
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:57:12 +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 61c751e9af5e..ba95b8a6f3ae 100644
--- a/sys/fs/ext2fs/ext2_extents.c
+++ b/sys/fs/ext2fs/ext2_extents.c
@@ -250,6 +250,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);