linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* is pid_namespace leak in v3.10?
@ 2016-07-05 11:40 Xishi Qiu
  2016-07-05 14:34 ` Oleg Nesterov
  0 siblings, 1 reply; 2+ messages in thread
From: Xishi Qiu @ 2016-07-05 11:40 UTC (permalink / raw)
  To: oleg, ebiederm; +Cc: Linux MM, LKML

I find pid_namespace leak by "cat /proc/slabinfo | grep pid_namespace".
The kernel version is RHEL 7.1 (kernel v3.10 stable).
The following is the test case, after several times, the count of pid_namespace
become very large, is it correct?

I also test mainline, and the count will increase too, but it seems stably later.

BTW, this patch doesn't help.
24c037ebf5723d4d9ab0996433cee4f96c292a4d
exit: pidns: alloc_pid() leaks pid_namespace if child_reaper is exiting

Thanks,
Xishi Qiu


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <signal.h>

#ifndef CLONE_NEWPID
#define CLONE_NEWPID            0x20000000
#endif

void test(void)
{
        printf("clone child\n");
        exit(0);
}

int main()
{
        pid_t pid, child_pid;
        int  i, status;
        void *stack;

        for (i = 0; i < 100; i++) {
                stack = malloc(8192);
                pid = clone(&test, (char *)stack + 8192, CLONE_NEWPID|SIGCHLD, 0);
        }

        sleep(5);

        return 0;
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: is pid_namespace leak in v3.10?
  2016-07-05 11:40 is pid_namespace leak in v3.10? Xishi Qiu
@ 2016-07-05 14:34 ` Oleg Nesterov
  0 siblings, 0 replies; 2+ messages in thread
From: Oleg Nesterov @ 2016-07-05 14:34 UTC (permalink / raw)
  To: Xishi Qiu; +Cc: ebiederm, Linux MM, LKML

On 07/05, Xishi Qiu wrote:
>
> I find pid_namespace leak by "cat /proc/slabinfo | grep pid_namespace".
> The kernel version is RHEL 7.1 (kernel v3.10 stable).
> The following is the test case, after several times, the count of pid_namespace
> become very large, is it correct?

Apparently not,

> I also test mainline, and the count will increase too, but it seems stably later.

And I can't reproduce the problem with the latest rhel7 kernel.

And just in case, I have no idea what actually slub reports as "active_objs" but
certainly this is not the number of allocated "in use" objects, so it is fine if
this counter doesn't go to zero when your test-case exits. But it should not grow
"too much".

> BTW, this patch doesn't help.
> 24c037ebf5723d4d9ab0996433cee4f96c292a4d
> exit: pidns: alloc_pid() leaks pid_namespace if child_reaper is exiting

Sure, it can't help, your test-case doesn't fork other processes which could race
with the exiting sub-namespace init.


> int main()
> {
>         pid_t pid, child_pid;
>         int  i, status;
>         void *stack;
>
>         for (i = 0; i < 100; i++) {
>                 stack = malloc(8192);
>                 pid = clone(&test, (char *)stack + 8192, CLONE_NEWPID|SIGCHLD, 0);
>         }
>
>         sleep(5);

is this sleep() really needed to trigger the problem?

Oleg.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-05 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05 11:40 is pid_namespace leak in v3.10? Xishi Qiu
2016-07-05 14:34 ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).