[PATCH v2] ext4: validate extent root during fast commit replay
From: Jérémy Jean
Date: Sun Nov 08 2026 - 15:19:47 EST
Fast commit replay skips extent tree validation in ext4_iget(). The
replay code then reads and updates the extent root stored in i_data
without validating its header.
The root has space for four extents. A corrupt header with eh_entries
set to 4 and eh_max set to 5 lets replay insert a fifth extent past
the end of i_data, which overwrites other fields in struct
ext4_inode_info.
Check the root in ext4_find_extent() during fast commit replay. Apply
the check even when EXT4_INODE_EXTENTS is clear, because replay can
call this function for an inode without that flag.
Fixes: 8016e29f4362 ("ext4: fast commit recovery path")
Cc: stable@xxxxxxxxxx
Signed-off-by: Jérémy Jean <Jeremy.Jean@xxxxxxxxxxxxxxxxx>
---
Changes in v2:
- Validate replay roots regardless of EXT4_INODE_EXTENTS.
- Rebase on fa4ad798f6f6.
v1: https://lore.kernel.org/all/20260821100559.3612643-2-Jeremy.Jean@xxxxxxxxxxxxxxxxx/
Sashiko: https://sashiko.dev/#/patchset/20260821100559.3612643-2-Jeremy.Jean@xxxxxxxxxxxxxxxxx
fs/ext4/extents.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index ad0d80e33f609..04268ed26711f 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -905,6 +905,12 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
ret = -EFSCORRUPTED;
goto err;
}
+ /* ext4_iget() skips extent validation during fast commit replay. */
+ if (unlikely(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)) {
+ ret = ext4_ext_check(inode, eh, depth, 0);
+ if (ret)
+ goto err;
+ }
if (path) {
ext4_ext_drop_refs(path);
--
2.47.3