hold task_lock around checks in keyctl
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 30 Jun 2012 07:55:24 +0000 (11:55 +0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 22 Jul 2012 19:58:01 +0000 (23:58 +0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
security/keys/keyctl.c

index 0291b3f9397cfa98c4980b83df737ed8ff122ebd..f1b59ae39d7ee1ac1cbf518ecbc5a6644276442f 100644 (file)
@@ -1486,6 +1486,7 @@ long keyctl_session_to_parent(void)
        oldwork = NULL;
        parent = me->real_parent;
 
+       task_lock(parent);
        /* the parent mustn't be init and mustn't be a kernel thread */
        if (parent->pid <= 1 || !parent->mm)
                goto unlock;
@@ -1529,6 +1530,7 @@ long keyctl_session_to_parent(void)
        if (!ret)
                newwork = NULL;
 unlock:
+       task_unlock(parent);
        write_unlock_irq(&tasklist_lock);
        rcu_read_unlock();
        if (oldwork)