diff options
Diffstat (limited to 'fs/f2fs/hash.c')
-rw-r--r-- | fs/f2fs/hash.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c index de841aaf3c43..e3beac546c63 100644 --- a/fs/f2fs/hash.c +++ b/fs/f2fs/hash.c | |||
@@ -111,7 +111,9 @@ void f2fs_hash_filename(const struct inode *dir, struct f2fs_filename *fname) | |||
111 | * If the casefolded name is provided, hash it instead of the | 111 | * If the casefolded name is provided, hash it instead of the |
112 | * on-disk name. If the casefolded name is *not* provided, that | 112 | * on-disk name. If the casefolded name is *not* provided, that |
113 | * should only be because the name wasn't valid Unicode, so fall | 113 | * should only be because the name wasn't valid Unicode, so fall |
114 | * back to treating the name as an opaque byte sequence. | 114 | * back to treating the name as an opaque byte sequence. Note |
115 | * that to handle encrypted directories, the fallback must use | ||
116 | * usr_fname (plaintext) rather than disk_name (ciphertext). | ||
115 | */ | 117 | */ |
116 | WARN_ON_ONCE(!fname->usr_fname->name); | 118 | WARN_ON_ONCE(!fname->usr_fname->name); |
117 | if (fname->cf_name.name) { | 119 | if (fname->cf_name.name) { |
@@ -121,6 +123,13 @@ void f2fs_hash_filename(const struct inode *dir, struct f2fs_filename *fname) | |||
121 | name = fname->usr_fname->name; | 123 | name = fname->usr_fname->name; |
122 | len = fname->usr_fname->len; | 124 | len = fname->usr_fname->len; |
123 | } | 125 | } |
126 | if (IS_ENCRYPTED(dir)) { | ||
127 | struct qstr tmp = QSTR_INIT(name, len); | ||
128 | |||
129 | fname->hash = | ||
130 | cpu_to_le32(fscrypt_fname_siphash(dir, &tmp)); | ||
131 | return; | ||
132 | } | ||
124 | } | 133 | } |
125 | #endif | 134 | #endif |
126 | fname->hash = cpu_to_le32(TEA_hash_name(name, len)); | 135 | fname->hash = cpu_to_le32(TEA_hash_name(name, len)); |