Skip to contentSkip to conversation

tty: prevent SAK to kill init process

PATCH In review Jiri Olsa 2 participants 3 messages Nov 1, 2010 – Nov 2, 2010 Char and misc drivers

lore
Share & tools
lore

Jiri Olsa

author
#0 lore raw

PATCH 1/1 tty: prevent SAK to kill init process

hi,

hitting "Secure Attention Key" on console that's openned by init process, causing panic due to an attempt to kill the init process.

Fixing this by skipping the init process in the loop.

wbr,
jirka

---
 drivers/char/tty_io.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/char/tty_io.c +4 -0
index c05c5af..1b85d37 100644
@@ -2746,6 +2746,8 @@ void __do_SAK(struct tty_struct *tty)
 	read_lock(&tasklist_lock);
 	/* Kill the entire session */
 	do_each_pid_task(session, PIDTYPE_SID, p) {
+		if (is_global_init(p))
+			continue;
 		printk(KERN_NOTICE "SAK: killed process %d"
 			" (%s): task_session(p)==tty->session\n",
 			task_pid_nr(p), p->comm);
@@ -2755,6 +2757,8 @@ void __do_SAK(struct tty_struct *tty)
 	 * tty open.
 	 */
 	do_each_thread(g, p) {
+		if (is_global_init(p))
+			continue;
 		if (p->signal->tty == tty) {
 			printk(KERN_NOTICE "SAK: killed process %d"
 			    " (%s): task_session(p)==tty->session\n",
Signature · 1 line
1.7.1
#1 lore raw
Quoted 7 lines · Jiri Olsa

hi,

hitting "Secure Attention Key" on console that's openned by init process, causing panic due to an attempt to kill the init process.

Fixing this by skipping the init process in the loop.

This sounds like proper behavior. The goal of SAK is the guarantee that no one else has the tty one, and this violates that goal. Which version init opens a controlling tty? I expect it is time to deliver SIGCLUE to it.

Eric

author
#2 lore raw
Quoted 8 lines · Eric W. Biederman
Quoted 6 lines · Jiri Olsa

hi,

hitting "Secure Attention Key" on console that's openned by init process, causing panic due to an attempt to kill the init process.

Quoted 6 lines
Quoted 1 line

Fixing this by skipping the init process in the loop.

This sounds like proper behavior. The goal of SAK is the guarantee that no one else has the tty one, and this violates that goal. Which version init opens a controlling tty? I expect it is time to deliver SIGCLUE to it.

I was using some older upstart version, which kept the console open

I found this log entry in changelog :)

* No longer holds /dev/console open, so the SAK SysRq key will not kill Upstart. (Bug: #486005)

So probably no need for the patch

sry for noise,
jirka