Re: [PATCH] ext4: Add validity checks for the casefold feature

From: Gabriel Krisman Bertazi

Date: Mon Nov 30 2026 - 11:35:31 EST


Edward Adam Davis <eadavis@xxxxxxxx> writes:

> 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.

Yeah, I don't think we can really have FEATURE_INCOMPAT_CASEFOLD
correctly enabled at runtime via SET_TUNE_SB_PARAM and working
immediately, because we cannot safely overwrite d->d_ops of all existing
dentries. Even if we start setting ->d_ops for newer dentries after
setting this flag, or somehow when flipping +F, we need vfs support when
instantiating negative dentries and ugh.

I also don't know if people really need to set FEATURE_INCOMPAT_CASEFOLD
at runtime, but if the need exists, it should be after a umount-mount to
ensures the tree is completely pruned from the cache.

Either way if we disable it, like this patch suggests, GET_TUNE_SB_PARAM
should be changed too to not say it is supported.

--
Gabriel Krisman Bertazi