[PATCH] ext4: Add validity checks for the casefold feature
From: Edward Adam Davis
Date: Mon Nov 30 2026 - 06:05:51 EST
The EXT4_FEATURE_INCOMPAT_CASEFOLD feature is not enabled during the file
system mount process; consequently, s_encoding is not loaded into the
superblock. When the EXT4_FEATURE_INCOMPAT_CASEFOLD feature is enabled via
EXT4_IOC_SET_TUNE_SB_PARAM, sb->s_encoding is not initialized.
After the EXT4_CASEFOLD_FL flag is set on a dir via ext4_ioctl_setflags(),
the lookup operation performed on that directory triggers a call to the
ext4_fname_setup_ci_filename() function. This function passes the NULL
value of dir->i_sb->s_encoding to utf8_casefold(), which subsequently leads
to a null-ptr-deref of um->tables within utf8nlookup().
Added validity checks related to casefold feature to prevent referencing
an uninitialized encoding.
Fixes: 04a91570ac67 ("ext4: implemet new ioctls to set and get superblock parameters")
Reported-by: syzbot+68178aa1e39c8606392e@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=68178aa1e39c8606392e
Signed-off-by: Edward Adam Davis <eadavis@xxxxxxxx>
---
fs/ext4/ioctl.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 83630cd40712..48d30c529490 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1464,7 +1464,10 @@ static int ext4_validate_tune_sb_params(struct super_block *sb,
(params->clear_feature_incompat_mask &
~EXT4_TUNE_CLEAR_INCOMPAT_SUPP) ||
(params->clear_feature_ro_compat_mask &
- ~EXT4_TUNE_CLEAR_RO_COMPAT_SUPP))
+ ~EXT4_TUNE_CLEAR_RO_COMPAT_SUPP) ||
+ (params->set_feature_incompat_mask &
+ EXT4_FEATURE_INCOMPAT_CASEFOLD &&
+ !sb->s_encoding))
return -EOPNOTSUPP;
/*
--
2.43.0