struct llcrypt_symlink_data *sd;
unsigned int ciphertext_len;
+ if (unlikely(!llcrypt_policy_has_filename_enc(inode)))
+ return 0;
+
err = llcrypt_require_key(inode);
if (err)
return err;
* the ciphertext length, even though this is redundant with i_size.
*/
- if (max_size < sizeof(*sd))
- return ERR_PTR(-EUCLEAN);
- sd = caddr;
- cstr.name = (unsigned char *)sd->encrypted_path;
- cstr.len = le16_to_cpu(sd->len);
+ if (unlikely(!llcrypt_policy_has_filename_enc(inode))) {
+ cstr.name = (unsigned char *)caddr;
+ cstr.len = strlen(cstr.name);
+
+ if (cstr.len == 0)
+ return ERR_PTR(-EUCLEAN);
+ } else {
+ if (max_size < sizeof(*sd))
+ return ERR_PTR(-EUCLEAN);
+ sd = caddr;
+ cstr.name = (unsigned char *)sd->encrypted_path;
+ cstr.len = le16_to_cpu(sd->len);
- if (cstr.len == 0)
- return ERR_PTR(-EUCLEAN);
+ if (cstr.len == 0)
+ return ERR_PTR(-EUCLEAN);
- if (cstr.len + sizeof(*sd) - 1 > max_size)
- return ERR_PTR(-EUCLEAN);
+ if (cstr.len + sizeof(*sd) - 1 > max_size)
+ return ERR_PTR(-EUCLEAN);
+ }
err = llcrypt_fname_alloc_buffer(inode, cstr.len, &pstr);
if (err)