aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2006-03-28 19:11:02 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-28 21:36:40 -0500
commit652486fb84a07ed750f1c11639518f55808bf555 (patch)
tree5fb6963a68dd63591f247d9bfc9f9e2d10468fb9
parentf96a795d4f6a8a13abe4b0d3c5d1c28ea8d7ce4b (diff)
[PATCH] do_SAK: don't depend on session ID 0
I'm not really certain what the thinking was but the code obviously wanted to walk processes other than just those in it's session, for purposes of do_SAK. Just walking those tasks that don't have a session assigned sounds at the very least incomplete. So modify the code to kill everything in the session and anything else that might have the tty open. Hopefully this helps if the do_SAK functionality is ever finished. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/char/tty_io.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index bd73242fe159..0bfd1b63662e 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2672,7 +2672,7 @@ static void __do_SAK(void *arg)
2672 tty_hangup(tty); 2672 tty_hangup(tty);
2673#else 2673#else
2674 struct tty_struct *tty = arg; 2674 struct tty_struct *tty = arg;
2675 struct task_struct *p; 2675 struct task_struct *g, *p;
2676 int session; 2676 int session;
2677 int i; 2677 int i;
2678 struct file *filp; 2678 struct file *filp;
@@ -2693,8 +2693,18 @@ static void __do_SAK(void *arg)
2693 tty->driver->flush_buffer(tty); 2693 tty->driver->flush_buffer(tty);
2694 2694
2695 read_lock(&tasklist_lock); 2695 read_lock(&tasklist_lock);
2696 /* Kill the entire session */
2696 do_each_task_pid(session, PIDTYPE_SID, p) { 2697 do_each_task_pid(session, PIDTYPE_SID, p) {
2697 if (p->signal->tty == tty || session > 0) { 2698 printk(KERN_NOTICE "SAK: killed process %d"
2699 " (%s): p->signal->session==tty->session\n",
2700 p->pid, p->comm);
2701 send_sig(SIGKILL, p, 1);
2702 } while_each_task_pid(session, PIDTYPE_SID, p);
2703 /* Now kill any processes that happen to have the
2704 * tty open.
2705 */
2706 do_each_thread(g, p) {
2707 if (p->signal->tty == tty) {
2698 printk(KERN_NOTICE "SAK: killed process %d" 2708 printk(KERN_NOTICE "SAK: killed process %d"
2699 " (%s): p->signal->session==tty->session\n", 2709 " (%s): p->signal->session==tty->session\n",
2700 p->pid, p->comm); 2710 p->pid, p->comm);
@@ -2721,7 +2731,7 @@ static void __do_SAK(void *arg)
2721 rcu_read_unlock(); 2731 rcu_read_unlock();
2722 } 2732 }
2723 task_unlock(p); 2733 task_unlock(p);
2724 } while_each_task_pid(session, PIDTYPE_SID, p); 2734 } while_each_thread(g, p);
2725 read_unlock(&tasklist_lock); 2735 read_unlock(&tasklist_lock);
2726#endif 2736#endif
2727} 2737}