]> Pileus Git - ~andy/linux/blobdiff - fs/autofs4/waitq.c
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/olof/chrome...
[~andy/linux] / fs / autofs4 / waitq.c
index 689e40d983ad64ca3726cd5f8dd64c44d49bb5e6..116fd38ee472c74f243c05428969c2bd1bbe85e2 100644 (file)
@@ -347,11 +347,23 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
        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
@@ -417,8 +429,8 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
                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;