Commit fed8859b3ab94274c986cbdf7d27130e0545f02c

Authored by Tyler Hicks
1 parent bd4f0fe8bb

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>

Showing 3 changed files with 14 additions and 27 deletions Side-by-side Diff

fs/ecryptfs/ecryptfs_kernel.h
... ... @@ -257,19 +257,18 @@
257 257 struct ecryptfs_crypt_stat {
258 258 #define ECRYPTFS_STRUCT_INITIALIZED 0x00000001
259 259 #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
273 272 u32 flags;
274 273 unsigned int file_version;
275 274 size_t iv_bytes;
... ... @@ -161,7 +161,6 @@
161 161 crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
162 162 goto out;
163 163 }
164   - crypt_stat->flags |= ECRYPTFS_NEW_FILE;
165 164 ecryptfs_printk(KERN_DEBUG, "Initializing crypto context\n");
166 165 rc = ecryptfs_new_file_context(ecryptfs_dentry);
167 166 if (rc) {
... ... @@ -193,11 +193,7 @@
193 193 &ecryptfs_inode_to_private(page->mapping->host)->crypt_stat;
194 194 int rc = 0;
195 195  
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)) {
201 197 rc = ecryptfs_read_lower_page_segment(page, page->index, 0,
202 198 PAGE_CACHE_SIZE,
203 199 page->mapping->host);
... ... @@ -295,8 +291,7 @@
295 291 struct ecryptfs_crypt_stat *crypt_stat =
296 292 &ecryptfs_inode_to_private(mapping->host)->crypt_stat;
297 293  
298   - if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)
299   - || (crypt_stat->flags & ECRYPTFS_NEW_FILE)) {
  294 + if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
300 295 rc = ecryptfs_read_lower_page_segment(
301 296 page, index, 0, PAGE_CACHE_SIZE, mapping->host);
302 297 if (rc) {
... ... @@ -487,12 +482,6 @@
487 482 &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat;
488 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 485 ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page"
497 486 "(page w/ index = [0x%.16lx], to = [%d])\n", index, to);
498 487 if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {