Commit 88ae4ab9 authored by Al Viro's avatar Al Viro

ecryptfs_lookup(): try either only encrypted or plaintext name

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent b1168a92
...@@ -388,55 +388,40 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, ...@@ -388,55 +388,40 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
unsigned int flags) unsigned int flags)
{ {
char *encrypted_and_encoded_name = NULL; char *encrypted_and_encoded_name = NULL;
size_t encrypted_and_encoded_name_size; struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
struct ecryptfs_mount_crypt_stat *mount_crypt_stat = NULL;
struct dentry *lower_dir_dentry, *lower_dentry; struct dentry *lower_dir_dentry, *lower_dentry;
const char *name = ecryptfs_dentry->d_name.name;
size_t len = ecryptfs_dentry->d_name.len;
struct dentry *res; struct dentry *res;
int rc = 0; int rc = 0;
lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent);
lower_dentry = lookup_one_len_unlocked(ecryptfs_dentry->d_name.name,
lower_dir_dentry,
ecryptfs_dentry->d_name.len);
if (IS_ERR(lower_dentry)) {
ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
"[%ld] on lower_dentry = [%pd]\n", __func__,
PTR_ERR(lower_dentry), ecryptfs_dentry);
res = ERR_CAST(lower_dentry);
goto out;
}
if (d_really_is_positive(lower_dentry))
goto interpose;
mount_crypt_stat = &ecryptfs_superblock_to_private( mount_crypt_stat = &ecryptfs_superblock_to_private(
ecryptfs_dentry->d_sb)->mount_crypt_stat; ecryptfs_dentry->d_sb)->mount_crypt_stat;
if (!(mount_crypt_stat if (mount_crypt_stat
&& (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES))) && (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)) {
goto interpose; rc = ecryptfs_encrypt_and_encode_filename(
dput(lower_dentry); &encrypted_and_encoded_name, &len,
rc = ecryptfs_encrypt_and_encode_filename( mount_crypt_stat, name, len);
&encrypted_and_encoded_name, &encrypted_and_encoded_name_size, if (rc) {
mount_crypt_stat, ecryptfs_dentry->d_name.name, printk(KERN_ERR "%s: Error attempting to encrypt and encode "
ecryptfs_dentry->d_name.len); "filename; rc = [%d]\n", __func__, rc);
if (rc) { return ERR_PTR(rc);
printk(KERN_ERR "%s: Error attempting to encrypt and encode " }
"filename; rc = [%d]\n", __func__, rc); name = encrypted_and_encoded_name;
res = ERR_PTR(rc);
goto out;
} }
lower_dentry = lookup_one_len_unlocked(encrypted_and_encoded_name,
lower_dir_dentry, lower_dentry = lookup_one_len_unlocked(name, lower_dir_dentry, len);
encrypted_and_encoded_name_size);
if (IS_ERR(lower_dentry)) { if (IS_ERR(lower_dentry)) {
ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
"[%ld] on lower_dentry = [%s]\n", __func__, "[%ld] on lower_dentry = [%s]\n", __func__,
PTR_ERR(lower_dentry), PTR_ERR(lower_dentry),
encrypted_and_encoded_name); name);
res = ERR_CAST(lower_dentry); res = ERR_CAST(lower_dentry);
goto out; } else {
res = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry);
} }
interpose:
res = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry);
out:
kfree(encrypted_and_encoded_name); kfree(encrypted_and_encoded_name);
return res; return res;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment