diff options
| author | Tyler Hicks <tyhicks@linux.vnet.ibm.com> | 2011-02-23 01:54:20 -0500 |
|---|---|---|
| committer | Tyler Hicks <tyhicks@linux.vnet.ibm.com> | 2011-03-28 02:47:44 -0400 |
| commit | fed8859b3ab94274c986cbdf7d27130e0545f02c (patch) | |
| tree | 01d36d5f87469aa25a7431e0b21ff86b7e524052 | |
| parent | bd4f0fe8bb7c73c738e1e11bc90d6e2cf9c6e20e (diff) | |
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 <tyhicks@linux.vnet.ibm.com>
| -rw-r--r-- | fs/ecryptfs/ecryptfs_kernel.h | 25 | ||||
| -rw-r--r-- | fs/ecryptfs/inode.c | 1 | ||||
| -rw-r--r-- | fs/ecryptfs/mmap.c | 15 |
3 files changed, 14 insertions, 27 deletions
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index e00753496e3..427478e2976 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
| @@ -257,19 +257,18 @@ struct ecryptfs_filename { | |||
| 257 | struct ecryptfs_crypt_stat { | 257 | struct ecryptfs_crypt_stat { |
| 258 | #define ECRYPTFS_STRUCT_INITIALIZED 0x00000001 | 258 | #define ECRYPTFS_STRUCT_INITIALIZED 0x00000001 |
| 259 | #define ECRYPTFS_POLICY_APPLIED 0x00000002 | 259 | #define ECRYPTFS_POLICY_APPLIED 0x00000002 |
| 260 | #define ECRYPTFS_NEW_FILE 0x00000004 | 260 | #define ECRYPTFS_ENCRYPTED 0x00000004 |
| 261 | #define ECRYPTFS_ENCRYPTED 0x00000008 | 261 | #define ECRYPTFS_SECURITY_WARNING 0x00000008 |
| 262 | #define ECRYPTFS_SECURITY_WARNING 0x00000010 | 262 | #define ECRYPTFS_ENABLE_HMAC 0x00000010 |
| 263 | #define ECRYPTFS_ENABLE_HMAC 0x00000020 | 263 | #define ECRYPTFS_ENCRYPT_IV_PAGES 0x00000020 |
| 264 | #define ECRYPTFS_ENCRYPT_IV_PAGES 0x00000040 | 264 | #define ECRYPTFS_KEY_VALID 0x00000040 |
| 265 | #define ECRYPTFS_KEY_VALID 0x00000080 | 265 | #define ECRYPTFS_METADATA_IN_XATTR 0x00000080 |
| 266 | #define ECRYPTFS_METADATA_IN_XATTR 0x00000100 | 266 | #define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000100 |
| 267 | #define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000200 | 267 | #define ECRYPTFS_KEY_SET 0x00000200 |
| 268 | #define ECRYPTFS_KEY_SET 0x00000400 | 268 | #define ECRYPTFS_ENCRYPT_FILENAMES 0x00000400 |
| 269 | #define ECRYPTFS_ENCRYPT_FILENAMES 0x00000800 | 269 | #define ECRYPTFS_ENCFN_USE_MOUNT_FNEK 0x00000800 |
| 270 | #define ECRYPTFS_ENCFN_USE_MOUNT_FNEK 0x00001000 | 270 | #define ECRYPTFS_ENCFN_USE_FEK 0x00001000 |
| 271 | #define ECRYPTFS_ENCFN_USE_FEK 0x00002000 | 271 | #define ECRYPTFS_UNLINK_SIGS 0x00002000 |
| 272 | #define ECRYPTFS_UNLINK_SIGS 0x00004000 | ||
| 273 | u32 flags; | 272 | u32 flags; |
| 274 | unsigned int file_version; | 273 | unsigned int file_version; |
| 275 | size_t iv_bytes; | 274 | size_t iv_bytes; |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 8fa365acb78..f99051b7ada 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
| @@ -161,7 +161,6 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry) | |||
| 161 | crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED); | 161 | crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED); |
| 162 | goto out; | 162 | goto out; |
| 163 | } | 163 | } |
| 164 | crypt_stat->flags |= ECRYPTFS_NEW_FILE; | ||
| 165 | ecryptfs_printk(KERN_DEBUG, "Initializing crypto context\n"); | 164 | ecryptfs_printk(KERN_DEBUG, "Initializing crypto context\n"); |
| 166 | rc = ecryptfs_new_file_context(ecryptfs_dentry); | 165 | rc = ecryptfs_new_file_context(ecryptfs_dentry); |
| 167 | if (rc) { | 166 | if (rc) { |
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index cc64fca89f8..519af27db05 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
| @@ -193,11 +193,7 @@ static int ecryptfs_readpage(struct file *file, struct page *page) | |||
| 193 | &ecryptfs_inode_to_private(page->mapping->host)->crypt_stat; | 193 | &ecryptfs_inode_to_private(page->mapping->host)->crypt_stat; |
| 194 | int rc = 0; | 194 | int rc = 0; |
| 195 | 195 | ||
| 196 | if (!crypt_stat | 196 | if (!crypt_stat || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { |
| 197 | || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED) | ||
| 198 | || (crypt_stat->flags & ECRYPTFS_NEW_FILE)) { | ||
| 199 | ecryptfs_printk(KERN_DEBUG, | ||
| 200 | "Passing through unencrypted page\n"); | ||
| 201 | rc = ecryptfs_read_lower_page_segment(page, page->index, 0, | 197 | rc = ecryptfs_read_lower_page_segment(page, page->index, 0, |
| 202 | PAGE_CACHE_SIZE, | 198 | PAGE_CACHE_SIZE, |
| 203 | page->mapping->host); | 199 | page->mapping->host); |
| @@ -295,8 +291,7 @@ static int ecryptfs_write_begin(struct file *file, | |||
| 295 | struct ecryptfs_crypt_stat *crypt_stat = | 291 | struct ecryptfs_crypt_stat *crypt_stat = |
| 296 | &ecryptfs_inode_to_private(mapping->host)->crypt_stat; | 292 | &ecryptfs_inode_to_private(mapping->host)->crypt_stat; |
| 297 | 293 | ||
| 298 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED) | 294 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { |
| 299 | || (crypt_stat->flags & ECRYPTFS_NEW_FILE)) { | ||
| 300 | rc = ecryptfs_read_lower_page_segment( | 295 | rc = ecryptfs_read_lower_page_segment( |
| 301 | page, index, 0, PAGE_CACHE_SIZE, mapping->host); | 296 | page, index, 0, PAGE_CACHE_SIZE, mapping->host); |
| 302 | if (rc) { | 297 | if (rc) { |
| @@ -487,12 +482,6 @@ static int ecryptfs_write_end(struct file *file, | |||
| 487 | &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat; | 482 | &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat; |
| 488 | int rc; | 483 | int rc; |
| 489 | 484 | ||
| 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"); | ||
| 496 | ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page" | 485 | ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page" |
| 497 | "(page w/ index = [0x%.16lx], to = [%d])\n", index, to); | 486 | "(page w/ index = [0x%.16lx], to = [%d])\n", index, to); |
| 498 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { | 487 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { |
