]> git.karo-electronics.de Git - karo-tx-linux.git/commit
vfork: make it killable
authorOleg Nesterov <oleg@redhat.com>
Mon, 22 Aug 2011 13:00:19 +0000 (15:00 +0200)
committerOleg Nesterov <oleg@redhat.com>
Mon, 22 Aug 2011 13:24:01 +0000 (15:24 +0200)
commit512c0ddb49d2e76f622a21ca6bb25957b6018505
treeab67f4d87c839e70dc91e6150fb23240a4950e0f
parent68b8b9a678ebadce52238ce297bd7651461f7211
vfork: make it killable

Make vfork() killable.

Change do_fork(CLONE_VFORK) to do wait_for_completion_killable().
If it fails we do not return to the user-mode and never touch the
memory shared with our child.

However, in this case we should clear child->vfork_done before
return, we use task_lock() in do_fork()->wait_for_vfork_done()
and complete_vfork_done() to serialize with each other.

Note: now that we use task_lock() we don't really need completion,
we could turn task->vfork_done into "task_struct *wake_up_me" but
this needs some complications.

NOTE: this and the next patches do not affect in-kernel users of
CLONE_VFORK, kernel threads run with all signals ignored including
SIGKILL/SIGSTOP.

However this is obviously the user-visible change. Not only a fatal
signal can kill the vforking parent, a sub-thread can do execve or
exit_group() and kill the thread sleeping in vfork().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
include/linux/sched.h
kernel/fork.c