Linux Container Development
 help / color / mirror / Atom feed
From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman)
To: Pavel Emelyanov <xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
Cc: Linux Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: Re: Pid namespaces problems
Date: Sat, 03 Nov 2007 22:06:48 -0600	[thread overview]
Message-ID: <m1640id57r.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <472AE42F.5000602-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org> (Pavel Emelyanov's message of "Fri, 02 Nov 2007 11:47:43 +0300")

Pavel Emelyanov <xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org> writes:

> Hi, Eric, Suka.
>
> Eric, you and Ulrich claim that pid namespaces are full of BUGs.
> Can you please share you BUG list with me, so I could correct
> mine.

To be clear.  I think the current pid namespace work is incomplete.
I do not think the pid namespaces is fundamentally buggy the way
Ingo and Ulrich were suggesting (my apologies for the delayed
reply I have been away from my computer).

I think I shared just about everything I know of off the top
of my head in earlier threads.  But I haven't tried to
find an exhaustive list of uncorrected code as they pop
up fairly easily when I audit various pid users.  Which
lead me to conclude that the pid namespace is not complete.

> Things as I see them now are the following:
> 1. signals delivery is not perfect in the namespace
> 2. fs/lock.c will report wrong ids in the namespace
> 3. some kernel threads (nfs) still use old api (relevant
>    for a namespace only)
> 4. tsk->pid and tsk->tgid should not be explicitly used
     A wrapper that gets those values for use in printk.

As a general principle I am opposed to using global pid values
(except in kernel print statements).  Using them we continue
to have pid wrap around issues if we store them, and mixing
global pid_t values and non-global pid_t values is all too possible.

For example:
  fs/autofs/inode.c: line 83 *pgrp = task_pgrp_nr(current);
  fs/autofs/inode.c: line 117: *pgrp = option;

We are simultaneously assigning a global pid and a pid from
the current pid namespace to the same variable.  Ouch!

Used in anything but the init_pid namespace that code is wrong.

So with stupid things like that I would very much like to 
convert everything to storing and comparing struct pid pointers
which have essentially the same cost as pid_t values, can
be used the same way, but cannot be accidentally mixed with
with pid_t operations.  So they are just less error prone.

> I'd appreciate some specific information, like "the ttys
> in drivers/char/tty_io.c may break the pid refcounting"
> rather than abstract "this is not clear whether the
> refcounting is good in fs/locks.c"

You are picking on the one instance that I figured I would need
further review to see if there was work that needed to be done.  That
is what I meant by unclear.  I didn't know if the code was safe and
the code wasn't using one of the idioms that would have made me
certain that the code was safe.

- We need to store a struct pid reference on the sysvipc semaphores (and
  probably the other sysvipc objects) so that if they are used across
  namespace boundaries we can convert and give processes the pid for
  their local namespace.

- There are several architectures with their own signal functions for
  other OS compatibility that have are using _pid and not _vpid
  variants of functions. (irix and solaris)
  arch/mips/kernel/irixsig.c:irix_waitsys
  arch/mips/kernel/sysirix.c:irix_setpgrp
  arch/sparc64/solaris/misc.c:solaris_procids

Eric

       reply	other threads:[~2007-11-04  4:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <472AE42F.5000602@openvz.org>
     [not found] ` <472AE42F.5000602-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-11-04  4:06   ` Eric W. Biederman [this message]
     [not found]     ` <m1640id57r.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2007-11-06  7:39       ` Pid namespaces problems Pavel Emelyanov
     [not found]         ` <47301A14.9040304-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-11-06 16:28           ` Eric W. Biederman
2007-11-07  8:28           ` Cedric Le Goater
     [not found]             ` <4731772D.3060806-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-11-07  8:18               ` Daniel Lezcano
2007-11-07  9:00               ` Daniel Lezcano
     [not found]                 ` <47317EA7.6030500-GANU6spQydw@public.gmane.org>
2007-11-07 16:12                   ` Pavel Emelyanov
     [not found]                     ` <4731E3DE.6000501-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-11-07 17:24                       ` Daniel Lezcano
     [not found]                         ` <4731F4BC.4000203-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-11-08 10:40                           ` Pavel Emelyanov
     [not found]                             ` <4732E7A5.6050703-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-11-08 11:07                               ` Daniel Lezcano
2007-11-08 10:53                           ` Denis V. Lunev
     [not found]                             ` <4732EA8E.7080400-3ImXcnM4P+0@public.gmane.org>
2007-11-08 13:29                               ` Daniel Lezcano
     [not found]                                 ` <47330F1F.4080806-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-11-08 13:37                                   ` Pavel Emelyanov
     [not found]                                     ` <47331122.3000304-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-11-08 13:42                                       ` net namespace plans for 2.6.25 (was Re: Pid namespaces problems) Cedric Le Goater
     [not found]                                         ` <47331241.2090501-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-11-08 13:45                                           ` Daniel Lezcano
     [not found]                                             ` <473312FD.5030609-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-11-08 13:58                                               ` Pavel Emelyanov
     [not found]                                                 ` <473315F5.20608-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2007-11-08 14:08                                                   ` Benjamin Thery
2007-11-08 14:09                                                   ` Daniel Lezcano
     [not found]                                                     ` <473318A0.7010509-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-11-09 10:14                                                       ` Pavel Emelyanov
2007-11-08 14:05                                               ` Denis V. Lunev
     [not found]                                                 ` <473317A2.2020307-3ImXcnM4P+0@public.gmane.org>
2007-11-08 14:00                                                   ` Daniel Lezcano
2007-11-08 13:43                                   ` Pid namespaces problems Denis V. Lunev

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=m1640id57r.fsf@ebiederm.dsl.xmission.com \
    --to=ebiederm-as9lmozglivwk0htik3j/w@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.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