提交 8787c7a3 编写于 作者: T Tyler Hicks

eCryptfs: Revert "dont call lookup_one_len to avoid NULL nameidata"

This reverts commit 21edad32 and commit
93c3fe40, which fixed a regression by
the former.

Al Viro pointed out bypassed dcache lookups in
ecryptfs_new_lower_dentry(), misuse of vfs_path_lookup() in
ecryptfs_lookup_one_lower() and a dislike of passing nameidata to the
lower filesystem.
Reported-by: NAl Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
上级 85e2efbb
...@@ -348,75 +348,6 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry, ...@@ -348,75 +348,6 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry,
return rc; return rc;
} }
/**
* ecryptfs_new_lower_dentry
* @name: The name of the new dentry.
* @lower_dir_dentry: Parent directory of the new dentry.
* @nd: nameidata from last lookup.
*
* Create a new dentry or get it from lower parent dir.
*/
static struct dentry *
ecryptfs_new_lower_dentry(struct qstr *name, struct dentry *lower_dir_dentry,
struct nameidata *nd)
{
struct dentry *new_dentry;
struct dentry *tmp;
struct inode *lower_dir_inode;
lower_dir_inode = lower_dir_dentry->d_inode;
tmp = d_alloc(lower_dir_dentry, name);
if (!tmp)
return ERR_PTR(-ENOMEM);
mutex_lock(&lower_dir_inode->i_mutex);
new_dentry = lower_dir_inode->i_op->lookup(lower_dir_inode, tmp, nd);
mutex_unlock(&lower_dir_inode->i_mutex);
if (!new_dentry)
new_dentry = tmp;
else
dput(tmp);
return new_dentry;
}
/**
* ecryptfs_lookup_one_lower
* @ecryptfs_dentry: The eCryptfs dentry that we are looking up
* @lower_dir_dentry: lower parent directory
* @name: lower file name
*
* Get the lower dentry from vfs. If lower dentry does not exist yet,
* create it.
*/
static struct dentry *
ecryptfs_lookup_one_lower(struct dentry *ecryptfs_dentry,
struct dentry *lower_dir_dentry, struct qstr *name)
{
struct nameidata nd;
struct vfsmount *lower_mnt;
int err;
lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(
ecryptfs_dentry->d_parent));
err = vfs_path_lookup(lower_dir_dentry, lower_mnt, name->name , 0, &nd);
mntput(lower_mnt);
if (!err) {
/* we dont need the mount */
mntput(nd.path.mnt);
return nd.path.dentry;
}
if (err != -ENOENT)
return ERR_PTR(err);
/* create a new lower dentry */
return ecryptfs_new_lower_dentry(name, lower_dir_dentry, &nd);
}
/** /**
* ecryptfs_lookup * ecryptfs_lookup
* @ecryptfs_dir_inode: The eCryptfs directory inode * @ecryptfs_dir_inode: The eCryptfs directory inode
...@@ -434,7 +365,6 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, ...@@ -434,7 +365,6 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
size_t encrypted_and_encoded_name_size; size_t encrypted_and_encoded_name_size;
struct ecryptfs_mount_crypt_stat *mount_crypt_stat = NULL; struct ecryptfs_mount_crypt_stat *mount_crypt_stat = NULL;
struct dentry *lower_dir_dentry, *lower_dentry; struct dentry *lower_dir_dentry, *lower_dentry;
struct qstr lower_name;
int rc = 0; int rc = 0;
if ((ecryptfs_dentry->d_name.len == 1 if ((ecryptfs_dentry->d_name.len == 1
...@@ -444,20 +374,14 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, ...@@ -444,20 +374,14 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
goto out_d_drop; 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);
lower_name.name = ecryptfs_dentry->d_name.name; mutex_lock(&lower_dir_dentry->d_inode->i_mutex);
lower_name.len = ecryptfs_dentry->d_name.len; lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name,
lower_name.hash = ecryptfs_dentry->d_name.hash; lower_dir_dentry,
if (lower_dir_dentry->d_op && lower_dir_dentry->d_op->d_hash) { ecryptfs_dentry->d_name.len);
rc = lower_dir_dentry->d_op->d_hash(lower_dir_dentry, mutex_unlock(&lower_dir_dentry->d_inode->i_mutex);
lower_dir_dentry->d_inode, &lower_name);
if (rc < 0)
goto out_d_drop;
}
lower_dentry = ecryptfs_lookup_one_lower(ecryptfs_dentry,
lower_dir_dentry, &lower_name);
if (IS_ERR(lower_dentry)) { if (IS_ERR(lower_dentry)) {
rc = PTR_ERR(lower_dentry); rc = PTR_ERR(lower_dentry);
ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_lower() 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_d_drop;
...@@ -479,20 +403,14 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, ...@@ -479,20 +403,14 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
"filename; rc = [%d]\n", __func__, rc); "filename; rc = [%d]\n", __func__, rc);
goto out_d_drop; goto out_d_drop;
} }
lower_name.name = encrypted_and_encoded_name; mutex_lock(&lower_dir_dentry->d_inode->i_mutex);
lower_name.len = encrypted_and_encoded_name_size; lower_dentry = lookup_one_len(encrypted_and_encoded_name,
lower_name.hash = full_name_hash(lower_name.name, lower_name.len); lower_dir_dentry,
if (lower_dir_dentry->d_op && lower_dir_dentry->d_op->d_hash) { encrypted_and_encoded_name_size);
rc = lower_dir_dentry->d_op->d_hash(lower_dir_dentry, mutex_unlock(&lower_dir_dentry->d_inode->i_mutex);
lower_dir_dentry->d_inode, &lower_name);
if (rc < 0)
goto out_d_drop;
}
lower_dentry = ecryptfs_lookup_one_lower(ecryptfs_dentry,
lower_dir_dentry, &lower_name);
if (IS_ERR(lower_dentry)) { if (IS_ERR(lower_dentry)) {
rc = PTR_ERR(lower_dentry); rc = PTR_ERR(lower_dentry);
ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_lower() 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_d_drop;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册