Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fork: fix copy_process(CLONE_PARENT) race with the exiting ->real_parent

current->group_leader->exit_signal may change during copy_process() if
current->real_parent exits.

Move the assignment inside tasklist_lock to avoid the race.

Signed-off-by: Eddy Wu <eddy_wu@trendmicro.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Eddy Wu and committed by
Linus Torvalds
b4e00444 9dbc1c03

+5 -5
+5 -5
kernel/fork.c
··· 2167 2167 /* ok, now we should be set up.. */ 2168 2168 p->pid = pid_nr(pid); 2169 2169 if (clone_flags & CLONE_THREAD) { 2170 - p->exit_signal = -1; 2171 2170 p->group_leader = current->group_leader; 2172 2171 p->tgid = current->tgid; 2173 2172 } else { 2174 - if (clone_flags & CLONE_PARENT) 2175 - p->exit_signal = current->group_leader->exit_signal; 2176 - else 2177 - p->exit_signal = args->exit_signal; 2178 2173 p->group_leader = p; 2179 2174 p->tgid = p->pid; 2180 2175 } ··· 2213 2218 if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) { 2214 2219 p->real_parent = current->real_parent; 2215 2220 p->parent_exec_id = current->parent_exec_id; 2221 + if (clone_flags & CLONE_THREAD) 2222 + p->exit_signal = -1; 2223 + else 2224 + p->exit_signal = current->group_leader->exit_signal; 2216 2225 } else { 2217 2226 p->real_parent = current; 2218 2227 p->parent_exec_id = current->self_exec_id; 2228 + p->exit_signal = args->exit_signal; 2219 2229 } 2220 2230 2221 2231 klp_copy_process(p);