diff options
Diffstat (limited to 'fs/ecryptfs/main.c')
-rw-r--r-- | fs/ecryptfs/main.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index c6ac85d6c701..760983d0f25e 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/key.h> | 35 | #include <linux/key.h> |
36 | #include <linux/parser.h> | 36 | #include <linux/parser.h> |
37 | #include <linux/fs_stack.h> | 37 | #include <linux/fs_stack.h> |
38 | #include <linux/ima.h> | 38 | #include <linux/slab.h> |
39 | #include "ecryptfs_kernel.h" | 39 | #include "ecryptfs_kernel.h" |
40 | 40 | ||
41 | /** | 41 | /** |
@@ -119,7 +119,6 @@ int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | |||
119 | const struct cred *cred = current_cred(); | 119 | const struct cred *cred = current_cred(); |
120 | struct ecryptfs_inode_info *inode_info = | 120 | struct ecryptfs_inode_info *inode_info = |
121 | ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); | 121 | ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); |
122 | int opened_lower_file = 0; | ||
123 | int rc = 0; | 122 | int rc = 0; |
124 | 123 | ||
125 | mutex_lock(&inode_info->lower_file_mutex); | 124 | mutex_lock(&inode_info->lower_file_mutex); |
@@ -136,12 +135,9 @@ int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | |||
136 | "for lower_dentry [0x%p] and lower_mnt [0x%p]; " | 135 | "for lower_dentry [0x%p] and lower_mnt [0x%p]; " |
137 | "rc = [%d]\n", lower_dentry, lower_mnt, rc); | 136 | "rc = [%d]\n", lower_dentry, lower_mnt, rc); |
138 | inode_info->lower_file = NULL; | 137 | inode_info->lower_file = NULL; |
139 | } else | 138 | } |
140 | opened_lower_file = 1; | ||
141 | } | 139 | } |
142 | mutex_unlock(&inode_info->lower_file_mutex); | 140 | mutex_unlock(&inode_info->lower_file_mutex); |
143 | if (opened_lower_file) | ||
144 | ima_counts_get(inode_info->lower_file); | ||
145 | return rc; | 141 | return rc; |
146 | } | 142 | } |
147 | 143 | ||
@@ -194,7 +190,7 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, | |||
194 | init_special_inode(inode, lower_inode->i_mode, | 190 | init_special_inode(inode, lower_inode->i_mode, |
195 | lower_inode->i_rdev); | 191 | lower_inode->i_rdev); |
196 | dentry->d_op = &ecryptfs_dops; | 192 | dentry->d_op = &ecryptfs_dops; |
197 | fsstack_copy_attr_all(inode, lower_inode, NULL); | 193 | fsstack_copy_attr_all(inode, lower_inode); |
198 | /* This size will be overwritten for real files w/ headers and | 194 | /* This size will be overwritten for real files w/ headers and |
199 | * other metadata */ | 195 | * other metadata */ |
200 | fsstack_copy_inode_size(inode, lower_inode); | 196 | fsstack_copy_inode_size(inode, lower_inode); |
@@ -501,17 +497,25 @@ struct kmem_cache *ecryptfs_sb_info_cache; | |||
501 | static int | 497 | static int |
502 | ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent) | 498 | ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent) |
503 | { | 499 | { |
500 | struct ecryptfs_sb_info *esi; | ||
504 | int rc = 0; | 501 | int rc = 0; |
505 | 502 | ||
506 | /* Released in ecryptfs_put_super() */ | 503 | /* Released in ecryptfs_put_super() */ |
507 | ecryptfs_set_superblock_private(sb, | 504 | ecryptfs_set_superblock_private(sb, |
508 | kmem_cache_zalloc(ecryptfs_sb_info_cache, | 505 | kmem_cache_zalloc(ecryptfs_sb_info_cache, |
509 | GFP_KERNEL)); | 506 | GFP_KERNEL)); |
510 | if (!ecryptfs_superblock_to_private(sb)) { | 507 | esi = ecryptfs_superblock_to_private(sb); |
508 | if (!esi) { | ||
511 | ecryptfs_printk(KERN_WARNING, "Out of memory\n"); | 509 | ecryptfs_printk(KERN_WARNING, "Out of memory\n"); |
512 | rc = -ENOMEM; | 510 | rc = -ENOMEM; |
513 | goto out; | 511 | goto out; |
514 | } | 512 | } |
513 | |||
514 | rc = bdi_setup_and_register(&esi->bdi, "ecryptfs", BDI_CAP_MAP_COPY); | ||
515 | if (rc) | ||
516 | goto out; | ||
517 | |||
518 | sb->s_bdi = &esi->bdi; | ||
515 | sb->s_op = &ecryptfs_sops; | 519 | sb->s_op = &ecryptfs_sops; |
516 | /* Released through deactivate_super(sb) from get_sb_nodev */ | 520 | /* Released through deactivate_super(sb) from get_sb_nodev */ |
517 | sb->s_root = d_alloc(NULL, &(const struct qstr) { | 521 | sb->s_root = d_alloc(NULL, &(const struct qstr) { |
@@ -590,8 +594,8 @@ out: | |||
590 | * with as much information as it can before needing | 594 | * with as much information as it can before needing |
591 | * the lower filesystem. | 595 | * the lower filesystem. |
592 | * ecryptfs_read_super(): this accesses the lower filesystem and uses | 596 | * ecryptfs_read_super(): this accesses the lower filesystem and uses |
593 | * ecryptfs_interpolate to perform most of the linking | 597 | * ecryptfs_interpose to perform most of the linking |
594 | * ecryptfs_interpolate(): links the lower filesystem into ecryptfs | 598 | * ecryptfs_interpose(): links the lower filesystem into ecryptfs (inode.c) |
595 | */ | 599 | */ |
596 | static int ecryptfs_get_sb(struct file_system_type *fs_type, int flags, | 600 | static int ecryptfs_get_sb(struct file_system_type *fs_type, int flags, |
597 | const char *dev_name, void *raw_data, | 601 | const char *dev_name, void *raw_data, |