aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/inode.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-07-20 04:03:41 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-29 13:24:16 -0400
commitbc65a1215eda3e067801e0a8f3eeffb62800f355 (patch)
treef53aefd935c6e99ffe24dee94a322083536d3004 /fs/ecryptfs/inode.c
parentfaf02010290e202e275c1bf94ca9dd808bf85607 (diff)
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>
Diffstat (limited to 'fs/ecryptfs/inode.c')
-rw-r--r--fs/ecryptfs/inode.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index ffa2be57804d..eeb734aea5ba 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -381,12 +381,6 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
381 struct dentry *lower_dir_dentry, *lower_dentry; 381 struct dentry *lower_dir_dentry, *lower_dentry;
382 int rc = 0; 382 int rc = 0;
383 383
384 if ((ecryptfs_dentry->d_name.len == 1
385 && !strcmp(ecryptfs_dentry->d_name.name, "."))
386 || (ecryptfs_dentry->d_name.len == 2
387 && !strcmp(ecryptfs_dentry->d_name.name, ".."))) {
388 goto out_d_drop;
389 }
390 lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); 384 lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent);
391 mutex_lock(&lower_dir_dentry->d_inode->i_mutex); 385 mutex_lock(&lower_dir_dentry->d_inode->i_mutex);
392 lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name, 386 lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name,
@@ -397,8 +391,8 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
397 rc = PTR_ERR(lower_dentry); 391 rc = PTR_ERR(lower_dentry);
398 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " 392 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
399 "[%d] on lower_dentry = [%s]\n", __func__, rc, 393 "[%d] on lower_dentry = [%s]\n", __func__, rc,
400 encrypted_and_encoded_name); 394 ecryptfs_dentry->d_name.name);
401 goto out_d_drop; 395 goto out;
402 } 396 }
403 if (lower_dentry->d_inode) 397 if (lower_dentry->d_inode)
404 goto interpose; 398 goto interpose;
@@ -415,7 +409,7 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
415 if (rc) { 409 if (rc) {
416 printk(KERN_ERR "%s: Error attempting to encrypt and encode " 410 printk(KERN_ERR "%s: Error attempting to encrypt and encode "
417 "filename; rc = [%d]\n", __func__, rc); 411 "filename; rc = [%d]\n", __func__, rc);
418 goto out_d_drop; 412 goto out;
419 } 413 }
420 mutex_lock(&lower_dir_dentry->d_inode->i_mutex); 414 mutex_lock(&lower_dir_dentry->d_inode->i_mutex);
421 lower_dentry = lookup_one_len(encrypted_and_encoded_name, 415 lower_dentry = lookup_one_len(encrypted_and_encoded_name,
@@ -427,14 +421,11 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
427 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " 421 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
428 "[%d] on lower_dentry = [%s]\n", __func__, rc, 422 "[%d] on lower_dentry = [%s]\n", __func__, rc,
429 encrypted_and_encoded_name); 423 encrypted_and_encoded_name);
430 goto out_d_drop; 424 goto out;
431 } 425 }
432interpose: 426interpose:
433 rc = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry, 427 rc = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry,
434 ecryptfs_dir_inode); 428 ecryptfs_dir_inode);
435 goto out;
436out_d_drop:
437 d_drop(ecryptfs_dentry);
438out: 429out:
439 kfree(encrypted_and_encoded_name); 430 kfree(encrypted_and_encoded_name);
440 return ERR_PTR(rc); 431 return ERR_PTR(rc);