Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27992890 authored by Roberto Sassu's avatar Roberto Sassu Committed by Tyler Hicks
Browse files

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: default avatarRoberto Sassu <roberto.sassu@polito.it>
Signed-off-by: default avatarTyler Hicks <tyhicks@linux.vnet.ibm.com>
parent 070baa51
Loading
Loading
Loading
Loading
+7 −9
Original line number Original line Diff line number Diff line
@@ -191,7 +191,6 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
				      | ECRYPTFS_ENCRYPTED);
				      | ECRYPTFS_ENCRYPTED);
	}
	}
	mutex_unlock(&crypt_stat->cs_mutex);
	mutex_unlock(&crypt_stat->cs_mutex);
	if (!ecryptfs_inode_to_private(inode)->lower_file) {
	rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
	rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
	if (rc) {
	if (rc) {
		printk(KERN_ERR "%s: Error attempting to initialize "
		printk(KERN_ERR "%s: Error attempting to initialize "
@@ -200,7 +199,6 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
			ecryptfs_dentry->d_name.name, rc);
			ecryptfs_dentry->d_name.name, rc);
		goto out_free;
		goto out_free;
	}
	}
	}
	if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY)
	if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY)
	    && !(file->f_flags & O_RDONLY)) {
	    && !(file->f_flags & O_RDONLY)) {
		rc = -EPERM;
		rc = -EPERM;
+14 −18
Original line number Original line Diff line number Diff line
@@ -185,7 +185,6 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
				"context; rc = [%d]\n", rc);
				"context; rc = [%d]\n", rc);
		goto out;
		goto out;
	}
	}
	if (!ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->lower_file) {
	rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
	rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
	if (rc) {
	if (rc) {
		printk(KERN_ERR "%s: Error attempting to initialize "
		printk(KERN_ERR "%s: Error attempting to initialize "
@@ -194,7 +193,6 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
			ecryptfs_dentry->d_name.name, rc);
			ecryptfs_dentry->d_name.name, rc);
		goto out;
		goto out;
	}
	}
	}
	rc = ecryptfs_write_metadata(ecryptfs_dentry);
	rc = ecryptfs_write_metadata(ecryptfs_dentry);
	if (rc) {
	if (rc) {
		printk(KERN_ERR "Error writing headers; rc = [%d]\n", rc);
		printk(KERN_ERR "Error writing headers; rc = [%d]\n", rc);
@@ -302,7 +300,6 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry,
		rc = -ENOMEM;
		rc = -ENOMEM;
		goto out;
		goto out;
	}
	}
	if (!ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->lower_file) {
	rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
	rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
	if (rc) {
	if (rc) {
		printk(KERN_ERR "%s: Error attempting to initialize "
		printk(KERN_ERR "%s: Error attempting to initialize "
@@ -311,7 +308,6 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry,
			ecryptfs_dentry->d_name.name, rc);
			ecryptfs_dentry->d_name.name, rc);
		goto out_free_kmem;
		goto out_free_kmem;
	}
	}
	}
	crypt_stat = &ecryptfs_inode_to_private(
	crypt_stat = &ecryptfs_inode_to_private(
					ecryptfs_dentry->d_inode)->crypt_stat;
					ecryptfs_dentry->d_inode)->crypt_stat;
	/* TODO: lock for crypt_stat comparison */
	/* TODO: lock for crypt_stat comparison */