[PATCH] freezer: Get out of refrigerator if fatal signals arepending

From: Michal Hocko
Date: Thu Sep 29 2011 - 07:45:22 EST


We should make sure that the current task doesn't enter refrigerator if
it has fatal signals pending because it should get to the signals
processing as soon as possible.

This closes a possible race when OOM killer selects a task which is
about to enter the fridge but it is not set as frozen yet. This will
lead to a livelock because select_bad_process would skip that task due
to TIF_MEMDIE set for the process but there is no chance for further
process.
oom_kill_task refrigerator
set_tsk_thread_flag(p, TIF_MEMDIE);
force_sig(SIGKILL, p);
if (frozen(p))
thaw_process(p)
frozen_process();
[...]
if (!frozen(current))
break;
schedule();

select_bad_process
[...]
if (test_tsk_thread_flag(p, TIF_MEMDIE))
return ERR_PTR(-1UL);

Signed-off-by: Michal Hocko <mhocko@xxxxxxx>
---
kernel/freezer.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/kernel/freezer.c b/kernel/freezer.c
index 7b01de9..74b8434 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -48,6 +48,10 @@ void refrigerator(void)
current->flags |= PF_FREEZING;

for (;;) {
+ if (fatal_signal_pending(current)) {
+ current->flags &= ~PF_FROZEN;
+ break;
+ }
set_current_state(TASK_UNINTERRUPTIBLE);
if (!frozen(current))
break;
--
1.7.6.3

--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/