aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/inode.c
diff options
context:
space:
mode:
authorTyler Hicks <tyhicks@canonical.com>2012-06-20 23:50:59 -0700
committerBen Hutchings <ben@decadent.org.uk>2012-10-17 03:49:52 +0100
commit5fb231c6b869110087e70b42b1dd6b5279045eb3 (patch)
tree5082ac61cb6875b65ed0f3981ffa894dd3db448a /fs/ecryptfs/inode.c
parent04661578e516400ca013a5bba87a2868bfb31610 (diff)
downloadkernel_samsung_smdk4412-5fb231c6b869110087e70b42b1dd6b5279045eb3.zip
kernel_samsung_smdk4412-5fb231c6b869110087e70b42b1dd6b5279045eb3.tar.gz
kernel_samsung_smdk4412-5fb231c6b869110087e70b42b1dd6b5279045eb3.tar.bz2
eCryptfs: Initialize empty lower files when opening them
commit e3ccaa9761200952cc269b1f4b7d7bb77a5e071b upstream. Historically, eCryptfs has only initialized lower files in the ecryptfs_create() path. Lower file initialization is the act of writing the cryptographic metadata from the inode's crypt_stat to the header of the file. The ecryptfs_open() path already expects that metadata to be in the header of the file. A number of users have reported empty lower files in beneath their eCryptfs mounts. Most of the causes for those empty files being left around have been addressed, but the presence of empty files causes problems due to the lack of proper cryptographic metadata. To transparently solve this problem, this patch initializes empty lower files in the ecryptfs_open() error path. If the metadata is unreadable due to the lower inode size being 0, plaintext passthrough support is not in use, and the metadata is stored in the header of the file (as opposed to the user.ecryptfs extended attribute), the lower file will be initialized. The number of nested conditionals in ecryptfs_open() was getting out of hand, so a helper function was created. To avoid the same nested conditional problem, the conditional logic was reversed inside of the helper function. https://launchpad.net/bugs/911507 Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Cc: John Johansen <john.johansen@canonical.com> Cc: Colin Ian King <colin.king@canonical.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'fs/ecryptfs/inode.c')
-rw-r--r--fs/ecryptfs/inode.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index f20787b..66f7cb6 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -246,8 +246,8 @@ out:
*
* Returns zero on success
*/
-static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,
- struct inode *ecryptfs_inode)
+int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,
+ struct inode *ecryptfs_inode)
{
struct ecryptfs_crypt_stat *crypt_stat =
&ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat;