提交 9fd973e0 编写于 作者: E Eric W. Biederman

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: N"Eric W. Biederman" <ebiederm@xmission.com>
上级 a0a5386a
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/file.h> #include <linux/file.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pid_namespace.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -157,6 +158,9 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) ...@@ -157,6 +158,9 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)
int error; int error;
int idx; int idx;
if (task_active_pid_ns(current) != &init_pid_ns)
return -EINVAL;
idx = get_device_index((struct coda_mount_data *) data); idx = get_device_index((struct coda_mount_data *) data);
/* Ignore errors in data, for backward compatibility */ /* Ignore errors in data, for backward compatibility */
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/pid_namespace.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/poll.h> #include <asm/poll.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -266,6 +267,9 @@ static int coda_psdev_open(struct inode * inode, struct file * file) ...@@ -266,6 +267,9 @@ static int coda_psdev_open(struct inode * inode, struct file * file)
struct venus_comm *vcp; struct venus_comm *vcp;
int idx, err; int idx, err;
if (task_active_pid_ns(current) != &init_pid_ns)
return -EINVAL;
idx = iminor(inode); idx = iminor(inode);
if (idx < 0 || idx >= MAX_CODADEVS) if (idx < 0 || idx >= MAX_CODADEVS)
return -ENODEV; return -ENODEV;
......
...@@ -50,8 +50,8 @@ static void *alloc_upcall(int opcode, int size) ...@@ -50,8 +50,8 @@ static void *alloc_upcall(int opcode, int size)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
inp->ih.opcode = opcode; inp->ih.opcode = opcode;
inp->ih.pid = current->pid; inp->ih.pid = task_pid_nr_ns(current, &init_pid_ns);
inp->ih.pgid = task_pgrp_nr(current); inp->ih.pgid = task_pgrp_nr_ns(current, &init_pid_ns);
inp->ih.uid = current_fsuid(); inp->ih.uid = current_fsuid();
return (void*)inp; return (void*)inp;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册