mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
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>
This commit is contained in:
parent
6eaba35b43
commit
fbff08706d
@ -347,11 +347,23 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
|
|||||||
struct qstr qstr;
|
struct qstr qstr;
|
||||||
char *name;
|
char *name;
|
||||||
int status, ret, type;
|
int status, ret, type;
|
||||||
|
pid_t pid;
|
||||||
|
pid_t tgid;
|
||||||
|
|
||||||
/* In catatonic mode, we don't wait for nobody */
|
/* In catatonic mode, we don't wait for nobody */
|
||||||
if (sbi->catatonic)
|
if (sbi->catatonic)
|
||||||
return -ENOENT;
|
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) {
|
if (!dentry->d_inode) {
|
||||||
/*
|
/*
|
||||||
* A wait for a negative dentry is invalid for certain
|
* 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,
|
|||||||
wq->ino = autofs4_get_ino(sbi);
|
wq->ino = autofs4_get_ino(sbi);
|
||||||
wq->uid = current_uid();
|
wq->uid = current_uid();
|
||||||
wq->gid = current_gid();
|
wq->gid = current_gid();
|
||||||
wq->pid = current->pid;
|
wq->pid = pid;
|
||||||
wq->tgid = current->tgid;
|
wq->tgid = tgid;
|
||||||
wq->status = -EINTR; /* Status return if interrupted */
|
wq->status = -EINTR; /* Status return if interrupted */
|
||||||
wq->wait_ctr = 2;
|
wq->wait_ctr = 2;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user