Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Jun 2015 19:17:03 +0200
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        kikuchan <kikuchan@uranus.dti.ne.jp>
Cc:        freebsd-jail@freebsd.org, freebsd-stable@freebsd.org
Subject:   Re: [patch] separate SysV IPC namespace for jail
Message-ID:  <20150608171702.GA15516@dft-labs.eu>
In-Reply-To: <CAG40kxGFvgP0Zhoseo%2BDi2Zk2J6kf0jA8isZD5UDOoqnWdkqYQ@mail.gmail.com>
References:  <CAG40kxFFnfvbLbqVprPC0oZ%2BnbKDYGxdvgd-vxWXFfN%2B3NQ0_A@mail.gmail.com> <20150605235348.GA9965@dft-labs.eu> <CAG40kxEaOAmcOCwb7p6NF6sgox-KysKh2RJgG7og1fi0WL0-Sg@mail.gmail.com> <20150607013929.GA9182@dft-labs.eu> <CAG40kxFaD%2BTS3Asb7ZiRW67XLtMOe6ChDEVgkSnt1Ji3013j4w@mail.gmail.com> <20150607083734.GB9182@dft-labs.eu> <CAG40kxGFvgP0Zhoseo%2BDi2Zk2J6kf0jA8isZD5UDOoqnWdkqYQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jun 08, 2015 at 01:42:21AM +0900, kikuchan wrote:
> From my curiosity, is my patch a technically bad?
> Is there race condition in it? Or, enabling key_t separation for jail
> could trigger race condition, perhaps?
> 

I only briefly looked at the patch. The fact that you perform outside of
ipcperm looks suspicious but may be harmless, so at best it's a bad
style. If you need ipc mechanism-specifc functions, make them call
ipcperm instead.

The jail check is too simplistic. Jails higher in the hierarchy should be
able to access whatever lower jails produced.

> 
> > I do see great benefit in having jail-aware ipcs.
> >
> > I do not believe the way to achieve it is to add jail-aware permission
> > checks. Support in question should provide support for separate
> > namespaces. The are several upsides, including lack of conflict between
> > jails and plugged infoleaks.
> 
> Sorry but I might misunderstand what your "separate namespaces" means.
> What namespace are you going to separate? key_t, shmid, kernel
> structure of shm, or others?
> What features do your "jail-aware ipcs" provide?
> 

Well, as I said in my first mail the idea is to make ipc code look at
structures assigned to given jail, so that we can have multiple jails
with only their own objects. No "well, this id is used by other jail",
unless the namespace is explicitly shared.

I did have a patch with a meh implementation doing this, but I lost it
along the way. It is easy to implement it for "private purposes" (i.e.
disregarding possible attacks with jailing processes). The real work is
making the whole business safe.

For instance back then I could not find any reliable mechanism to tell
me whether given process has a shared address space. There is only a
vm_refcnt counter in vmspace which is modified on various occasions,
thus is not suitable. Adding a separate counter sucks and adding a "once
set, never cleared flag" sucks as well. Maybe there is a good method.

-- 
Mateusz Guzik <mjguzik gmail.com>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150608171702.GA15516>