aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2014-01-23 18:54:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-23 19:36:59 -0500
commitfbff08706d12fcdb160604c4ba790df6707c32cb (patch)
tree0d04ed6125de1dca536105046bc98aefc97773b7 /fs/autofs4
parent6eaba35b437438988078efc92f1ef445a00cd7bc (diff)
autofs4: translate pids to the right namespace for the daemon
The PID and the TGID of the process triggering 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. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Cc: Eric Biederman <ebiederm@xmission.com> Acked-by: Ian Kent <raven@themaw.net> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/autofs4')
-rw-r--r--fs/autofs4/waitq.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 689e40d983ad..116fd38ee472 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -347,11 +347,23 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
347 struct qstr qstr; 347 struct qstr qstr;
348 char *name; 348 char *name;
349 int status, ret, type; 349 int status, ret, type;
350 pid_t pid;
351 pid_t tgid;
350 352
351 /* In catatonic mode, we don't wait for nobody */ 353 /* In catatonic mode, we don't wait for nobody */
352 if (sbi->catatonic) 354 if (sbi->catatonic)
353 return -ENOENT; 355 return -ENOENT;
354 356
357 /*
358 * Try translating pids to the namespace of the daemon.
359 *
360 * Zero means failure: we are in an unrelated pid namespace.
361 */
362 pid = task_pid_nr_ns(current, ns_of_pid(sbi->oz_pgrp));
363 tgid = task_tgid_nr_ns(current, ns_of_pid(sbi->oz_pgrp));
364 if (pid == 0 || tgid == 0)
365 return -ENOENT;
366
355 if (!dentry->d_inode) { 367 if (!dentry->d_inode) {
356 /* 368 /*
357 * A wait for a negative dentry is invalid for certain 369 * A wait for a negative dentry is invalid for certain
@@ -417,8 +429,8 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
417 wq->ino = autofs4_get_ino(sbi); 429 wq->ino = autofs4_get_ino(sbi);
418 wq->uid = current_uid(); 430 wq->uid = current_uid();
419 wq->gid = current_gid(); 431 wq->gid = current_gid();
420 wq->pid = current->pid; 432 wq->pid = pid;
421 wq->tgid = current->tgid; 433 wq->tgid = tgid;
422 wq->status = -EINTR; /* Status return if interrupted */ 434 wq->status = -EINTR; /* Status return if interrupted */
423 wq->wait_ctr = 2; 435 wq->wait_ctr = 2;
424 436