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

Miklos Szeredi miklos at szeredi.hu
Fri Jul 18 15:29:16 UTC 2014


On Mon, Jul 14, 2014 at 9:18 PM, Seth Forshee
<seth.forshee at canonical.com> 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 at canonical.com>
> ---
>  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


More information about the lxc-devel mailing list