Re: [PATCH 2/3] fuse: Translate pid making a request into the server's pid namespace

From: Miklos Szeredi
Date: Fri Jul 18 2014 - 11:29:26 EST


On Mon, Jul 14, 2014 at 9:18 PM, Seth Forshee
<seth.forshee@xxxxxxxxxxxxx> wrote:
> If the server is executing in a pid namespace then then giving it
> the global pid of the process making the request is useless.
> Translate the pid into the server's pid namespace.
>
> Signed-off-by: Seth Forshee <seth.forshee@xxxxxxxxxxxxx>
> ---
> fs/fuse/dev.c | 9 +++++----
> fs/fuse/fuse_i.h | 4 ++++
> fs/fuse/inode.c | 2 ++
> 3 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 219d1e685183..db781ff6392b 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -20,6 +20,7 @@
> #include <linux/swap.h>
> #include <linux/splice.h>
> #include <linux/aio.h>
> +#include <linux/sched.h>
>
> MODULE_ALIAS_MISCDEV(FUSE_MINOR);
> MODULE_ALIAS("devname:fuse");
> @@ -124,11 +125,11 @@ static void __fuse_put_request(struct fuse_req *req)
> atomic_dec(&req->count);
> }
>
> -static void fuse_req_init_context(struct fuse_req *req)
> +static void fuse_req_init_context(struct fuse_conn *fc, struct fuse_req *req)
> {
> req->in.h.uid = from_kuid_munged(&init_user_ns, current_fsuid());
> req->in.h.gid = from_kgid_munged(&init_user_ns, current_fsgid());
> - req->in.h.pid = current->pid;
> + req->in.h.pid = pid_nr_ns(task_pid(current), fc->pid_ns);

I think this is wrong. We should store struct pid* in req->in and
translate into the server's pid in fuse_dev_do_read() before we copy
in.h.

Thanks,
Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/