← Back to team overview

ecryptfs-devel team mailing list archive

[PATCH 2/3] EcryptFS: if failing create due to interpose failing remove lower file

 

While dentry interpose fails on create, the create is returned as having
failed, but this occurs after the lower file has been created.  This
results in the lower file being created and existing while the create
failed.

Remove the lower file if the interpose failed to keep the lower file system
consistent with the ecryptfs view.

Signed-off-by: John Johansen <john.johansen@xxxxxxxxxxxxx>
---
 fs/ecryptfs/inode.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index eba14c5..fb7cc7d 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -127,6 +127,8 @@ ecryptfs_do_create(struct inode *directory_inode,
 	rc = ecryptfs_interpose(lower_dentry, ecryptfs_dentry,
 				directory_inode->i_sb, 0);
 	if (rc) {
+		/* underlying file created but failing create so remove */
+		vfs_unlink(lower_dir_dentry->d_inode, lower_dentry);
 		ecryptfs_printk(KERN_ERR, "Failure in ecryptfs_interpose\n");
 		goto out_lock;
 	}
-- 
1.7.1




References