public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] protect /sbin/init from unwanted signals more
@ 2008-11-18 17:59 Oleg Nesterov
  2008-11-19 18:51 ` Roland McGrath
  0 siblings, 1 reply; 13+ messages in thread
From: Oleg Nesterov @ 2008-11-18 17:59 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric W. Biederman, Pavel Emelyanov, Roland McGrath,
	Serge E. Hallyn, Sukadev Bhattiprolu, linux-kernel

init ignores the SIG_DFL signals but we queue them anyway, including
SIGKILL. This is mostly OK, the signal will be dropped silently when
dequeued, but the pending SIGKILL has 2 bad implications:

	- it implies fatal_signal_pending(), so we confuse things
	  like wait_for_completion_killable/lock_page_killable.

	- for the sub-namespace inits, the pending SIGKILL can
	  mask (legacy_queue) the subsequent SIGKILL from the
	  parent namespace which must kill cinit reliably.
	  (preparation, cinits don't have SIGNAL_UNKILLABLE yet)

The patch can't help when init is ptraced, but ptracing of init is
not "safe" anyway.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>

--- K-IS/kernel/signal.c~1_INIT_IGN_KILL	2008-11-10 19:21:17.000000000 +0100
+++ K-IS/kernel/signal.c	2008-11-17 19:54:09.000000000 +0100
@@ -43,7 +43,13 @@ static struct kmem_cache *sigqueue_cache
 
 static void __user *sig_handler(struct task_struct *t, int sig)
 {
-	return t->sighand->action[sig - 1].sa.sa_handler;
+	void __user *h = t->sighand->action[sig - 1].sa.sa_handler;
+
+	/* drop SIGKILL early to not confuse wait_xxx_killable/etc */
+	if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) && h == SIG_DFL)
+		h = SIG_IGN;
+
+	return h;
 }
 
 static int sig_handler_ignored(void __user *handler, int sig)


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-12-04 17:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-18 17:59 [PATCH 1/2] protect /sbin/init from unwanted signals more Oleg Nesterov
2008-11-19 18:51 ` Roland McGrath
2008-11-20  2:00   ` Eric W. Biederman
2008-11-20  3:04     ` Roland McGrath
2008-11-20 14:52     ` Oleg Nesterov
2008-11-20 18:10       ` Eric W. Biederman
2008-11-20 20:00         ` Oleg Nesterov
2008-11-20 20:28           ` [PATCH] processes: reparent_thread: don't call kill_orphaned_pgrp() if task_detached() Oleg Nesterov
2008-11-26 20:21             ` Roland McGrath
2008-12-04 17:14               ` Oleg Nesterov
2008-12-04  1:06             ` Roland McGrath
2008-11-20 15:20   ` [PATCH 1/2] protect /sbin/init from unwanted signals more Oleg Nesterov
2008-11-20 21:24     ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox