Skip to content

Commit bd4f0fe

Browse files
author
Tyler Hicks
committed
eCryptfs: Remove unnecessary grow_file() function
When creating a new eCryptfs file, the crypto metadata is written out and then the lower file was being "grown" with 4 kB of encrypted zeroes. I suspect that growing the encrypted file was to prevent an information leak that the unencrypted file was empty. However, the unencrypted file size is stored, in plaintext, in the metadata so growing the file is unnecessary. Signed-off-by: Tyler Hicks <[email protected]>
1 parent 4047185 commit bd4f0fe

File tree

2 files changed

+1
-23
lines changed

2 files changed

+1
-23
lines changed

fs/ecryptfs/crypto.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,7 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry)
13891389
rc = -ENOMEM;
13901390
goto out;
13911391
}
1392+
/* Zeroed page ensures the in-header unencrypted i_size is set to 0 */
13921393
rc = ecryptfs_write_headers_virt(virt, virt_len, &size, crypt_stat,
13931394
ecryptfs_dentry);
13941395
if (unlikely(rc)) {

fs/ecryptfs/inode.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,6 @@ ecryptfs_do_create(struct inode *directory_inode,
142142
return rc;
143143
}
144144

145-
/**
146-
* grow_file
147-
* @ecryptfs_dentry: the eCryptfs dentry
148-
*
149-
* This is the code which will grow the file to its correct size.
150-
*/
151-
static int grow_file(struct dentry *ecryptfs_dentry)
152-
{
153-
struct inode *ecryptfs_inode = ecryptfs_dentry->d_inode;
154-
char zero_virt[] = { 0x00 };
155-
int rc = 0;
156-
157-
rc = ecryptfs_write(ecryptfs_inode, zero_virt, 0, 1);
158-
i_size_write(ecryptfs_inode, 0);
159-
rc = ecryptfs_write_inode_size_to_metadata(ecryptfs_inode);
160-
ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat.flags |=
161-
ECRYPTFS_NEW_FILE;
162-
return rc;
163-
}
164-
165145
/**
166146
* ecryptfs_initialize_file
167147
*
@@ -202,9 +182,6 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
202182
printk(KERN_ERR "Error writing headers; rc = [%d]\n", rc);
203183
goto out;
204184
}
205-
rc = grow_file(ecryptfs_dentry);
206-
if (rc)
207-
printk(KERN_ERR "Error growing file; rc = [%d]\n", rc);
208185
out:
209186
return rc;
210187
}

0 commit comments

Comments
 (0)