From owner-freebsd-jail@freebsd.org Tue Mar 22 23:25:14 2016 Return-Path: Delivered-To: freebsd-jail@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E154ADAB68 for ; Tue, 22 Mar 2016 23:25:14 +0000 (UTC) (envelope-from jamie@freebsd.org) Received: from gritton.org (gritton.org [162.220.209.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "www.gritton.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 432761375; Tue, 22 Mar 2016 23:25:13 +0000 (UTC) (envelope-from jamie@freebsd.org) Received: from gritton.org (gritton.org [162.220.209.3]) by gritton.org (8.15.2/8.15.2) with ESMTPS id u2MNPCe8005513 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Mar 2016 17:25:12 -0600 (MDT) (envelope-from jamie@freebsd.org) Received: (from www@localhost) by gritton.org (8.15.2/8.15.2/Submit) id u2MNPBIv005512; Tue, 22 Mar 2016 17:25:11 -0600 (MDT) (envelope-from jamie@freebsd.org) X-Authentication-Warning: gritton.org: www set sender to jamie@freebsd.org using -f To: freebsd-jail@freebsd.org Subject: Re: SHM objects cannot be isolated in jails, any evolution in future FreeBSD versions? X-PHP-Originating-Script: 0:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 22 Mar 2016 17:25:11 -0600 From: James Gritton In-Reply-To: <27abd17bc67680df02ef6d06f31d77be@whitewinterwolf.com> References: <0ad738494152d249f3bbe3b722a46bd2@gritton.org> <1457989662.568170.549069906.791C2D05@webmail.messagingengine.com> <56E7C926.3020201@quip.cz> <27abd17bc67680df02ef6d06f31d77be@whitewinterwolf.com> Message-ID: <972dba829167a5fd824faf61663a3aae@gritton.org> X-Sender: jamie@freebsd.org User-Agent: Roundcube Webmail/1.1.2 X-BeenThere: freebsd-jail@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Discussion about FreeBSD jail\(8\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2016 23:25:14 -0000 On 2016-03-17 05:54, Simon wrote: > Le 2016-03-15 09:34, Miroslav Lachman a écrit : >> Mark Felder wrote on 03/14/2016 22:07: >>> >>> >>> On Sat, Mar 12, 2016, at 11:42, James Gritton wrote: >>>> On 2016-03-12 04:05, Simon wrote: >>>>> The shm_open()(2) function changed since FreeBSD 7.0: the SHM >>>>> objects >>>>> path are now uncorrelated from the physical file system to become >>>>> just >>>>> abstract objects. Probably due to this, the jail system do not >>>>> provide >>>>> any form of filtering regarding shared memory created using this >>>>> function. Therefore: >>>>> >>>>> - Anyone can create unauthorized communication channels between >>>>> jails, >>>>> - Users with enough privileges in any jail can access and modify >>>>> any >>>>> SHM objects system-wide, ie. shared memory objects created in any >>>>> other jail and in the host system. >>>>> >>>>> I've seen a few claims that SHM objects were being handled >>>>> differently >>>>> whether they were created inside or outside a jail. However, I >>>>> tested >>>>> on FreeBSD 10.1 and 9.3 but found no evidence of this: both version >>>>> were affected by the same issue. >>>>> >>>>> A reference of such claim: >>>>> https://lists.freebsd.org/pipermail/freebsd-ports-bugs/2015-July/312665.html >>>>> >>>>> My initial post on FreeBSD forum discussing the issue with more >>>>> details: https://forums.freebsd.org/threads/55468/ >>>>> >>>>> Currently, there does not seem to be any way to prevent this. >>>>> >>>>> I'm therefore wondering if there are any concrete plans to change >>>>> this >>>>> situation in future FreeBSD versions? Be able to block the >>>>> currently >>>>> free inter-jail SHM-based communication seems a minimum, however >>>>> such >>>>> setting would also most likely prevent SHM-based application to >>>>> work. >>>>> >>>>> Using file based SHM objects in jails seemed a good ideas but it >>>>> does >>>>> not seem implemented this way, I don't know why. Is this planned, >>>>> or >>>>> are there any greater plans ongoing also involving IPC's similar >>>>> issue? >>>> >>>> There are no concrete plans I'm aware of, but it's definitely a >>>> thing >>>> that should be done. How about filing a bug report for it? You've >>>> already got a good write-up of the situation. >>>> >>> >>> Both this and SYSV IPC jail support[1] are badly needed. >>> >>> [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=48471 >> >> Yes, it is very sad that original patch was not commited, nor >> commented or improved by core developers for long 13 years. I am not >> 100% sure but I thing there was some patch from PJD for SysV IPC too. >> There were EclipseBSD with resource limits in times of FreeBSD 3.4 and >> there is FreeVPS for 6.x with virtualized IPC... >> >> So I really hope SysV IPC aware jails will become reality soon. >> >> Miroslav Lachman > > Hi everyone, > > Odd thing, I've seen that the very first exchanges which opened this > mailing list back in 2007 precisely discussed IPC isolation in Jail > and some work already done in the Jail2 project part of the now > abandoned FreeVPS project. At that time IPC virtualization was > qualified as an easy job: > >> As say about SYSV IPC stuff you say about only virtualization? or >> also about limits? "virtualization" is easy, but for limits - need >> more >> work > (https://lists.freebsd.org/pipermail/freebsd-jail/2007-May/000004.html) > > We have now come full circle :). > > As per the SHM objects issue, I've now filled a new bug #208082: > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208082 > > I explain in the bug description why it may be different than the > already existing bug #48471 covering SysV IPC. > > Le 2016-03-17 01:10, Dewayne Geraghty a écrit : >> PS We don't want/need the complexity (or performance hit) associated >> with v* additions when a well thought out (simple) jail does the task >> very nicely :) > > I agree, the main advantage of jails and other lightweight containers > is precisely their lightness. > > Regards, > Simon. I've put a diff on the bug report (Bug 208082), for the shm objects, and also for ksem and mqueue which have the same problems. Any review is welcome :-). SYSV IPC is a separate issue. I'm following up with bz about my memory of hearing there's something vimage-related there, and if there isn't I can jump into that one as well (I actually have some work already done with it, so it just needs a little more). - Jamie From owner-freebsd-jail@freebsd.org Wed Mar 23 09:16:18 2016 Return-Path: Delivered-To: freebsd-jail@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 48EFB99A23C for ; Wed, 23 Mar 2016 09:16:18 +0000 (UTC) (envelope-from 000.fbsd@quip.cz) Received: from elsa.codelab.cz (elsa.codelab.cz [94.124.105.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E62F61A89; Wed, 23 Mar 2016 09:16:17 +0000 (UTC) (envelope-from 000.fbsd@quip.cz) Received: from elsa.codelab.cz (localhost [127.0.0.1]) by elsa.codelab.cz (Postfix) with ESMTP id 1016828412; Wed, 23 Mar 2016 10:16:14 +0100 (CET) Received: from illbsd.quip.test (ip-86-49-16-209.net.upcbroadband.cz [86.49.16.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by elsa.codelab.cz (Postfix) with ESMTPSA id 3EA8A2840C; Wed, 23 Mar 2016 10:16:12 +0100 (CET) Message-ID: <56F25EDB.1090408@quip.cz> Date: Wed, 23 Mar 2016 10:16:11 +0100 From: Miroslav Lachman <000.fbsd@quip.cz> User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:35.0) Gecko/20100101 Firefox/35.0 SeaMonkey/2.32 MIME-Version: 1.0 To: James Gritton , freebsd-jail@freebsd.org Subject: Re: SHM objects cannot be isolated in jails, any evolution in future FreeBSD versions? References: <0ad738494152d249f3bbe3b722a46bd2@gritton.org> <1457989662.568170.549069906.791C2D05@webmail.messagingengine.com> <56E7C926.3020201@quip.cz> <27abd17bc67680df02ef6d06f31d77be@whitewinterwolf.com> <972dba829167a5fd824faf61663a3aae@gritton.org> In-Reply-To: <972dba829167a5fd824faf61663a3aae@gritton.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-jail@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Discussion about FreeBSD jail\(8\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2016 09:16:18 -0000 James Gritton wrote on 03/23/2016 00:25: > On 2016-03-17 05:54, Simon wrote: >> Le 2016-03-15 09:34, Miroslav Lachman a écrit : >>> Mark Felder wrote on 03/14/2016 22:07: >>>> >>>> >>>> On Sat, Mar 12, 2016, at 11:42, James Gritton wrote: >>>>> On 2016-03-12 04:05, Simon wrote: >>>>>> The shm_open()(2) function changed since FreeBSD 7.0: the SHM objects >>>>>> path are now uncorrelated from the physical file system to become >>>>>> just >>>>>> abstract objects. Probably due to this, the jail system do not >>>>>> provide >>>>>> any form of filtering regarding shared memory created using this >>>>>> function. Therefore: >>>>>> >>>>>> - Anyone can create unauthorized communication channels between >>>>>> jails, >>>>>> - Users with enough privileges in any jail can access and modify any >>>>>> SHM objects system-wide, ie. shared memory objects created in any >>>>>> other jail and in the host system. >>>>>> >>>>>> I've seen a few claims that SHM objects were being handled >>>>>> differently >>>>>> whether they were created inside or outside a jail. However, I tested >>>>>> on FreeBSD 10.1 and 9.3 but found no evidence of this: both version >>>>>> were affected by the same issue. >>>>>> >>>>>> A reference of such claim: >>>>>> https://lists.freebsd.org/pipermail/freebsd-ports-bugs/2015-July/312665.html >>>>>> >>>>>> >>>>>> My initial post on FreeBSD forum discussing the issue with more >>>>>> details: https://forums.freebsd.org/threads/55468/ >>>>>> >>>>>> Currently, there does not seem to be any way to prevent this. >>>>>> >>>>>> I'm therefore wondering if there are any concrete plans to change >>>>>> this >>>>>> situation in future FreeBSD versions? Be able to block the currently >>>>>> free inter-jail SHM-based communication seems a minimum, however such >>>>>> setting would also most likely prevent SHM-based application to work. >>>>>> >>>>>> Using file based SHM objects in jails seemed a good ideas but it does >>>>>> not seem implemented this way, I don't know why. Is this planned, or >>>>>> are there any greater plans ongoing also involving IPC's similar >>>>>> issue? >>>>> >>>>> There are no concrete plans I'm aware of, but it's definitely a thing >>>>> that should be done. How about filing a bug report for it? You've >>>>> already got a good write-up of the situation. >>>>> >>>> >>>> Both this and SYSV IPC jail support[1] are badly needed. >>>> >>>> [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=48471 >>> >>> Yes, it is very sad that original patch was not commited, nor >>> commented or improved by core developers for long 13 years. I am not >>> 100% sure but I thing there was some patch from PJD for SysV IPC too. >>> There were EclipseBSD with resource limits in times of FreeBSD 3.4 and >>> there is FreeVPS for 6.x with virtualized IPC... >>> >>> So I really hope SysV IPC aware jails will become reality soon. >>> >>> Miroslav Lachman >> >> Hi everyone, >> >> Odd thing, I've seen that the very first exchanges which opened this >> mailing list back in 2007 precisely discussed IPC isolation in Jail >> and some work already done in the Jail2 project part of the now >> abandoned FreeVPS project. At that time IPC virtualization was >> qualified as an easy job: >> >>> As say about SYSV IPC stuff you say about only virtualization? or >>> also about limits? "virtualization" is easy, but for limits - need more >>> work >> (https://lists.freebsd.org/pipermail/freebsd-jail/2007-May/000004.html) >> >> We have now come full circle :). >> >> As per the SHM objects issue, I've now filled a new bug #208082: >> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208082 >> >> I explain in the bug description why it may be different than the >> already existing bug #48471 covering SysV IPC. >> >> Le 2016-03-17 01:10, Dewayne Geraghty a écrit : >>> PS We don't want/need the complexity (or performance hit) associated >>> with v* additions when a well thought out (simple) jail does the task >>> very nicely :) >> >> I agree, the main advantage of jails and other lightweight containers >> is precisely their lightness. >> >> Regards, >> Simon. > > I've put a diff on the bug report (Bug 208082), for the shm objects, and > also for ksem and mqueue which have the same problems. Any review is > welcome :-). > > SYSV IPC is a separate issue. I'm following up with bz about my memory > of hearing there's something vimage-related there, and if there isn't I > can jump into that one as well (I actually have some work already done > with it, so it just needs a little more). I am more interested in SysV IPC (needed to run PostgreSQL in jails) but working SHM is good starting point. I really appreciate all your work on improving jails! Thank you for this great news :) Miroslav Lachman