From: Eric W. Biederman Date: Thu, 31 Jan 2013 02:50:54 +0000 (-0800) Subject: coda: Restrict coda messages to the initial pid namespace X-Git-Tag: firefly_0821_release~3680^2~1038^2~68 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9fd973e085f7759f710603422b2e11ad5f2e000d;p=firefly-linux-kernel-4.4.55.git 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 Signed-off-by: "Eric W. Biederman" --- 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 @@ #include #include #include +#include #include @@ -157,6 +158,9 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) int error; int idx; + if (task_active_pid_ns(current) != &init_pid_ns) + return -EINVAL; + idx = get_device_index((struct coda_mount_data *) data); /* 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 @@ #include #include #include +#include #include #include #include @@ -266,6 +267,9 @@ static int coda_psdev_open(struct inode * inode, struct file * file) struct venus_comm *vcp; int idx, err; + if (task_active_pid_ns(current) != &init_pid_ns) + return -EINVAL; + idx = iminor(inode); if (idx < 0 || idx >= MAX_CODADEVS) 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) return ERR_PTR(-ENOMEM); inp->ih.opcode = opcode; - inp->ih.pid = current->pid; - inp->ih.pgid = task_pgrp_nr(current); + inp->ih.pid = task_pid_nr_ns(current, &init_pid_ns); + inp->ih.pgid = task_pgrp_nr_ns(current, &init_pid_ns); inp->ih.uid = current_fsuid(); return (void*)inp;