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