Skip to content

Commit fed8859

Browse files
author
Tyler Hicks
committed
eCryptfs: Remove ECRYPTFS_NEW_FILE crypt stat flag
Now that grow_file() is not called in the ecryptfs_create() path, the ECRYPTFS_NEW_FILE flag is no longer needed. It helped ecryptfs_readpage() know not to decrypt zeroes that were read from the lower file in the grow_file() path. Signed-off-by: Tyler Hicks <[email protected]>
1 parent bd4f0fe commit fed8859

File tree

3 files changed

+14
-27
lines changed

3 files changed

+14
-27
lines changed

fs/ecryptfs/ecryptfs_kernel.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,18 @@ struct ecryptfs_filename {
257257
struct ecryptfs_crypt_stat {
258258
#define ECRYPTFS_STRUCT_INITIALIZED 0x00000001
259259
#define ECRYPTFS_POLICY_APPLIED 0x00000002
260-
#define ECRYPTFS_NEW_FILE 0x00000004
261-
#define ECRYPTFS_ENCRYPTED 0x00000008
262-
#define ECRYPTFS_SECURITY_WARNING 0x00000010
263-
#define ECRYPTFS_ENABLE_HMAC 0x00000020
264-
#define ECRYPTFS_ENCRYPT_IV_PAGES 0x00000040
265-
#define ECRYPTFS_KEY_VALID 0x00000080
266-
#define ECRYPTFS_METADATA_IN_XATTR 0x00000100
267-
#define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000200
268-
#define ECRYPTFS_KEY_SET 0x00000400
269-
#define ECRYPTFS_ENCRYPT_FILENAMES 0x00000800
270-
#define ECRYPTFS_ENCFN_USE_MOUNT_FNEK 0x00001000
271-
#define ECRYPTFS_ENCFN_USE_FEK 0x00002000
272-
#define ECRYPTFS_UNLINK_SIGS 0x00004000
260+
#define ECRYPTFS_ENCRYPTED 0x00000004
261+
#define ECRYPTFS_SECURITY_WARNING 0x00000008
262+
#define ECRYPTFS_ENABLE_HMAC 0x00000010
263+
#define ECRYPTFS_ENCRYPT_IV_PAGES 0x00000020
264+
#define ECRYPTFS_KEY_VALID 0x00000040
265+
#define ECRYPTFS_METADATA_IN_XATTR 0x00000080
266+
#define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000100
267+
#define ECRYPTFS_KEY_SET 0x00000200
268+
#define ECRYPTFS_ENCRYPT_FILENAMES 0x00000400
269+
#define ECRYPTFS_ENCFN_USE_MOUNT_FNEK 0x00000800
270+
#define ECRYPTFS_ENCFN_USE_FEK 0x00001000
271+
#define ECRYPTFS_UNLINK_SIGS 0x00002000
273272
u32 flags;
274273
unsigned int file_version;
275274
size_t iv_bytes;

fs/ecryptfs/inode.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
161161
crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
162162
goto out;
163163
}
164-
crypt_stat->flags |= ECRYPTFS_NEW_FILE;
165164
ecryptfs_printk(KERN_DEBUG, "Initializing crypto context\n");
166165
rc = ecryptfs_new_file_context(ecryptfs_dentry);
167166
if (rc) {

fs/ecryptfs/mmap.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,7 @@ static int ecryptfs_readpage(struct file *file, struct page *page)
193193
&ecryptfs_inode_to_private(page->mapping->host)->crypt_stat;
194194
int rc = 0;
195195

196-
if (!crypt_stat
197-
|| !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)
198-
|| (crypt_stat->flags & ECRYPTFS_NEW_FILE)) {
199-
ecryptfs_printk(KERN_DEBUG,
200-
"Passing through unencrypted page\n");
196+
if (!crypt_stat || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
201197
rc = ecryptfs_read_lower_page_segment(page, page->index, 0,
202198
PAGE_CACHE_SIZE,
203199
page->mapping->host);
@@ -295,8 +291,7 @@ static int ecryptfs_write_begin(struct file *file,
295291
struct ecryptfs_crypt_stat *crypt_stat =
296292
&ecryptfs_inode_to_private(mapping->host)->crypt_stat;
297293

298-
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)
299-
|| (crypt_stat->flags & ECRYPTFS_NEW_FILE)) {
294+
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
300295
rc = ecryptfs_read_lower_page_segment(
301296
page, index, 0, PAGE_CACHE_SIZE, mapping->host);
302297
if (rc) {
@@ -487,12 +482,6 @@ static int ecryptfs_write_end(struct file *file,
487482
&ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat;
488483
int rc;
489484

490-
if (crypt_stat->flags & ECRYPTFS_NEW_FILE) {
491-
ecryptfs_printk(KERN_DEBUG, "ECRYPTFS_NEW_FILE flag set in "
492-
"crypt_stat at memory location [%p]\n", crypt_stat);
493-
crypt_stat->flags &= ~(ECRYPTFS_NEW_FILE);
494-
} else
495-
ecryptfs_printk(KERN_DEBUG, "Not a new file\n");
496485
ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page"
497486
"(page w/ index = [0x%.16lx], to = [%d])\n", index, to);
498487
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {

0 commit comments

Comments
 (0)