Re: Possible "struct pid" leak from tty_io.c

From: Eric W. Biederman
Date: Wed Mar 14 2007 - 10:41:25 EST



How does this look?

I don't have the setup to test this easily, but this bit makes seems to make
sense. I will keep code reviewing and see if I can convince myself that this
is correct or incorrect in the mean time...

diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index e453268..fc125ac 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1376,6 +1376,8 @@ static void do_tty_hangup(struct work_struct *work)
read_unlock(&tasklist_lock);

tty->flags = 0;
+ put_pid(tty->session);
+ put_pid(tty->pgrp);
tty->session = NULL;
tty->pgrp = NULL;
tty->ctrl_status = 0;
@@ -3841,6 +3843,8 @@ static struct pid *__proc_set_tty(struct task_struct *tsk, struct tty_struct *tt
{
struct pid *old_pgrp;
if (tty) {
+ put_pid(tty->session);
+ put_pid(tty->pgrp);
tty->session = get_pid(task_session(tsk));
tty->pgrp = get_pid(task_pgrp(tsk));
}
-
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/