From f7844601fb857a2243575dc0efef6b6f06bd771f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 28 Oct 2002 16:23:03 -0800 Subject: [PATCH] thread-aware oom-killer From Ingo - performance optimization: do not kill threads in the same thread group as the OOM-ing thread. (it's still necessery to scan over every thread though, as it's possible to have CLONE_VM threads in a different thread group - we do not want those to escape the OOM-kill.) - to not let newly created child threads slip out of the group-kill. Note that the 2.4 kernel's OOM handler has the same problem, and it could be the reason why forkbombs occasionally slip out of the OOM kill. --- kernel/fork.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'kernel') diff --git a/kernel/fork.c b/kernel/fork.c index f8620b82f8f5..2f5f00301182 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -863,6 +863,14 @@ static struct task_struct *copy_process(unsigned long clone_flags, /* Need tasklist lock for parent etc handling! */ write_lock_irq(&tasklist_lock); + /* + * Check for pending SIGKILL! The new thread should not be allowed + * to slip out of an OOM kill. (or normal SIGKILL.) + */ + if (sigismember(¤t->pending.signal, SIGKILL)) { + write_unlock_irq(&tasklist_lock); + goto bad_fork_cleanup_namespace; + } /* CLONE_PARENT re-uses the old parent */ if (clone_flags & CLONE_PARENT) -- cgit v1.2.3