aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2015-08-10 19:25:44 -0400
committerEric W. Biederman <ebiederm@xmission.com>2015-08-12 15:55:28 -0400
commitfaf00da544045fdc1454f3b9e6d7f65c841de302 (patch)
treee08a54d870374ea8e0d8421c39f4c90559fd4ab0
parent12c641ab8270f787dfcce08b5f20ce8b65008096 (diff)
userns,pidns: Force thread group sharing, not signal handler sharing.
The code that places signals in signal queues computes the uids, gids, and pids at the time the signals are enqueued. Which means that tasks that share signal queues must be in the same pid and user namespaces. Sharing signal handlers is fine, but bizarre. So make the code in fork and userns_install clearer by only testing for what is functionally necessary. Also update the comment in unshare about unsharing a user namespace to be a little more explicit and make a little more sense. Acked-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
-rw-r--r--kernel/fork.c8
-rw-r--r--kernel/user_namespace.c4
2 files changed, 6 insertions, 6 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index d544ae97f999..2c72b8a8ae24 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1273,10 +1273,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1273 1273
1274 /* 1274 /*
1275 * If the new process will be in a different pid or user namespace 1275 * If the new process will be in a different pid or user namespace
1276 * do not allow it to share a thread group or signal handlers or 1276 * do not allow it to share a thread group with the forking task.
1277 * parent with the forking task.
1278 */ 1277 */
1279 if (clone_flags & CLONE_SIGHAND) { 1278 if (clone_flags & CLONE_THREAD) {
1280 if ((clone_flags & (CLONE_NEWUSER | CLONE_NEWPID)) || 1279 if ((clone_flags & (CLONE_NEWUSER | CLONE_NEWPID)) ||
1281 (task_active_pid_ns(current) != 1280 (task_active_pid_ns(current) !=
1282 current->nsproxy->pid_ns_for_children)) 1281 current->nsproxy->pid_ns_for_children))
@@ -1944,7 +1943,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
1944 int err; 1943 int err;
1945 1944
1946 /* 1945 /*
1947 * If unsharing a user namespace must also unshare the thread. 1946 * If unsharing a user namespace must also unshare the thread group
1947 * and unshare the filesystem root and working directories.
1948 */ 1948 */
1949 if (unshare_flags & CLONE_NEWUSER) 1949 if (unshare_flags & CLONE_NEWUSER)
1950 unshare_flags |= CLONE_THREAD | CLONE_FS; 1950 unshare_flags |= CLONE_THREAD | CLONE_FS;
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 4109f8320684..f65a0a06a8c0 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -976,8 +976,8 @@ static int userns_install(struct nsproxy *nsproxy, struct ns_common *ns)
976 if (user_ns == current_user_ns()) 976 if (user_ns == current_user_ns())
977 return -EINVAL; 977 return -EINVAL;
978 978
979 /* Threaded processes may not enter a different user namespace */ 979 /* Tasks that share a thread group must share a user namespace */
980 if (atomic_read(&current->mm->mm_users) > 1) 980 if (!thread_group_empty(current))
981 return -EINVAL; 981 return -EINVAL;
982 982
983 if (current->fs->users != 1) 983 if (current->fs->users != 1)