Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1665478pxk; Tue, 1 Sep 2020 04:53:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRIZIvZpryqcHzjW2ObPkCcTDhDDbAOwqB5MdD7zHl/XQgUXlLVVRMjrq+Bwd6Bia17E4i X-Received: by 2002:a17:906:c108:: with SMTP id do8mr1223296ejc.88.1598961190144; Tue, 01 Sep 2020 04:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598961190; cv=none; d=google.com; s=arc-20160816; b=jBCaO1TgoGVAN9TsFz1t2qQtpduWzT6NGoh3ha04EfOEJqPoTc0kGdIcNFvPsOoNli xG7gsEddqrve4eqry3+MhehXaG+Hp78R2jVgIA0FhSWPrOfJ4Pf/C0qV5J2LNUeU8pxf 0K7kH2BNVyb3o7QDYT16wixpJwS33xMd7dZGYuEYgC8G6zlkCaf7kNoyR+7h/5iIyc53 3DUsfd2TI9YuyknghT4QUQZs5z5tUs3ZHkO0V4yya5ilqWQEfcCk4rogoIjZojtfCPbn F0iE4eAG10hU/smyw9NPx+Rb3KzsfSiFiSG++OQwGMfM58niMeJ6jN8SuN9jUAlXOwah qdxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=zlarGX4b7TlHjKUfiLX/48oOIjgABhb9aogNH0WVcSc=; b=TKCc1mXMhAh46IKLwPD60791nnMMeSTJGOmmYZdpJh1Gc9v3k6c1aq2qUkS9CQ901r XDhvoc8rY9T2bxAeXCnuUIaYgnIR3t4Rj9hr4UDcpMx2NV5KPbuCOLdjiAKrc7Z1C1/1 4Yv2GkDdJIZhZ4P++uBO7HXQHq4zuL76zn0w0CPsonBUfl10xwXHluDyOvVcOwe8HRso D/o7z6b2jHzeX03UwmL24cDyG/AvK0vmYiWCdgv/u+FJotjnQ02by/ehfpVGEHYe7r4R bt0x09WsE51V2BhMvKUoA4SViTEFkohJ6E+4lUA+78u7zwmnts41DjdrSHO0rks7syQR ftRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q24si438463edi.78.2020.09.01.04.52.47; Tue, 01 Sep 2020 04:53:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726091AbgIALsQ convert rfc822-to-8bit (ORCPT + 99 others); Tue, 1 Sep 2020 07:48:16 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2724 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726928AbgIALl7 (ORCPT ); Tue, 1 Sep 2020 07:41:59 -0400 Received: from lhreml726-chm.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id F168EDFA3E5FEAFFAA85; Tue, 1 Sep 2020 12:41:57 +0100 (IST) Received: from fraeml706-chm.china.huawei.com (10.206.15.55) by lhreml726-chm.china.huawei.com (10.201.108.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1913.5; Tue, 1 Sep 2020 12:41:57 +0100 Received: from fraeml714-chm.china.huawei.com (10.206.15.33) by fraeml706-chm.china.huawei.com (10.206.15.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1913.5; Tue, 1 Sep 2020 13:41:56 +0200 Received: from fraeml714-chm.china.huawei.com ([10.206.15.33]) by fraeml714-chm.china.huawei.com ([10.206.15.33]) with mapi id 15.01.1913.007; Tue, 1 Sep 2020 13:41:56 +0200 From: Roberto Sassu To: Mimi Zohar , "mjg59@google.com" CC: "linux-integrity@vger.kernel.org" , "linux-security-module@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Silviu Vlasceanu , "stable@vger.kernel.org" Subject: RE: [PATCH 07/11] evm: Set IMA_CHANGE_XATTR/ATTR bit if EVM_ALLOW_METADATA_WRITES is set Thread-Topic: [PATCH 07/11] evm: Set IMA_CHANGE_XATTR/ATTR bit if EVM_ALLOW_METADATA_WRITES is set Thread-Index: AQHWRYqWnNLPRhTOMk2ID5bSdlZ6YalHdJUAgAx1KTCAAAkjgIAAJpbA Date: Tue, 1 Sep 2020 11:41:56 +0000 Message-ID: <7f3dd815639a44ba9b0fb532c217bd21@huawei.com> References: <20200618160329.1263-2-roberto.sassu@huawei.com> <20200618160458.1579-7-roberto.sassu@huawei.com> <67cafcf63daf8e418871eb5302e7327ba851e253.camel@linux.ibm.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.48.193.114] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Mimi Zohar [mailto:zohar@linux.ibm.com] > Sent: Tuesday, September 1, 2020 1:05 PM > On Tue, 2020-09-01 at 09:08 +0000, Roberto Sassu wrote: > > > From: Mimi Zohar [mailto:zohar@linux.ibm.com] > > > Sent: Monday, August 24, 2020 2:18 PM > > > On Thu, 2020-06-18 at 18:04 +0200, Roberto Sassu wrote: > > > > When EVM_ALLOW_METADATA_WRITES is set, EVM allows any > operation > > > on > > > > metadata. Its main purpose is to allow users to freely set metadata > when > > > > they are protected by a portable signature, until the HMAC key is > loaded. > > > > > > > > However, IMA is not notified about metadata changes and, after the > first > > > > appraisal, always allows access to the files without checking metadata > > > > again. > > > > > > ^after the first successful appraisal > > > > > > > > This patch checks in evm_reset_status() if EVM_ALLOW_METADATA > > > WRITES is > > > > enabled and if it is, sets the IMA_CHANGE_XATTR/ATTR bits > depending on > > > the > > > > operation performed. At the next appraisal, metadata are revalidated. > > > > > > EVM modifying IMA bits crosses the boundary between EVM and IMA. > > > There > > > is already an IMA post_setattr hook. IMA could reset its own bit > > > there. If necessary EVM could export as a function it's status info. > > > > I wouldn't try to guess in IMA when EVM resets its status. We would have > > to duplicate the logic to check if an EVM key is loaded, if the passed xattr > > is a POSIX ACL, ... > > Agreed, but IMA could call an EVM function. > > > > > I think it is better to set a flag, maybe a new one, directly in EVM, to notify > > the integrity subsystem that iint->evm_status is no longer valid. > > > > If the EVM flag is set, IMA would reset the appraisal flags, as it uses > > iint->evm_status for appraisal. We can consider to reset also the measure > > flags when we have a template that includes file metadata. > > When would IMA read the EVM flag? Who would reset the flag? At what > point would it be reset? Just as EVM shouldn't be resetting the IMA > flag, IMA shouldn't be resetting the EVM flag. IMA would read the flag in process_measurement() and behave similarly to when it processes IMA_CHANGE_ATTR. The flag would be reset by evm_verify_hmac(). Roberto HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Li Peng, Li Jian, Shi Yanli