Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751558AbdG0RSa convert rfc822-to-8bit (ORCPT ); Thu, 27 Jul 2017 13:18:30 -0400 Received: from g2t1383g.austin.hpe.com ([15.233.16.89]:48783 "EHLO g2t1383g.austin.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981AbdG0RS0 (ORCPT ); Thu, 27 Jul 2017 13:18:26 -0400 From: "Magalhaes, Guilherme (Brazil R&D-CL)" To: Mimi Zohar , "Serge E. Hallyn" CC: Mehmet Kayaalp , Yuqiong Sun , containers , linux-kernel , David Safford , "James Bottomley" , linux-security-module , ima-devel , Yuqiong Sun Subject: RE: [Linux-ima-devel] [RFC PATCH 1/5] ima: extend clone() with IMA namespace support Thread-Topic: [Linux-ima-devel] [RFC PATCH 1/5] ima: extend clone() with IMA namespace support Thread-Index: AQHTAasZRnYdXqbK8Eu44qjVHwfC/qJk2nOAgAAPogCAAAQnAIAAAV6AgAAK6QCAAAaNgIAACb8AgAADPYCAAALQgIAABdUAgAKLihCAACa8gIAAJxeg Date: Thu, 27 Jul 2017 17:18:22 +0000 Message-ID: References: <20170720225033.21298-1-mkayaalp@linux.vnet.ibm.com> <20170720225033.21298-2-mkayaalp@linux.vnet.ibm.com> <20170725175317.GA727@mail.hallyn.com> <1501008554.3689.30.camel@HansenPartnership.com> <20170725190406.GA1883@mail.hallyn.com> <1501009739.3689.33.camel@HansenPartnership.com> <1501012082.27413.17.camel@linux.vnet.ibm.com> <645db815-7773-e351-5db7-89f38cd88c3d@linux.vnet.ibm.com> <20170725204622.GA4969@mail.hallyn.com> <1501016277.27413.50.camel@linux.vnet.ibm.com> <20170725210801.GA5628@mail.hallyn.com> <1501018134.27413.66.camel@linux.vnet.ibm.com> <1501166369.28419.171.camel@linux.vnet.ibm.com> In-Reply-To: <1501166369.28419.171.camel@linux.vnet.ibm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=guilherme.magalhaes@hpe.com; x-originating-ip: [15.211.195.12] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;TU4PR84MB0301;7:tHt/uyD8fF87WMo91Rmcb51r8poRIivkSyp0qlDBSRHkZL2PnerA7es36fBuHzjbNBYl1gJh6PRTgLOc1k69CbOzTKcF0q8/j2IZEIh3uNUH7cWQGl9zpWq1axSEIu83h2c0Ig1igm207OxMfgxsBfqT4uZVmZDvbikXzJYG+I68ymJqJE/iSsNjnlPC1tDR3GhOq2ah2ij59CsUcWMRwMBNjpxGj1m4z8DGBqoJeV1vp713N7etKzx5fkrBVcU+/THEbZqaLKDK2uHkgX8bkg+/TrahsaTpehybFdC9gkJXSV7YrQx9dPeL4hynbXRmdCKIc/7w3Txk0XQTiEI1imhFpP9uNpcrBw3Rn0jU4/6UGkKpO85XOKrd9BcoAZGarWhTpO7zOOpiro4Kqm/apZhNj1NfK5VBfY4KyaID3jlngLC/ObPizOd06MeQ5Yh+pBA0D4HhQE/KJ4e6QOAeD0tu+sYDGan5FgMIIEf21LyyMwIFcCacRT546Gq/i+aX+uaYJX5CdJtfFK79DpGktkn7Nyl+LJDrxuOc7381UHsMJhxggaPX9azjDupleEmZL8QZL1xdvEb2/es8AlmNjO8UCnKTl96GCLjHaapk8D1f+uvQwyKbTtPxw9W/GjYoB+KEDEFfbGFbAcyiZBDcPK3ZtpY0dCJ3gpOzZNDW6hXxzWJS5Cr03ellVurm8N62nIqczOCfvk2kugtoCKkSYBoDmxylL32M7mZOM3vxB+GsyghTKhkqCtmc48EDxPMvOoC08+QB7kbkinMPAnNMoxyK7h3fKHbatVY87NAPoyo= x-ms-office365-filtering-correlation-id: 7ed005d6-cf7b-474c-c355-08d4d5137be6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:TU4PR84MB0301; x-ms-traffictypediagnostic: TU4PR84MB0301: x-exchange-antispam-report-test: UriScan:(143289334528602)(227479698468861)(192374486261705)(9452136761055)(106981052589767)(42262312472803)(274839183919467)(104084551191319); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123562025)(20161123560025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:TU4PR84MB0301;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:TU4PR84MB0301; x-forefront-prvs: 03818C953D x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39850400002)(39410400002)(39860400002)(39400400002)(39450400003)(39840400002)(377454003)(189002)(199003)(24454002)(13464003)(54534003)(377424004)(4326008)(39060400002)(55016002)(3846002)(54906002)(102836003)(6116002)(81166006)(9686003)(81156014)(3280700002)(93886004)(68736007)(25786009)(97736004)(76176999)(3660700001)(77096006)(8656003)(2906002)(189998001)(74316002)(101416001)(50986999)(86362001)(6506006)(229853002)(54356999)(5660300001)(33656002)(66066001)(2950100002)(7696004)(6246003)(53546010)(7736002)(305945005)(106356001)(105586002)(478600001)(38730400002)(8936002)(230783001)(53936002)(2900100001)(7416002)(8676002)(6436002)(14454004)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:TU4PR84MB0301;H:TU4PR84MB0302.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jul 2017 17:18:22.3710 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: TU4PR84MB0301 X-OriginatorOrg: hpe.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9582 Lines: 209 > -----Original Message----- > From: Mimi Zohar [mailto:zohar@linux.vnet.ibm.com] > Sent: quinta-feira, 27 de julho de 2017 11:39 > To: Magalhaes, Guilherme (Brazil R&D-CL) > ; Serge E. Hallyn > Cc: Mehmet Kayaalp ; Yuqiong Sun > ; containers foundation.org>; linux-kernel ; David Safford > ; James Bottomley > ; linux-security-module security-module@vger.kernel.org>; ima-devel devel@lists.sourceforge.net>; Yuqiong Sun > Subject: Re: [Linux-ima-devel] [RFC PATCH 1/5] ima: extend clone() with IMA > namespace support > > On Thu, 2017-07-27 at 12:51 +0000, Magalhaes, Guilherme (Brazil R&D- > CL) wrote: > > > > > > > On Tue, 2017-07-25 at 16:08 -0500, Serge E. Hallyn wrote: > > > > On Tue, Jul 25, 2017 at 04:57:57PM -0400, Mimi Zohar wrote: > > > > > On Tue, 2017-07-25 at 15:46 -0500, Serge E. Hallyn wrote: > > > > > > On Tue, Jul 25, 2017 at 04:11:29PM -0400, Stefan Berger wrote: > > > > > > > On 07/25/2017 03:48 PM, Mimi Zohar wrote: > > > > > > > >On Tue, 2017-07-25 at 12:08 -0700, James Bottomley wrote: > > > > > > > >>On Tue, 2017-07-25 at 14:04 -0500, Serge E. Hallyn wrote: > > > > > > > >>>On Tue, Jul 25, 2017 at 11:49:14AM -0700, James Bottomley > wrote: > > > > > > > >>>>On Tue, 2017-07-25 at 12:53 -0500, Serge E. Hallyn wrote: > > > > > > > >>>>>On Thu, Jul 20, 2017 at 06:50:29PM -0400, Mehmet Kayaalp > > > wrote: > > > > > > > >>>>>> > > > > > > > >>>>>>From: Yuqiong Sun > > > > > > > >>>>>> > > > > > > > >>>>>>Add new CONFIG_IMA_NS config option. Let clone() create > a > > > > > > > >>>>>>new IMA namespace upon CLONE_NEWNS flag. Add > ima_ns > > > data > > > > > > > >>>>>>structure in nsproxy. ima_ns is allocated and freed upon > > > > > > > >>>>>>IMA namespace creation and exit. Currently, the ima_ns > > > > > > > >>>>>>contains no useful IMA data but only a dummy interface. > > > > > > > >>>>>>This patch creates the framework for namespacing the > > > different aspects of IMA (eg. > > > > > > > >>>>>>IMA-audit, IMA-measurement, IMA-appraisal). > > > > > > > >>>>>> > > > > > > > >>>>>>Signed-off-by: Yuqiong Sun > > > > > > > >>>>>> > > > > > > > >>>>>>Changelog: > > > > > > > >>>>>>* Use CLONE_NEWNS instead of a new CLONE_NEWIMA > flag > > > > > > > >>>>>Hi, > > > > > > > >>>>> > > > > > > > >>>>>So this means that every mount namespace clone will clone > a > > > > > > > >>>>>new IMA namespace. Is that really ok? > > > > > > > >>>>Based on what: space concerns (struct ima_ns is reasonably > > > small)? > > > > > > > >>>>or whether tying it to the mount namespace is the correct > > > > > > > >>>>thing to do. On > > > > > > > >>>Mostly the latter. The other would be not so much space > > > > > > > >>>concerns as time concerns. Many things use new mounts > > > > > > > >>>namespaces, and we wouldn't want multiple IMA calls on all > > > > > > > >>>file accesses by all of those. > > > > > > > >>> > > > > > > > >>>>the latter, it does seem that this should be a property of > > > > > > > >>>>either the mount or user ns rather than its own separate ns. > > > > > > > >>>>I could see a use where even a container might want multiple > > > > > > > >>>>ima keyrings within the container (say containerised apache > > > > > > > >>>>service with multiple tenants), so instinct tells me that > > > > > > > >>>>mount ns is the correct granularity for this. > > > > > > > >>>I wonder whether we could use echo 1 > > > > > > > > >>>/sys/kernel/security/ima/newns as the trigger for requesting > > > > > > > >>>a new ima ns on the next clone(CLONE_NEWNS). > > > > > > > >>I could go with that, but what about the trigger being > > > > > > > >>installing or updating the keyring? That's the only operation > > > > > > > >>that needs namespace separation, so on mount ns clone, you > get > > > > > > > >>a pointer to the old ima_ns until you do something that > > > > > > > >>requires a new key, which then triggers the copy of the > namespace > > > and installing it? > > > > > > > >It isn't just the keyrings that need to be namespaced, but the > > > > > > > >measurement list and policy as well. > > > > > > > > > > > > > > > >IMA-measurement, IMA-appraisal and IMA-audit are all policy > > > based. > > > > > > > > > > > > > > > >As soon as the namespace starts, measurements should be > added > > > > > > > >to the namespace specific measurement list, not it's parent. > > > > > > > > > > > > Shouldn't it be both? > > > > > > > > > > The policy defines which files are measured. ?The namespace policy > > > > > could be different than it's parent's policy, and the parent's > > > > > policy could be different than the native policy. ?Basically, file > > > > > measurements need to be added to the namespace measurement > list, > > > > > recursively, up to the native measurement list. > > > > > > > > Yes, but if a task t1 is in namespace ns2 which is a child of > > > > namespace ns1, and it accesses a file which ns1's policy says must be > > > > measured, then will ns1's required measurement happen (and be > > > appended > > > > to the ns1 measurement list), whether or not ns2's policy requires it? > > > > > > Yes, as the file needs to be measured only in the ns1 policy, the > > > measurement would exist in the ns1 measurement list, but not in the > > > ns2 measurement list. ?The pseudo code snippet below might help. > > > > This algorithm is potentially extending a PCR in TPM multiple times > > for a single file event under a given namespace and duplicating > > entries. Any concerns with performance and memory footprint? > > Going forward we assume associated with each container will be a vTPM. > The namespace measurements will extend a vTPM. ?As the container comes > and goes the associated measurement list, keyring, and vTPM will come > and go as well. ?For this reason, based on policy, the same file > measurement might appear in multiple measurement lists. My concern is that the base of namespacing the measurement lists is on the integration of containers with vTPM. Associating vTPM with containers as they are today is not a simple integration since vTPM requires a VM and containers do not. I cannot envision this association right now, but it might be possible after some research to understand the existent possibilities. For example, Intel SGX or clear containers may help with this integration. However, these technologies have trade-offs which could restrict adoption. -- Guilherme > > > What is the reason to adding a measurement to multiple namespace > > measurement lists? How are these lists going to be used? For Remote > > Attestation we need a single list (the native one) which has the > > complete list of measurements and in the same order they were > > extended in the TPM. Additionally, when namespaces are released, > > would the measurement list under that namespace disappear? How to > > store this list considering the namespaces may have a short life and > > be reused thousands of times? > > Different scenarios have different requirements. ?You're assuming that > only the system owner is interested in the measurement list, not the > container owner. > > The current builtin measurement policies measure everything executed > on the system and anything accessed by real root. ?The namespace > policy would probably be similar, but instead of measuring files > accessed by real root, it would be files accessed by root in the > namespace. > > > Should the native measurement list have all measurements triggered > > in the whole system, including the ones made under other namespaces? > > Following the algorithm below, if the file is not in the policy of > > the 'native'/initial namespace, the measurement is not added to the > > native measurement list. > > Correct. ?The policy controls what is included measured, appraised, > and audited. > > > Each measurement entry in the list could have new fields to identify > > the namespace. Since the namespaces can be reused, a timestamp or > > others fields could be added to uniquely identify the namespace id. > > The more fields included in the measurement list, the more > measurements will be added to the measurement list. ?Wouldn't it be > enough to know that a certain file has been accessed/executed on the > system and base any analytics/forensics on the IMA-audit data. > > > Regarding namespace hierarchy and IMA policy, we could assume that > > if a given namespace has no policy set, the policy of that namespace > > parent is applied and then the native/initial namespace should > > always have a set policy. > > We shouldn't assume measure, appraise, or audit by default. ?Just like > it is up to the native system to define a policy or if there is a > policy, the "container" owner should define the policy, or if there is > a policy. > > Mimi > > > > > > > do { > > > . > > > . > > > > > > /* calculate file hash based on xattr algorithm */ > > > collect_measurement() > > > > > > /* recursively added to each namespace based on policy */ > > > ima_store_measurement() > > > > > > /* Based on the specific namespace policy and keys. */ > > > if (!once) { > > > once = 1; > > > result = ima_appraise_measurement() > > > } > > > > > > ima_audit_measurement() > > > > > > } while ((ns = ns->parent)); > > > > > > return result; > > > > > > Mimi