aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/miscdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ecryptfs/miscdev.c')
-rw-r--r--fs/ecryptfs/miscdev.c27
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)
42{ 42{
43 struct ecryptfs_daemon *daemon; 43 struct ecryptfs_daemon *daemon;
44 unsigned int mask = 0; 44 unsigned int mask = 0;
45 uid_t euid = current_euid();
45 int rc; 46 int rc;
46 47
47 mutex_lock(&ecryptfs_daemon_hash_mux); 48 mutex_lock(&ecryptfs_daemon_hash_mux);
48 /* TODO: Just use file->private_data? */ 49 /* TODO: Just use file->private_data? */
49 rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, 50 rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());
50 current->nsproxy->user_ns);
51 BUG_ON(rc || !daemon); 51 BUG_ON(rc || !daemon);
52 mutex_lock(&daemon->mux); 52 mutex_lock(&daemon->mux);
53 mutex_unlock(&ecryptfs_daemon_hash_mux); 53 mutex_unlock(&ecryptfs_daemon_hash_mux);
@@ -83,6 +83,7 @@ static int
83ecryptfs_miscdev_open(struct inode *inode, struct file *file) 83ecryptfs_miscdev_open(struct inode *inode, struct file *file)
84{ 84{
85 struct ecryptfs_daemon *daemon = NULL; 85 struct ecryptfs_daemon *daemon = NULL;
86 uid_t euid = current_euid();
86 int rc; 87 int rc;
87 88
88 mutex_lock(&ecryptfs_daemon_hash_mux); 89 mutex_lock(&ecryptfs_daemon_hash_mux);
@@ -93,11 +94,9 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
93 "count; rc = [%d]\n", __func__, rc); 94 "count; rc = [%d]\n", __func__, rc);
94 goto out_unlock_daemon_list; 95 goto out_unlock_daemon_list;
95 } 96 }
96 rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, 97 rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());
97 current->nsproxy->user_ns);
98 if (rc || !daemon) { 98 if (rc || !daemon) {
99 rc = ecryptfs_spawn_daemon(&daemon, current->euid, 99 rc = ecryptfs_spawn_daemon(&daemon, euid, current_user_ns(),
100 current->nsproxy->user_ns,
101 task_pid(current)); 100 task_pid(current));
102 if (rc) { 101 if (rc) {
103 printk(KERN_ERR "%s: Error attempting to spawn daemon; " 102 printk(KERN_ERR "%s: Error attempting to spawn daemon; "
@@ -147,11 +146,11 @@ static int
147ecryptfs_miscdev_release(struct inode *inode, struct file *file) 146ecryptfs_miscdev_release(struct inode *inode, struct file *file)
148{ 147{
149 struct ecryptfs_daemon *daemon = NULL; 148 struct ecryptfs_daemon *daemon = NULL;
149 uid_t euid = current_euid();
150 int rc; 150 int rc;
151 151
152 mutex_lock(&ecryptfs_daemon_hash_mux); 152 mutex_lock(&ecryptfs_daemon_hash_mux);
153 rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, 153 rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());
154 current->nsproxy->user_ns);
155 BUG_ON(rc || !daemon); 154 BUG_ON(rc || !daemon);
156 mutex_lock(&daemon->mux); 155 mutex_lock(&daemon->mux);
157 BUG_ON(daemon->pid != task_pid(current)); 156 BUG_ON(daemon->pid != task_pid(current));
@@ -246,12 +245,12 @@ ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count,
246 char packet_length[3]; 245 char packet_length[3];
247 size_t i; 246 size_t i;
248 size_t total_length; 247 size_t total_length;
248 uid_t euid = current_euid();
249 int rc; 249 int rc;
250 250
251 mutex_lock(&ecryptfs_daemon_hash_mux); 251 mutex_lock(&ecryptfs_daemon_hash_mux);
252 /* TODO: Just use file->private_data? */ 252 /* TODO: Just use file->private_data? */
253 rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, 253 rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());
254 current->nsproxy->user_ns);
255 BUG_ON(rc || !daemon); 254 BUG_ON(rc || !daemon);
256 mutex_lock(&daemon->mux); 255 mutex_lock(&daemon->mux);
257 if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { 256 if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) {
@@ -290,8 +289,8 @@ check_list:
290 * message from the queue; try again */ 289 * message from the queue; try again */
291 goto check_list; 290 goto check_list;
292 } 291 }
293 BUG_ON(current->euid != daemon->euid); 292 BUG_ON(euid != daemon->euid);
294 BUG_ON(current->nsproxy->user_ns != daemon->user_ns); 293 BUG_ON(current_user_ns() != daemon->user_ns);
295 BUG_ON(task_pid(current) != daemon->pid); 294 BUG_ON(task_pid(current) != daemon->pid);
296 msg_ctx = list_first_entry(&daemon->msg_ctx_out_queue, 295 msg_ctx = list_first_entry(&daemon->msg_ctx_out_queue,
297 struct ecryptfs_msg_ctx, daemon_out_list); 296 struct ecryptfs_msg_ctx, daemon_out_list);
@@ -414,6 +413,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
414 size_t packet_size, packet_size_length, i; 413 size_t packet_size, packet_size_length, i;
415 ssize_t sz = 0; 414 ssize_t sz = 0;
416 char *data; 415 char *data;
416 uid_t euid = current_euid();
417 int rc; 417 int rc;
418 418
419 if (count == 0) 419 if (count == 0)
@@ -463,8 +463,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
463 goto out_free; 463 goto out_free;
464 } 464 }
465 rc = ecryptfs_miscdev_response(&data[i], packet_size, 465 rc = ecryptfs_miscdev_response(&data[i], packet_size,
466 current->euid, 466 euid, current_user_ns(),
467 current->nsproxy->user_ns,
468 task_pid(current), seq); 467 task_pid(current), seq);
469 if (rc) 468 if (rc)
470 printk(KERN_WARNING "%s: Failed to deliver miscdev " 469 printk(KERN_WARNING "%s: Failed to deliver miscdev "