Skip to content

Commit 8216776

Browse files
ebiggerstytso
authored andcommitted
ext4: reject casefold inode flag without casefold feature
It is invalid for the casefold inode flag to be set without the casefold superblock feature flag also being set. e2fsck already considers this case to be invalid and handles it by offering to clear the casefold flag on the inode. __ext4_iget() also already considered this to be invalid, sort of, but it only got so far as logging an error message; it didn't actually reject the inode. Make it reject the inode so that other code doesn't have to handle this case. This matches what f2fs does. Note: we could check 's_encoding != NULL' instead of ext4_has_feature_casefold(). This would make the check robust against the casefold feature being enabled by userspace writing to the page cache of the mounted block device. However, it's unsolvable in general for filesystems to be robust against concurrent writes to the page cache of the mounted block device. Though this very particular scenario involving the casefold feature is solvable, we should not pretend that we can support this model, so let's just check the casefold feature. tune2fs already forbids enabling casefold on a mounted filesystem. Signed-off-by: Eric Biggers <ebiggers@google.com> Link: https://lore.kernel.org/r/20230814182903.37267-2-ebiggers@kernel.org Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 0f6bc57 commit 8216776

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/ext4/inode.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4974,9 +4974,12 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
49744974
"iget: bogus i_mode (%o)", inode->i_mode);
49754975
goto bad_inode;
49764976
}
4977-
if (IS_CASEFOLDED(inode) && !ext4_has_feature_casefold(inode->i_sb))
4977+
if (IS_CASEFOLDED(inode) && !ext4_has_feature_casefold(inode->i_sb)) {
49784978
ext4_error_inode(inode, function, line, 0,
49794979
"casefold flag without casefold feature");
4980+
ret = -EFSCORRUPTED;
4981+
goto bad_inode;
4982+
}
49804983
if ((err_str = check_igot_inode(inode, flags)) != NULL) {
49814984
ext4_error_inode(inode, function, line, 0, err_str);
49824985
ret = -EFSCORRUPTED;

0 commit comments

Comments
 (0)