Commit 27992890b02d340198a3a22fc210d13684a41564

Authored by Roberto Sassu
Committed by Tyler Hicks
1 parent 070baa5128

ecryptfs: test lower_file pointer when lower_file_mutex is locked

This patch prevents the lower_file pointer in the 'ecryptfs_inode_info'
structure to be checked when the mutex 'lower_file_mutex' is not locked.

Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>

Showing 2 changed files with 21 additions and 27 deletions Side-by-side Diff

... ... @@ -191,15 +191,13 @@
191 191 | ECRYPTFS_ENCRYPTED);
192 192 }
193 193 mutex_unlock(&crypt_stat->cs_mutex);
194   - if (!ecryptfs_inode_to_private(inode)->lower_file) {
195   - rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
196   - if (rc) {
197   - printk(KERN_ERR "%s: Error attempting to initialize "
198   - "the persistent file for the dentry with name "
199   - "[%s]; rc = [%d]\n", __func__,
200   - ecryptfs_dentry->d_name.name, rc);
201   - goto out_free;
202   - }
  194 + rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
  195 + if (rc) {
  196 + printk(KERN_ERR "%s: Error attempting to initialize "
  197 + "the persistent file for the dentry with name "
  198 + "[%s]; rc = [%d]\n", __func__,
  199 + ecryptfs_dentry->d_name.name, rc);
  200 + goto out_free;
203 201 }
204 202 if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY)
205 203 && !(file->f_flags & O_RDONLY)) {
... ... @@ -185,15 +185,13 @@
185 185 "context; rc = [%d]\n", rc);
186 186 goto out;
187 187 }
188   - if (!ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->lower_file) {
189   - rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
190   - if (rc) {
191   - printk(KERN_ERR "%s: Error attempting to initialize "
192   - "the persistent file for the dentry with name "
193   - "[%s]; rc = [%d]\n", __func__,
194   - ecryptfs_dentry->d_name.name, rc);
195   - goto out;
196   - }
  188 + rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
  189 + if (rc) {
  190 + printk(KERN_ERR "%s: Error attempting to initialize "
  191 + "the persistent file for the dentry with name "
  192 + "[%s]; rc = [%d]\n", __func__,
  193 + ecryptfs_dentry->d_name.name, rc);
  194 + goto out;
197 195 }
198 196 rc = ecryptfs_write_metadata(ecryptfs_dentry);
199 197 if (rc) {
... ... @@ -302,15 +300,13 @@
302 300 rc = -ENOMEM;
303 301 goto out;
304 302 }
305   - if (!ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->lower_file) {
306   - rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
307   - if (rc) {
308   - printk(KERN_ERR "%s: Error attempting to initialize "
309   - "the persistent file for the dentry with name "
310   - "[%s]; rc = [%d]\n", __func__,
311   - ecryptfs_dentry->d_name.name, rc);
312   - goto out_free_kmem;
313   - }
  303 + rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
  304 + if (rc) {
  305 + printk(KERN_ERR "%s: Error attempting to initialize "
  306 + "the persistent file for the dentry with name "
  307 + "[%s]; rc = [%d]\n", __func__,
  308 + ecryptfs_dentry->d_name.name, rc);
  309 + goto out_free_kmem;
314 310 }
315 311 crypt_stat = &ecryptfs_inode_to_private(
316 312 ecryptfs_dentry->d_inode)->crypt_stat;