public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Alan Cox <alan@linux.intel.com>, Greg KH <greg@kroah.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Serge Hallyn <serue@us.ibm.com>,
	Sukadev Bhattiprolu <sukadev@us.ibm.com>,
	stable@kernel.org
Subject: Re: [PATCH 1/1] tty: release_one_tty() forgets to put pids
Date: Fri, 02 Apr 2010 11:22:29 -0700	[thread overview]
Message-ID: <m14ojtogt6.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <alpine.LFD.2.00.1004021040320.3634@i5.linux-foundation.org> (Linus Torvalds's message of "Fri\, 2 Apr 2010 10\:46\:24 -0700 \(PDT\)")

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Fri, 2 Apr 2010, Oleg Nesterov wrote:
>>
>> release_one_tty(tty) can be called when tty still has a reference
>> to pgrp/session. In this case we leak the pid.
>
> Hmm. Maybe we should have cleared this in tty_release() already. We 
> already do some of the session clearing there (but we clear the session in 
> the _tasks_ associated with the tty, not the tty session pointer).
>
> But:
>
>> The patch needs the ack from someone who understand tty magic.
>
> I think the patch is simpler than worrying about the much more complex 
> release logic. So I think I actually prefer this patch over something that 
> tries to be clever in tty_release.
>
> We might even push it into "free_tty_struct()", although I think that the 
> only non-release_one_tty() callers of that are the ones that allocated the 
> tty but due to some failure never connected it to anything. So on the 
> whole I think you picked the right spot.
>
> So I'll ACK it. But maybe Alan sees some problem/issue I didn't see.

I agree.   However we made it to release_one_tty with pids we need
to free them, before we free the tty structure itself.

My general paranoia would suggest setting the pids to NULL.  So that
we don't have the chance of a use after free.

Eric

  reply	other threads:[~2010-04-02 18:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-27 12:21 [2.6.31 and later] "struct pid" leak Tetsuo Handa
2010-03-30 15:31 ` Catalin Marinas
2010-03-31 22:17   ` Andrew Morton
2010-04-01 16:52     ` Oleg Nesterov
2010-04-01 17:21       ` Serge E. Hallyn
2010-04-01 17:33         ` Serge E. Hallyn
2010-04-02 15:29         ` Oleg Nesterov
2010-04-02 16:04     ` [PATCH 0/1] tty: release_one_tty() forgets to put pids Oleg Nesterov
2010-04-02 16:05       ` [PATCH 1/1] " Oleg Nesterov
2010-04-02 16:19         ` Oleg Nesterov
2010-04-02 17:46         ` Linus Torvalds
2010-04-02 18:22           ` Eric W. Biederman [this message]
2010-04-02 18:48             ` Oleg Nesterov
2010-04-02 18:43           ` Oleg Nesterov
2010-04-02 20:09           ` Alan Cox
2010-04-03  2:40       ` [PATCH 0/1] " Tetsuo Handa
2010-04-03  3:08       ` Linus Torvalds
2010-04-03  5:15         ` [stable] " Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m14ojtogt6.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@linux.intel.com \
    --cc=catalin.marinas@arm.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=serue@us.ibm.com \
    --cc=stable@kernel.org \
    --cc=sukadev@us.ibm.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox