mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-07 10:03:24 +00:00
ecryptfs_lookup(): try either only encrypted or plaintext name
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
b1168a9282
commit
88ae4ab980
@ -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;
|
|
||||||
dput(lower_dentry);
|
|
||||||
rc = ecryptfs_encrypt_and_encode_filename(
|
rc = ecryptfs_encrypt_and_encode_filename(
|
||||||
&encrypted_and_encoded_name, &encrypted_and_encoded_name_size,
|
&encrypted_and_encoded_name, &len,
|
||||||
mount_crypt_stat, ecryptfs_dentry->d_name.name,
|
mount_crypt_stat, name, len);
|
||||||
ecryptfs_dentry->d_name.len);
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
printk(KERN_ERR "%s: Error attempting to encrypt and encode "
|
printk(KERN_ERR "%s: Error attempting to encrypt and encode "
|
||||||
"filename; rc = [%d]\n", __func__, rc);
|
"filename; rc = [%d]\n", __func__, rc);
|
||||||
res = ERR_PTR(rc);
|
return ERR_PTR(rc);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
lower_dentry = lookup_one_len_unlocked(encrypted_and_encoded_name,
|
name = encrypted_and_encoded_name;
|
||||||
lower_dir_dentry,
|
}
|
||||||
encrypted_and_encoded_name_size);
|
|
||||||
|
lower_dentry = lookup_one_len_unlocked(name, lower_dir_dentry, len);
|
||||||
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 {
|
||||||
}
|
|
||||||
interpose:
|
|
||||||
res = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry);
|
res = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry);
|
||||||
out:
|
}
|
||||||
kfree(encrypted_and_encoded_name);
|
kfree(encrypted_and_encoded_name);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user