summaryrefslogtreecommitdiff
path: root/fs/ext4/hash.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2019-09-03 01:43:17 -0400
committerTheodore Ts'o <tytso@mit.edu>2019-09-03 01:43:17 -0400
commit6456ca6520ab6c9aec589b4640169cd6da378c68 (patch)
treefd571eddedc34f63bc84e72e6c6c190ec0056be0 /fs/ext4/hash.c
parent9ba55543fc0c6bb1cf8edd63be8802d9ab7e1202 (diff)
ext4: fix kernel oops caused by spurious casefold flag
If an directory has the a casefold flag set without the casefold feature set, s_encoding will not be initialized, and this will cause the kernel to dereference a NULL pointer. In addition to adding checks to avoid these kernel oops, attempts to load inodes with the casefold flag when the casefold feature is not enable will cause the file system to be declared corrupted. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/hash.c')
-rw-r--r--fs/ext4/hash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/ext4/hash.c b/fs/ext4/hash.c
index d358bfcb6b3f..3e133793a5a3 100644
--- a/fs/ext4/hash.c
+++ b/fs/ext4/hash.c
@@ -280,7 +280,7 @@ int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
unsigned char *buff;
struct qstr qstr = {.name = name, .len = len };
- if (len && IS_CASEFOLDED(dir)) {
+ if (len && IS_CASEFOLDED(dir) && um) {
buff = kzalloc(sizeof(char) * PATH_MAX, GFP_KERNEL);
if (!buff)
return -ENOMEM;