fork: fix copy_process(CLONE_PARENT) race with the exiting ->real_parent
authorEddy Wu <itseddy0402@gmail.com>
Sat, 7 Nov 2020 06:47:22 +0000 (14:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Nov 2020 09:29:06 +0000 (10:29 +0100)
commitee55b8c6bf4d59c7b82079b8a7d67597bb3a5539
treecd1cef901bcef446c25c6990da87105f2fa05a34
parent9421bad22e9fb7f513d81ef8fec513c8a4850c0d
fork: fix copy_process(CLONE_PARENT) race with the exiting ->real_parent

commit b4e00444cab4c3f3fec876dc0cccc8cbb0d1a948 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/fork.c