From: "Serge E. Hallyn" <serge@hallyn.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: raven@themaw.net, autofs@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
sukadev@linux.vnet.ibm.com, serge.hallyn@canonical.com,
ebiederm@xmission.com
Subject: Re: [PATCH 2/2] autofs4: translate pids to the right namespace for the daemon
Date: Tue, 7 May 2013 13:15:04 -0500 [thread overview]
Message-ID: <20130507181504.GB12315@austin.hallyn.com> (raw)
In-Reply-To: <20130507135654.GB6129@tucsk.piliscsaba.szeredi.hu>
Quoting Miklos Szeredi (miklos@szeredi.hu):
> From: Miklos Szeredi <mszeredi@suse.cz>
>
> The PID and the TGID of the process tringgering the mount are sent to the
> daemon. Currently the global pid values are sent (ones valid in the initial pid
> namespace) but this is wrong if the autofs daemon itself is not running in the
> initial pid namespace.
>
> So send the pid values that are valid in the namespace of the autofs daemon.
>
> The namespace to use is taken from the oz_pgrp pid pointer, which was set at
> mount time to the mounting process' pid namespace.
>
> If the pid translation fails (the triggering process is in an unrelated pid
> namespace) then the automount fails with ENOENT.
>
> Cc: Serge E. Hallyn <serue@us.ibm.com>
Makes sense.
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Thanks, Miklos.
> Cc: Eric Biederman <ebiederm@xmission.com>
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
> ---
> fs/autofs4/waitq.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> --- a/fs/autofs4/waitq.c
> +++ b/fs/autofs4/waitq.c
> @@ -353,11 +353,23 @@ int autofs4_wait(struct autofs_sb_info *
> struct qstr qstr;
> char *name;
> int status, ret, type;
> + pid_t pid;
> + pid_t tgid;
>
> /* In catatonic mode, we don't wait for nobody */
> if (sbi->catatonic)
> return -ENOENT;
>
> + /*
> + * Try translating pids to the namespace of the daemon.
> + *
> + * Zero means failure: we are in an unrelated pid namespace.
> + */
> + pid = task_pid_nr_ns(current, ns_of_pid(sbi->oz_pgrp));
> + tgid = task_tgid_nr_ns(current, ns_of_pid(sbi->oz_pgrp));
> + if (pid == 0 || tgid == 0)
> + return -ENOENT;
> +
> if (!dentry->d_inode) {
> /*
> * A wait for a negative dentry is invalid for certain
> @@ -423,8 +435,8 @@ int autofs4_wait(struct autofs_sb_info *
> wq->ino = autofs4_get_ino(sbi);
> wq->uid = current_uid();
> wq->gid = current_gid();
> - wq->pid = current->pid;
> - wq->tgid = current->tgid;
> + wq->pid = pid;
> + wq->tgid = tgid;
> wq->status = -EINTR; /* Status return if interrupted */
> wq->wait_ctr = 2;
> mutex_unlock(&sbi->wq_mutex);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2013-05-07 18:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-07 13:54 [PATCH 1/2] autofs4: allow autofs to work outside the initial PID namespace Miklos Szeredi
2013-05-07 13:56 ` [PATCH 2/2] autofs4: translate pids to the right namespace for the daemon Miklos Szeredi
2013-05-07 18:15 ` Serge E. Hallyn [this message]
2013-05-07 18:14 ` [PATCH 1/2] autofs4: allow autofs to work outside the initial PID namespace Serge E. Hallyn
-- strict thread matches above, loose matches on Subject: below --
2012-11-22 16:24 Miklos Szeredi
2012-11-22 16:26 ` [PATCH 2/2] autofs4: translate pids to the right namespace for the daemon Miklos Szeredi
2012-11-13 11:48 [PATCH 1/2] autofs4: allow autofs to work outside the initial PID namespace Miklos Szeredi
2012-11-13 11:49 ` [PATCH 2/2] autofs4: translate pids to the right namespace for the daemon Miklos Szeredi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130507181504.GB12315@austin.hallyn.com \
--to=serge@hallyn.com \
--cc=autofs@vger.kernel.org \
--cc=ebiederm@xmission.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=raven@themaw.net \
--cc=serge.hallyn@canonical.com \
--cc=sukadev@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®