mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
ext4: correct encrypted dentry name hash when not casefolded
commit 70dd7b573afeba9b8f8a33f2ae1e4a9a2ec8c1ec upstream. 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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a02d7f5b24
commit
7b30d0b9f5
@@ -279,12 +279,20 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
|
|||||||
struct fscrypt_str de_name =
|
struct fscrypt_str de_name =
|
||||||
FSTR_INIT(de->name,
|
FSTR_INIT(de->name,
|
||||||
de->name_len);
|
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 */
|
/* Directory is encrypted */
|
||||||
err = fscrypt_fname_disk_to_usr(inode,
|
err = fscrypt_fname_disk_to_usr(inode,
|
||||||
EXT4_DIRENT_HASH(de),
|
hash, minor_hash, &de_name, &fstr);
|
||||||
EXT4_DIRENT_MINOR_HASH(de),
|
|
||||||
&de_name, &fstr);
|
|
||||||
de_name = fstr;
|
de_name = fstr;
|
||||||
fstr.len = save_len;
|
fstr.len = save_len;
|
||||||
if (err)
|
if (err)
|
||||||
|
|||||||
Reference in New Issue
Block a user