summaryrefslogtreecommitdiffstats
path: root/fs/ext4/dir.c
diff options
context:
space:
mode:
authoryao.ly <yao.ly@linux.alibaba.com>2024-07-01 08:43:39 +0200
committerTheodore Ts'o <tytso@mit.edu>2024-08-27 03:20:25 +0200
commit70dd7b573afeba9b8f8a33f2ae1e4a9a2ec8c1ec (patch)
tree062fa6f2281cc159038c02450f562e6176e7d03a /fs/ext4/dir.c
parentext4: correct comment of h_checksum (diff)
downloadlinux-70dd7b573afeba9b8f8a33f2ae1e4a9a2ec8c1ec.tar.xz
linux-70dd7b573afeba9b8f8a33f2ae1e4a9a2ec8c1ec.zip
ext4: correct encrypted dentry name hash when not casefolded
EXT4_DIRENT_HASH and EXT4_DIRENT_MINOR_HASH will access struct ext4_dir_entry_hash followed ext4_dir_entry. But there is no ext4_dir_entry_hash followed when inode is encrypted and not casefolded Signed-off-by: yao.ly <yao.ly@linux.alibaba.com> Link: https://patch.msgid.link/1719816219-128287-1-git-send-email-yao.ly@linux.alibaba.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
Diffstat (limited to '')
-rw-r--r--fs/ext4/dir.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index ff4514e4626b..b8b6b06015cd 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -279,12 +279,20 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
struct fscrypt_str de_name =
FSTR_INIT(de->name,
de->name_len);
+ u32 hash;
+ u32 minor_hash;
+
+ if (IS_CASEFOLDED(inode)) {
+ hash = EXT4_DIRENT_HASH(de);
+ minor_hash = EXT4_DIRENT_MINOR_HASH(de);
+ } else {
+ hash = 0;
+ minor_hash = 0;
+ }
/* Directory is encrypted */
err = fscrypt_fname_disk_to_usr(inode,
- EXT4_DIRENT_HASH(de),
- EXT4_DIRENT_MINOR_HASH(de),
- &de_name, &fstr);
+ hash, minor_hash, &de_name, &fstr);
de_name = fstr;
fstr.len = save_len;
if (err)