|
@@ -168,19 +168,18 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
|
|
"context; rc = [%d]\n", rc);
|
|
"context; rc = [%d]\n", rc);
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
- rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
|
|
|
|
|
|
+ rc = ecryptfs_get_lower_file(ecryptfs_dentry);
|
|
if (rc) {
|
|
if (rc) {
|
|
printk(KERN_ERR "%s: Error attempting to initialize "
|
|
printk(KERN_ERR "%s: Error attempting to initialize "
|
|
- "the persistent file for the dentry with name "
|
|
|
|
|
|
+ "the lower file for the dentry with name "
|
|
"[%s]; rc = [%d]\n", __func__,
|
|
"[%s]; rc = [%d]\n", __func__,
|
|
ecryptfs_dentry->d_name.name, rc);
|
|
ecryptfs_dentry->d_name.name, rc);
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
rc = ecryptfs_write_metadata(ecryptfs_dentry);
|
|
rc = ecryptfs_write_metadata(ecryptfs_dentry);
|
|
- if (rc) {
|
|
|
|
|
|
+ if (rc)
|
|
printk(KERN_ERR "Error writing headers; rc = [%d]\n", rc);
|
|
printk(KERN_ERR "Error writing headers; rc = [%d]\n", rc);
|
|
- goto out;
|
|
|
|
- }
|
|
|
|
|
|
+ ecryptfs_put_lower_file(ecryptfs_dentry->d_inode);
|
|
out:
|
|
out:
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
@@ -230,7 +229,7 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry,
|
|
struct ecryptfs_crypt_stat *crypt_stat;
|
|
struct ecryptfs_crypt_stat *crypt_stat;
|
|
char *page_virt = NULL;
|
|
char *page_virt = NULL;
|
|
u64 file_size;
|
|
u64 file_size;
|
|
- int rc = 0;
|
|
|
|
|
|
+ int put_lower = 0, rc = 0;
|
|
|
|
|
|
lower_dir_dentry = lower_dentry->d_parent;
|
|
lower_dir_dentry = lower_dentry->d_parent;
|
|
lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(
|
|
lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(
|
|
@@ -277,14 +276,15 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry,
|
|
rc = -ENOMEM;
|
|
rc = -ENOMEM;
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
- rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
|
|
|
|
|
|
+ rc = ecryptfs_get_lower_file(ecryptfs_dentry);
|
|
if (rc) {
|
|
if (rc) {
|
|
printk(KERN_ERR "%s: Error attempting to initialize "
|
|
printk(KERN_ERR "%s: Error attempting to initialize "
|
|
- "the persistent file for the dentry with name "
|
|
|
|
|
|
+ "the lower file for the dentry with name "
|
|
"[%s]; rc = [%d]\n", __func__,
|
|
"[%s]; rc = [%d]\n", __func__,
|
|
ecryptfs_dentry->d_name.name, rc);
|
|
ecryptfs_dentry->d_name.name, rc);
|
|
goto out_free_kmem;
|
|
goto out_free_kmem;
|
|
}
|
|
}
|
|
|
|
+ put_lower = 1;
|
|
crypt_stat = &ecryptfs_inode_to_private(
|
|
crypt_stat = &ecryptfs_inode_to_private(
|
|
ecryptfs_dentry->d_inode)->crypt_stat;
|
|
ecryptfs_dentry->d_inode)->crypt_stat;
|
|
/* TODO: lock for crypt_stat comparison */
|
|
/* TODO: lock for crypt_stat comparison */
|
|
@@ -322,6 +322,8 @@ out_put:
|
|
mntput(lower_mnt);
|
|
mntput(lower_mnt);
|
|
d_drop(ecryptfs_dentry);
|
|
d_drop(ecryptfs_dentry);
|
|
out:
|
|
out:
|
|
|
|
+ if (put_lower)
|
|
|
|
+ ecryptfs_put_lower_file(ecryptfs_dentry->d_inode);
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -757,8 +759,11 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
|
|
|
|
|
|
if (unlikely((ia->ia_size == i_size))) {
|
|
if (unlikely((ia->ia_size == i_size))) {
|
|
lower_ia->ia_valid &= ~ATTR_SIZE;
|
|
lower_ia->ia_valid &= ~ATTR_SIZE;
|
|
- goto out;
|
|
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
+ rc = ecryptfs_get_lower_file(dentry);
|
|
|
|
+ if (rc)
|
|
|
|
+ return rc;
|
|
crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat;
|
|
crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat;
|
|
/* Switch on growing or shrinking file */
|
|
/* Switch on growing or shrinking file */
|
|
if (ia->ia_size > i_size) {
|
|
if (ia->ia_size > i_size) {
|
|
@@ -836,6 +841,7 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
|
|
lower_ia->ia_valid &= ~ATTR_SIZE;
|
|
lower_ia->ia_valid &= ~ATTR_SIZE;
|
|
}
|
|
}
|
|
out:
|
|
out:
|
|
|
|
+ ecryptfs_put_lower_file(inode);
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -911,7 +917,13 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
|
|
|
|
|
|
mount_crypt_stat = &ecryptfs_superblock_to_private(
|
|
mount_crypt_stat = &ecryptfs_superblock_to_private(
|
|
dentry->d_sb)->mount_crypt_stat;
|
|
dentry->d_sb)->mount_crypt_stat;
|
|
|
|
+ rc = ecryptfs_get_lower_file(dentry);
|
|
|
|
+ if (rc) {
|
|
|
|
+ mutex_unlock(&crypt_stat->cs_mutex);
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
rc = ecryptfs_read_metadata(dentry);
|
|
rc = ecryptfs_read_metadata(dentry);
|
|
|
|
+ ecryptfs_put_lower_file(inode);
|
|
if (rc) {
|
|
if (rc) {
|
|
if (!(mount_crypt_stat->flags
|
|
if (!(mount_crypt_stat->flags
|
|
& ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED)) {
|
|
& ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED)) {
|