diff options
Diffstat (limited to 'fs/ecryptfs/miscdev.c')
| -rw-r--r-- | fs/ecryptfs/miscdev.c | 27 | 
1 files changed, 13 insertions, 14 deletions
diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c index b484792a0996..efd95a0ed1ea 100644 --- a/fs/ecryptfs/miscdev.c +++ b/fs/ecryptfs/miscdev.c @@ -42,12 +42,12 @@ ecryptfs_miscdev_poll(struct file *file, poll_table *pt)  {  	struct ecryptfs_daemon *daemon;  	unsigned int mask = 0; +	uid_t euid = current_euid();  	int rc;  	mutex_lock(&ecryptfs_daemon_hash_mux);  	/* TODO: Just use file->private_data? */ -	rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, -					  current->nsproxy->user_ns); +	rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());  	BUG_ON(rc || !daemon);  	mutex_lock(&daemon->mux);  	mutex_unlock(&ecryptfs_daemon_hash_mux); @@ -83,6 +83,7 @@ static int  ecryptfs_miscdev_open(struct inode *inode, struct file *file)  {  	struct ecryptfs_daemon *daemon = NULL; +	uid_t euid = current_euid();  	int rc;  	mutex_lock(&ecryptfs_daemon_hash_mux); @@ -93,11 +94,9 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)  		       "count; rc = [%d]\n", __func__, rc);  		goto out_unlock_daemon_list;  	} -	rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, -					  current->nsproxy->user_ns); +	rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());  	if (rc || !daemon) { -		rc = ecryptfs_spawn_daemon(&daemon, current->euid, -					   current->nsproxy->user_ns, +		rc = ecryptfs_spawn_daemon(&daemon, euid, current_user_ns(),  					   task_pid(current));  		if (rc) {  			printk(KERN_ERR "%s: Error attempting to spawn daemon; " @@ -147,11 +146,11 @@ static int  ecryptfs_miscdev_release(struct inode *inode, struct file *file)  {  	struct ecryptfs_daemon *daemon = NULL; +	uid_t euid = current_euid();  	int rc;  	mutex_lock(&ecryptfs_daemon_hash_mux); -	rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, -					  current->nsproxy->user_ns); +	rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());  	BUG_ON(rc || !daemon);  	mutex_lock(&daemon->mux);  	BUG_ON(daemon->pid != task_pid(current)); @@ -246,12 +245,12 @@ ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count,  	char packet_length[3];  	size_t i;  	size_t total_length; +	uid_t euid = current_euid();  	int rc;  	mutex_lock(&ecryptfs_daemon_hash_mux);  	/* TODO: Just use file->private_data? */ -	rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, -					  current->nsproxy->user_ns); +	rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());  	BUG_ON(rc || !daemon);  	mutex_lock(&daemon->mux);  	if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { @@ -290,8 +289,8 @@ check_list:  		 * message from the queue; try again */  		goto check_list;  	} -	BUG_ON(current->euid != daemon->euid); -	BUG_ON(current->nsproxy->user_ns != daemon->user_ns); +	BUG_ON(euid != daemon->euid); +	BUG_ON(current_user_ns() != daemon->user_ns);  	BUG_ON(task_pid(current) != daemon->pid);  	msg_ctx = list_first_entry(&daemon->msg_ctx_out_queue,  				   struct ecryptfs_msg_ctx, daemon_out_list); @@ -414,6 +413,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,  	size_t packet_size, packet_size_length, i;  	ssize_t sz = 0;  	char *data; +	uid_t euid = current_euid();  	int rc;  	if (count == 0) @@ -463,8 +463,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,  			goto out_free;  		}  		rc = ecryptfs_miscdev_response(&data[i], packet_size, -					       current->euid, -					       current->nsproxy->user_ns, +					       euid, current_user_ns(),  					       task_pid(current), seq);  		if (rc)  			printk(KERN_WARNING "%s: Failed to deliver miscdev "  | 
