diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2016-03-28 00:43:29 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-03-31 00:27:33 -0400 |
| commit | 88ae4ab9802eaa8e400e611f85883143d89d6b61 (patch) | |
| tree | 95649d048fff70dea980427eb91c515aa7cd3095 /fs/ecryptfs | |
| parent | b1168a928277149e1c606763d76ff5c728988755 (diff) | |
ecryptfs_lookup(): try either only encrypted or plaintext name
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ecryptfs')
| -rw-r--r-- | fs/ecryptfs/inode.c | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 91ebc8f18e20..2b8fc9b6b570 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
| @@ -388,55 +388,40 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, | |||
| 388 | unsigned int flags) | 388 | unsigned int flags) |
| 389 | { | 389 | { |
| 390 | char *encrypted_and_encoded_name = NULL; | 390 | char *encrypted_and_encoded_name = NULL; |
| 391 | size_t encrypted_and_encoded_name_size; | 391 | struct ecryptfs_mount_crypt_stat *mount_crypt_stat; |
| 392 | struct ecryptfs_mount_crypt_stat *mount_crypt_stat = NULL; | ||
| 393 | struct dentry *lower_dir_dentry, *lower_dentry; | 392 | struct dentry *lower_dir_dentry, *lower_dentry; |
| 393 | const char *name = ecryptfs_dentry->d_name.name; | ||
| 394 | size_t len = ecryptfs_dentry->d_name.len; | ||
| 394 | struct dentry *res; | 395 | struct dentry *res; |
| 395 | int rc = 0; | 396 | int rc = 0; |
| 396 | 397 | ||
| 397 | lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); | 398 | lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); |
| 398 | lower_dentry = lookup_one_len_unlocked(ecryptfs_dentry->d_name.name, | 399 | |
| 399 | lower_dir_dentry, | ||
| 400 | ecryptfs_dentry->d_name.len); | ||
| 401 | if (IS_ERR(lower_dentry)) { | ||
| 402 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " | ||
| 403 | "[%ld] on lower_dentry = [%pd]\n", __func__, | ||
| 404 | PTR_ERR(lower_dentry), ecryptfs_dentry); | ||
| 405 | res = ERR_CAST(lower_dentry); | ||
| 406 | goto out; | ||
| 407 | } | ||
| 408 | if (d_really_is_positive(lower_dentry)) | ||
| 409 | goto interpose; | ||
| 410 | mount_crypt_stat = &ecryptfs_superblock_to_private( | 400 | mount_crypt_stat = &ecryptfs_superblock_to_private( |
| 411 | ecryptfs_dentry->d_sb)->mount_crypt_stat; | 401 | ecryptfs_dentry->d_sb)->mount_crypt_stat; |
| 412 | if (!(mount_crypt_stat | 402 | if (mount_crypt_stat |
| 413 | && (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES))) | 403 | && (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)) { |
| 414 | goto interpose; | 404 | rc = ecryptfs_encrypt_and_encode_filename( |
| 415 | dput(lower_dentry); | 405 | &encrypted_and_encoded_name, &len, |
| 416 | rc = ecryptfs_encrypt_and_encode_filename( | 406 | mount_crypt_stat, name, len); |
| 417 | &encrypted_and_encoded_name, &encrypted_and_encoded_name_size, | 407 | if (rc) { |
| 418 | mount_crypt_stat, ecryptfs_dentry->d_name.name, | 408 | printk(KERN_ERR "%s: Error attempting to encrypt and encode " |
| 419 | ecryptfs_dentry->d_name.len); | 409 | "filename; rc = [%d]\n", __func__, rc); |
| 420 | if (rc) { | 410 | return ERR_PTR(rc); |
| 421 | printk(KERN_ERR "%s: Error attempting to encrypt and encode " | 411 | } |
| 422 | "filename; rc = [%d]\n", __func__, rc); | 412 | name = encrypted_and_encoded_name; |
| 423 | res = ERR_PTR(rc); | ||
| 424 | goto out; | ||
| 425 | } | 413 | } |
| 426 | lower_dentry = lookup_one_len_unlocked(encrypted_and_encoded_name, | 414 | |
| 427 | lower_dir_dentry, | 415 | lower_dentry = lookup_one_len_unlocked(name, lower_dir_dentry, len); |
| 428 | encrypted_and_encoded_name_size); | ||
| 429 | if (IS_ERR(lower_dentry)) { | 416 | if (IS_ERR(lower_dentry)) { |
| 430 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " | 417 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " |
| 431 | "[%ld] on lower_dentry = [%s]\n", __func__, | 418 | "[%ld] on lower_dentry = [%s]\n", __func__, |
| 432 | PTR_ERR(lower_dentry), | 419 | PTR_ERR(lower_dentry), |
| 433 | encrypted_and_encoded_name); | 420 | name); |
| 434 | res = ERR_CAST(lower_dentry); | 421 | res = ERR_CAST(lower_dentry); |
| 435 | goto out; | 422 | } else { |
| 423 | res = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry); | ||
| 436 | } | 424 | } |
| 437 | interpose: | ||
| 438 | res = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry); | ||
| 439 | out: | ||
| 440 | kfree(encrypted_and_encoded_name); | 425 | kfree(encrypted_and_encoded_name); |
| 441 | return res; | 426 | return res; |
| 442 | } | 427 | } |
