diff options
author | Tyler Hicks <tyhicks@linux.vnet.ibm.com> | 2009-04-13 16:29:27 -0400 |
---|---|---|
committer | Tyler Hicks <tyhicks@linux.vnet.ibm.com> | 2009-04-22 04:54:13 -0400 |
commit | 13a791b4e63eb0537a7f804a340d6527485983b4 (patch) | |
tree | ad3c74093e8efe0da14644a0dc16ac0c61b2e6e5 /fs/ecryptfs/inode.c | |
parent | 3a5203ab3c0c31e0f1434c69e893bfb85c6e6657 (diff) |
eCryptfs: Fix data corruption when using ecryptfs_passthrough
ecryptfs_passthrough is a mount option that allows eCryptfs to allow
data to be written to non-eCryptfs files in the lower filesystem. The
passthrough option was causing data corruption due to it not always
being treated as a non-eCryptfs file.
The first 8 bytes of an eCryptfs file contains the decrypted file size.
This value was being written to the non-eCryptfs files, too. Also,
extra 0x00 characters were being written to make the file size a
multiple of PAGE_CACHE_SIZE.
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
Diffstat (limited to 'fs/ecryptfs/inode.c')
-rw-r--r-- | fs/ecryptfs/inode.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 55b3145b8072..5ed86e25b8a2 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -814,6 +814,13 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length) | |||
814 | size_t num_zeros = (PAGE_CACHE_SIZE | 814 | size_t num_zeros = (PAGE_CACHE_SIZE |
815 | - (new_length & ~PAGE_CACHE_MASK)); | 815 | - (new_length & ~PAGE_CACHE_MASK)); |
816 | 816 | ||
817 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { | ||
818 | rc = vmtruncate(inode, new_length); | ||
819 | if (rc) | ||
820 | goto out_free; | ||
821 | rc = vmtruncate(lower_dentry->d_inode, new_length); | ||
822 | goto out_free; | ||
823 | } | ||
817 | if (num_zeros) { | 824 | if (num_zeros) { |
818 | char *zeros_virt; | 825 | char *zeros_virt; |
819 | 826 | ||
@@ -915,8 +922,6 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia) | |||
915 | } | 922 | } |
916 | rc = 0; | 923 | rc = 0; |
917 | crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED); | 924 | crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED); |
918 | mutex_unlock(&crypt_stat->cs_mutex); | ||
919 | goto out; | ||
920 | } | 925 | } |
921 | } | 926 | } |
922 | mutex_unlock(&crypt_stat->cs_mutex); | 927 | mutex_unlock(&crypt_stat->cs_mutex); |