lkml.org 
[lkml]   [2007]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Possible "struct pid" leak from tty_io.c
On 13/03/07, Eric W. Biederman <ebiederm@xmission.com> wrote:
> "Catalin Marinas" <catalin.marinas@gmail.com> writes:
> > void proc_clear_tty(struct task_struct *p)
> > {
> > + struct tty_struct *tty;
> > +
> > spin_lock_irq(&p->sighand->siglock);
> > + tty = p->signal->tty;
> > + if (tty) {
> > + put_pid(tty->session);
> > + put_pid(tty->pgrp);
> > + }
> > p->signal->tty = NULL;
> > spin_unlock_irq(&p->sighand->siglock);
> > }
>
> This patch can't be right. Not the way proc_clear_tty is called
> once for each process in the session, plus we aren't clearing
> tty->session and tty->pgrp here.
>
> If the above patch works it's a fluke.

I looked at the logs and the pointer isn't freed indeed. It is just a
false negative in kmemleak and it would appear as a leak at some
point. But the previous patch (do_tty_hangup) seems to fix one of the
leaks.

For the 2nd leak, proc_set_tty is called and, for symmetry, I added
put_pid in proc_clear_tty (but without any deep thought). I also
haven't checked any lockdep issues with adding put_pid when
p->sighand->siglock is held.

--
Catalin
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-03-14 11:03    [W:0.062 / U:2.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site