mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Catalin Marinas" <catalin.marinas@gmail.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: Possible "struct pid" leak from tty_io.c
Date: Fri, 9 Mar 2007 10:53:01 +0000	[thread overview]
Message-ID: <b0943d9e0703090253r690e1f21qf8d7a1edfd08561b@mail.gmail.com> (raw)
In-Reply-To: <m13b4f7ggy.fsf@ebiederm.dsl.xmission.com>

On 08/03/07, Eric W. Biederman <ebiederm@xmission.com> wrote:
> "Catalin Marinas" <catalin.marinas@gmail.com> writes:
> > I'm trying to track down a kmemleak report (on an ARM platform) which
> > seems to have appeared with commit
> > ab521dc0f8e117fd808d3e425216864d60390500. As I'm not familiar with the
> > TTY layer at all, is it possible that the above commit missed a
> > put_pid() call on some path?
>
> I won't arbitrarily rule a missing put_pid out.  I have been know to
> goof up upon occasion.

I'm not entirely sure it's this part of the code, I would have to do
some more investigations (I didn't get this leak before). An
"unscientific" test shows that if I define get_pid/put_pid in the
tty_io.c file so that pid->count is not affected, the leak disappears.
This doesn't necessarily prove that the fault is here though.

> I just did a quick look to see what kmemleak is.  A conservative
> tracing leak detector sounds interesting.  Except for all of the list
> heads which lead to container_of calls I don't know of anything in the
> struct pid implementation that would be difficult for it to work with.
> Well that and there is some rcu access protection which can delay the
> free by a bit.

Kmemleak can cope with list heads and rcu delayed freeing as it also
checks for pointer aliases (those accessible via container_of).

> > The /sbin/init application calls sys_clone() a few times but only one
> > leak is reported (see below). Looking at the reported pid object (at
> > 0xc7c14500), count is 2 and nr is 296 but no process with pid 296
> > exists any more.
>
> It could still be a valid session or a process group id.
> If you examine the struct pid you can test for this be examining all
> of the list heads it keeps.  If there is something on any of the
> lists that would account a count of 1.  How we have a count of 2
> I don't have enough information to guess.

I think it's only the pid_chain and rcu member that could be placed in
a list and kmemleak scans the memory for these two offsets as well.
I'll check those lists anyway but I doubt it's a more fundamental
problem with how kmemleak handles struct pid as I should've probably
got more reports.

> In most any other layer we cache pids indefinitely and a situation
> where we have a pointer to a struct pid with a ref count of 1 long
> after the process goes away is expected.

Yes, indeed, but what kmemleak reports is that the pid structure
wasn't freed yet and there is no way to determine its pointer directly
or via container_of on members (by scanning the memory), hence it is
considered a leak.

> I don't understand your situation enough to guess what is going wrong
> yet.  Hopefully I have given you enough information to get started.

Yes, many thanks. I'll dig further and let you know.

-- 
Catalin

  reply	other threads:[~2007-03-09 10:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-08 17:27 Catalin Marinas
2007-03-08 18:11 ` Eric W. Biederman
2007-03-09 10:53   ` Catalin Marinas [this message]
2007-03-09 16:13     ` Eric W. Biederman
2007-03-09 16:53       ` Catalin Marinas
2007-03-09 16:44   ` Catalin Marinas
2007-03-09 17:09     ` Eric W. Biederman
2007-03-12 15:07       ` Catalin Marinas
2007-03-12 16:12         ` Eric W. Biederman
2007-03-13 19:31         ` Eric W. Biederman
2007-03-14  9:59           ` Catalin Marinas
2007-03-14 14:40             ` Eric W. Biederman
2007-03-14 17:08               ` Catalin Marinas
2007-03-15 19:15                 ` Eric W. Biederman
2007-03-16 22:01                 ` Eric W. Biederman
2007-03-16 22:44                   ` Catalin Marinas
2007-03-18 18:45                     ` [PATCH] tty: Fix two reported pid leaks Eric W. Biederman
2007-03-18 18:52                       ` [PATCH 0/4] tty: small fixes and cleanups Eric W. Biederman
2007-03-18 18:57                         ` [PATCH 1/4] tty: Remove unnecessary export of proc_clear_tty Eric W. Biederman
2007-03-18 19:03                           ` [PATCH 2/4] tty: Simplify calling of put_pid Eric W. Biederman
2007-03-18 19:08                             ` [PATCH 3/4] tty: Introduce no_tty and use it in selinux Eric W. Biederman
2007-03-18 19:13                               ` [PATCH 4/4] tty: In tiocsctty when we steal a tty hang it up Eric W. Biederman
2007-03-18 20:55                               ` [PATCH 3/4] tty: Introduce no_tty and use it in selinux Alan Cox

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=b0943d9e0703090253r690e1f21qf8d7a1edfd08561b@mail.gmail.com \
    --to=catalin.marinas@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®