diff options
Diffstat (limited to 'fs/ecryptfs/inode.c')
-rw-r--r-- | fs/ecryptfs/inode.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index fc7d2b748503..f0ad965d7d51 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -259,7 +259,8 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry) | |||
259 | "context; rc = [%d]\n", rc); | 259 | "context; rc = [%d]\n", rc); |
260 | goto out; | 260 | goto out; |
261 | } | 261 | } |
262 | rc = ecryptfs_get_lower_file(ecryptfs_dentry); | 262 | rc = ecryptfs_get_lower_file(ecryptfs_dentry, |
263 | ecryptfs_dentry->d_inode); | ||
263 | if (rc) { | 264 | if (rc) { |
264 | printk(KERN_ERR "%s: Error attempting to initialize " | 265 | printk(KERN_ERR "%s: Error attempting to initialize " |
265 | "the lower file for the dentry with name " | 266 | "the lower file for the dentry with name " |
@@ -350,50 +351,51 @@ static int ecryptfs_lookup_interpose(struct dentry *ecryptfs_dentry, | |||
350 | __func__, rc); | 351 | __func__, rc); |
351 | goto out; | 352 | goto out; |
352 | } | 353 | } |
353 | if (inode->i_state & I_NEW) | 354 | if (!S_ISREG(inode->i_mode)) { |
354 | unlock_new_inode(inode); | 355 | if (inode->i_state & I_NEW) |
355 | d_add(ecryptfs_dentry, inode); | 356 | unlock_new_inode(inode); |
356 | if (S_ISDIR(lower_inode->i_mode)) | 357 | d_add(ecryptfs_dentry, inode); |
357 | goto out; | ||
358 | if (S_ISLNK(lower_inode->i_mode)) | ||
359 | goto out; | ||
360 | if (special_file(lower_inode->i_mode)) | ||
361 | goto out; | 358 | goto out; |
359 | } | ||
362 | /* Released in this function */ | 360 | /* Released in this function */ |
363 | page_virt = kmem_cache_zalloc(ecryptfs_header_cache_2, GFP_USER); | 361 | page_virt = kmem_cache_zalloc(ecryptfs_header_cache_2, GFP_USER); |
364 | if (!page_virt) { | 362 | if (!page_virt) { |
365 | printk(KERN_ERR "%s: Cannot kmem_cache_zalloc() a page\n", | 363 | printk(KERN_ERR "%s: Cannot kmem_cache_zalloc() a page\n", |
366 | __func__); | 364 | __func__); |
367 | rc = -ENOMEM; | 365 | rc = -ENOMEM; |
366 | make_bad_inode(inode); | ||
368 | goto out; | 367 | goto out; |
369 | } | 368 | } |
370 | rc = ecryptfs_get_lower_file(ecryptfs_dentry); | 369 | rc = ecryptfs_get_lower_file(ecryptfs_dentry, inode); |
371 | if (rc) { | 370 | if (rc) { |
372 | printk(KERN_ERR "%s: Error attempting to initialize " | 371 | printk(KERN_ERR "%s: Error attempting to initialize " |
373 | "the lower file for the dentry with name " | 372 | "the lower file for the dentry with name " |
374 | "[%s]; rc = [%d]\n", __func__, | 373 | "[%s]; rc = [%d]\n", __func__, |
375 | ecryptfs_dentry->d_name.name, rc); | 374 | ecryptfs_dentry->d_name.name, rc); |
375 | make_bad_inode(inode); | ||
376 | goto out_free_kmem; | 376 | goto out_free_kmem; |
377 | } | 377 | } |
378 | put_lower = 1; | 378 | put_lower = 1; |
379 | crypt_stat = &ecryptfs_inode_to_private( | 379 | crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat; |
380 | ecryptfs_dentry->d_inode)->crypt_stat; | ||
381 | /* TODO: lock for crypt_stat comparison */ | 380 | /* TODO: lock for crypt_stat comparison */ |
382 | if (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED)) | 381 | if (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED)) |
383 | ecryptfs_set_default_sizes(crypt_stat); | 382 | ecryptfs_set_default_sizes(crypt_stat); |
384 | rc = ecryptfs_read_and_validate_header_region(page_virt, | 383 | rc = ecryptfs_read_and_validate_header_region(page_virt, inode); |
385 | ecryptfs_dentry->d_inode); | ||
386 | if (rc) { | 384 | if (rc) { |
387 | memset(page_virt, 0, PAGE_CACHE_SIZE); | 385 | memset(page_virt, 0, PAGE_CACHE_SIZE); |
388 | rc = ecryptfs_read_and_validate_xattr_region(page_virt, | 386 | rc = ecryptfs_read_and_validate_xattr_region(page_virt, |
389 | ecryptfs_dentry); | 387 | inode); |
390 | if (rc) { | 388 | if (rc) { |
391 | rc = 0; | 389 | rc = 0; |
392 | goto out_free_kmem; | 390 | goto unlock_inode; |
393 | } | 391 | } |
394 | crypt_stat->flags |= ECRYPTFS_METADATA_IN_XATTR; | 392 | crypt_stat->flags |= ECRYPTFS_METADATA_IN_XATTR; |
395 | } | 393 | } |
396 | ecryptfs_i_size_init(page_virt, ecryptfs_dentry->d_inode); | 394 | ecryptfs_i_size_init(page_virt, inode); |
395 | unlock_inode: | ||
396 | if (inode->i_state & I_NEW) | ||
397 | unlock_new_inode(inode); | ||
398 | d_add(ecryptfs_dentry, inode); | ||
397 | out_free_kmem: | 399 | out_free_kmem: |
398 | kmem_cache_free(ecryptfs_header_cache_2, page_virt); | 400 | kmem_cache_free(ecryptfs_header_cache_2, page_virt); |
399 | goto out; | 401 | goto out; |
@@ -403,7 +405,7 @@ out_put: | |||
403 | d_drop(ecryptfs_dentry); | 405 | d_drop(ecryptfs_dentry); |
404 | out: | 406 | out: |
405 | if (put_lower) | 407 | if (put_lower) |
406 | ecryptfs_put_lower_file(ecryptfs_dentry->d_inode); | 408 | ecryptfs_put_lower_file(inode); |
407 | return rc; | 409 | return rc; |
408 | } | 410 | } |
409 | 411 | ||
@@ -843,7 +845,7 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia, | |||
843 | lower_ia->ia_valid &= ~ATTR_SIZE; | 845 | lower_ia->ia_valid &= ~ATTR_SIZE; |
844 | return 0; | 846 | return 0; |
845 | } | 847 | } |
846 | rc = ecryptfs_get_lower_file(dentry); | 848 | rc = ecryptfs_get_lower_file(dentry, inode); |
847 | if (rc) | 849 | if (rc) |
848 | return rc; | 850 | return rc; |
849 | crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat; | 851 | crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat; |
@@ -999,7 +1001,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia) | |||
999 | 1001 | ||
1000 | mount_crypt_stat = &ecryptfs_superblock_to_private( | 1002 | mount_crypt_stat = &ecryptfs_superblock_to_private( |
1001 | dentry->d_sb)->mount_crypt_stat; | 1003 | dentry->d_sb)->mount_crypt_stat; |
1002 | rc = ecryptfs_get_lower_file(dentry); | 1004 | rc = ecryptfs_get_lower_file(dentry, inode); |
1003 | if (rc) { | 1005 | if (rc) { |
1004 | mutex_unlock(&crypt_stat->cs_mutex); | 1006 | mutex_unlock(&crypt_stat->cs_mutex); |
1005 | goto out; | 1007 | goto out; |