sanitize ecryptfs_lookup()
* ->lookup() never gets hit with . or .. * dentry it gets is unhashed, so unless we had gone and hashed it ourselves, there's no need to d_drop() the sucker. * wrong name printed in one of the printks (NULL, in fact) Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -381,12 +381,6 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
|
|||||||
struct dentry *lower_dir_dentry, *lower_dentry;
|
struct dentry *lower_dir_dentry, *lower_dentry;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if ((ecryptfs_dentry->d_name.len == 1
|
|
||||||
&& !strcmp(ecryptfs_dentry->d_name.name, "."))
|
|
||||||
|| (ecryptfs_dentry->d_name.len == 2
|
|
||||||
&& !strcmp(ecryptfs_dentry->d_name.name, ".."))) {
|
|
||||||
goto out_d_drop;
|
|
||||||
}
|
|
||||||
lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent);
|
lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent);
|
||||||
mutex_lock(&lower_dir_dentry->d_inode->i_mutex);
|
mutex_lock(&lower_dir_dentry->d_inode->i_mutex);
|
||||||
lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name,
|
lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name,
|
||||||
@@ -397,8 +391,8 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
|
|||||||
rc = PTR_ERR(lower_dentry);
|
rc = PTR_ERR(lower_dentry);
|
||||||
ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
|
ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
|
||||||
"[%d] on lower_dentry = [%s]\n", __func__, rc,
|
"[%d] on lower_dentry = [%s]\n", __func__, rc,
|
||||||
encrypted_and_encoded_name);
|
ecryptfs_dentry->d_name.name);
|
||||||
goto out_d_drop;
|
goto out;
|
||||||
}
|
}
|
||||||
if (lower_dentry->d_inode)
|
if (lower_dentry->d_inode)
|
||||||
goto interpose;
|
goto interpose;
|
||||||
@@ -415,7 +409,7 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
|
|||||||
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);
|
||||||
goto out_d_drop;
|
goto out;
|
||||||
}
|
}
|
||||||
mutex_lock(&lower_dir_dentry->d_inode->i_mutex);
|
mutex_lock(&lower_dir_dentry->d_inode->i_mutex);
|
||||||
lower_dentry = lookup_one_len(encrypted_and_encoded_name,
|
lower_dentry = lookup_one_len(encrypted_and_encoded_name,
|
||||||
@@ -427,14 +421,11 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
|
|||||||
ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
|
ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
|
||||||
"[%d] on lower_dentry = [%s]\n", __func__, rc,
|
"[%d] on lower_dentry = [%s]\n", __func__, rc,
|
||||||
encrypted_and_encoded_name);
|
encrypted_and_encoded_name);
|
||||||
goto out_d_drop;
|
goto out;
|
||||||
}
|
}
|
||||||
interpose:
|
interpose:
|
||||||
rc = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry,
|
rc = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry,
|
||||||
ecryptfs_dir_inode);
|
ecryptfs_dir_inode);
|
||||||
goto out;
|
|
||||||
out_d_drop:
|
|
||||||
d_drop(ecryptfs_dentry);
|
|
||||||
out:
|
out:
|
||||||
kfree(encrypted_and_encoded_name);
|
kfree(encrypted_and_encoded_name);
|
||||||
return ERR_PTR(rc);
|
return ERR_PTR(rc);
|
||||||
|
Reference in New Issue
Block a user