summaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2023-08-14 11:29:01 -0700
committerTheodore Ts'o <tytso@mit.edu>2023-08-27 11:27:13 -0400
commit8216776ccff6fcd40e3fdaa109aa4150ebe760b3 (patch)
treeba9b552dcfa15ee98c4743f0bf7efbcd367aafb1 /fs/ext4
parent0f6bc57971c63f7352c3564d19a5dc707fe8332a (diff)
downloadlinux-stable-8216776ccff6fcd40e3fdaa109aa4150ebe760b3.tar.gz
linux-stable-8216776ccff6fcd40e3fdaa109aa4150ebe760b3.tar.bz2
linux-stable-8216776ccff6fcd40e3fdaa109aa4150ebe760b3.zip
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>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/inode.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c5d8f8933c8c..6c490f05e2ba 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4974,9 +4974,12 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
"iget: bogus i_mode (%o)", inode->i_mode);
goto bad_inode;
}
- if (IS_CASEFOLDED(inode) && !ext4_has_feature_casefold(inode->i_sb))
+ if (IS_CASEFOLDED(inode) && !ext4_has_feature_casefold(inode->i_sb)) {
ext4_error_inode(inode, function, line, 0,
"casefold flag without casefold feature");
+ ret = -EFSCORRUPTED;
+ goto bad_inode;
+ }
if ((err_str = check_igot_inode(inode, flags)) != NULL) {
ext4_error_inode(inode, function, line, 0, err_str);
ret = -EFSCORRUPTED;