aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2018-07-13 16:30:33 -0400
committerEric W. Biederman <ebiederm@xmission.com>2018-07-23 08:57:12 -0400
commit4ca1d3ee46130e9b939c02a93e3970dad151fed6 (patch)
tree7bf6b99caa95de54febc2597e9c2ef3d7bb9f033 /kernel/fork.c
parent0729614992c946f6e8ccb9ef260aea1f06993df0 (diff)
fork: Move and describe why the code examines PIDNS_ADDING
Normally this would be something that would be handled by handling signals that are sent to a group of processes but in this case the forking process is not a member of the group being signaled. Thus special code is needed to prevent a race with pid namespaces exiting, and fork adding new processes within them. Move this test up before the signal restart just in case signals are also pending. Fatal conditions should take presedence over restarts. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index cc5be0d01ce6..b9c54318a292 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1922,6 +1922,12 @@ static __latent_entropy struct task_struct *copy_process(
1922 1922
1923 rseq_fork(p, clone_flags); 1923 rseq_fork(p, clone_flags);
1924 1924
1925 /* Don't start children in a dying pid namespace */
1926 if (unlikely(!(ns_of_pid(pid)->pid_allocated & PIDNS_ADDING))) {
1927 retval = -ENOMEM;
1928 goto bad_fork_cancel_cgroup;
1929 }
1930
1925 /* 1931 /*
1926 * Process group and session signals need to be delivered to just the 1932 * Process group and session signals need to be delivered to just the
1927 * parent before the fork or both the parent and the child after the 1933 * parent before the fork or both the parent and the child after the
@@ -1935,10 +1941,7 @@ static __latent_entropy struct task_struct *copy_process(
1935 retval = -ERESTARTNOINTR; 1941 retval = -ERESTARTNOINTR;
1936 goto bad_fork_cancel_cgroup; 1942 goto bad_fork_cancel_cgroup;
1937 } 1943 }
1938 if (unlikely(!(ns_of_pid(pid)->pid_allocated & PIDNS_ADDING))) { 1944
1939 retval = -ENOMEM;
1940 goto bad_fork_cancel_cgroup;
1941 }
1942 1945
1943 init_task_pid_links(p); 1946 init_task_pid_links(p);
1944 if (likely(p->pid)) { 1947 if (likely(p->pid)) {