diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-01-30 21:50:54 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 09:00:52 -0500 |
commit | 9fd973e085f7759f710603422b2e11ad5f2e000d (patch) | |
tree | ab037487925db629c9e3c5b45475f0e97954fd1d /fs/coda | |
parent | a0a5386ac6400493cc2eb8b58583e56af0708730 (diff) |
coda: Restrict coda messages to the initial pid namespace
Remove the slight chance that pids in coda messages will be
interpreted in the wrong pid namespace.
- Explicitly send all pids in coda messages in the initial pid
namespace.
- Only allow mounts from processes in the initial pid namespace.
- Only allow processes in the initial pid namespace to open the coda
character device to communicate with coda.
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/coda')
-rw-r--r-- | fs/coda/inode.c | 4 | ||||
-rw-r--r-- | fs/coda/psdev.c | 4 | ||||
-rw-r--r-- | fs/coda/upcall.c | 4 |
3 files changed, 10 insertions, 2 deletions
diff --git a/fs/coda/inode.c b/fs/coda/inode.c index be2aa4909487..77bbaf4666a7 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/file.h> | 20 | #include <linux/file.h> |
21 | #include <linux/vfs.h> | 21 | #include <linux/vfs.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/pid_namespace.h> | ||
23 | 24 | ||
24 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
25 | 26 | ||
@@ -157,6 +158,9 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) | |||
157 | int error; | 158 | int error; |
158 | int idx; | 159 | int idx; |
159 | 160 | ||
161 | if (task_active_pid_ns(current) != &init_pid_ns) | ||
162 | return -EINVAL; | ||
163 | |||
160 | idx = get_device_index((struct coda_mount_data *) data); | 164 | idx = get_device_index((struct coda_mount_data *) data); |
161 | 165 | ||
162 | /* Ignore errors in data, for backward compatibility */ | 166 | /* Ignore errors in data, for backward compatibility */ |
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index 761d5b31b18d..dd60f905d4fe 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/list.h> | 37 | #include <linux/list.h> |
38 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
39 | #include <linux/device.h> | 39 | #include <linux/device.h> |
40 | #include <linux/pid_namespace.h> | ||
40 | #include <asm/io.h> | 41 | #include <asm/io.h> |
41 | #include <asm/poll.h> | 42 | #include <asm/poll.h> |
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
@@ -266,6 +267,9 @@ static int coda_psdev_open(struct inode * inode, struct file * file) | |||
266 | struct venus_comm *vcp; | 267 | struct venus_comm *vcp; |
267 | int idx, err; | 268 | int idx, err; |
268 | 269 | ||
270 | if (task_active_pid_ns(current) != &init_pid_ns) | ||
271 | return -EINVAL; | ||
272 | |||
269 | idx = iminor(inode); | 273 | idx = iminor(inode); |
270 | if (idx < 0 || idx >= MAX_CODADEVS) | 274 | if (idx < 0 || idx >= MAX_CODADEVS) |
271 | return -ENODEV; | 275 | return -ENODEV; |
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index 0c68fd31fbf2..5c6d2cd6ee86 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c | |||
@@ -50,8 +50,8 @@ static void *alloc_upcall(int opcode, int size) | |||
50 | return ERR_PTR(-ENOMEM); | 50 | return ERR_PTR(-ENOMEM); |
51 | 51 | ||
52 | inp->ih.opcode = opcode; | 52 | inp->ih.opcode = opcode; |
53 | inp->ih.pid = current->pid; | 53 | inp->ih.pid = task_pid_nr_ns(current, &init_pid_ns); |
54 | inp->ih.pgid = task_pgrp_nr(current); | 54 | inp->ih.pgid = task_pgrp_nr_ns(current, &init_pid_ns); |
55 | inp->ih.uid = current_fsuid(); | 55 | inp->ih.uid = current_fsuid(); |
56 | 56 | ||
57 | return (void*)inp; | 57 | return (void*)inp; |