Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp71089ybh; Mon, 20 Jul 2020 10:34:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWN3VeTGUImEKsGMa7BtQixA4udjsHS9fEuVRdiZ14+ubAVt9fGEsgJVGZWshPszRgHV1T X-Received: by 2002:a17:906:6852:: with SMTP id a18mr14946285ejs.348.1595266497370; Mon, 20 Jul 2020 10:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595266497; cv=none; d=google.com; s=arc-20160816; b=wHm75hRnnX5AdN+9V3q/Iq/cVRwWnO0zV69uvtQJ3GMWmjPQ9iODOsESSEK7nXQu40 qna8MX/xXTSA3aGhjA8SyrUd3EEhM+FMKvzavcVuZkln61QzI+Mg1QKgl/jE0z7ZHcDr rdODB2kQj931FpT77vWFn9euf1w3g47dBMhfqQMYO8Umqio+YfVH7PH/Dmasuuan3ByH VqyZ0zRnte/Gfc73CqHbHIDozt0MwObyMKmuJ57Im12+Dh9sbWFoX8O/2lYbhv6P8o73 +5hMhE0EHA+8Lzww21s97am5WilDLfNIhHvFgQsh1iKYDaLI4E2zE/Fxm2z6+oex+hLi MHaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature:dkim-filter; bh=IZbk6/wtyJwvcs8UDH0IEXfn70iZQSY+5CSfF+kU3Rc=; b=LhE/c5ErPQ2rKHdT05yIwXg791GgLKbW7mTV2WNYRyTRlBouqPIxl+0gWqeENaPX2n iq252LnUVXOWe1IGysI14DI8CXguLtBtPXrI5GDNFQpOS2vq+lBGzNPIKUpFTH5V0F6H ncPxVZi4H3LhREQFDcXkZ+v8nebKuWoLT05ncH9kIZHyOhF/xQI7i1NOx5ru7m2Jgdtx oSBRrcqB++71izHS0s3FciQ9pJH7JQn7bT/dZF29NO1theDuNvB/SzT2TD7uqje7EgZC 2Z/SNPMXNS3FHZTGZYTCgObWP8SanoOuIwTUXsfwt8kZN7laP/ArQQtVxmIcAk+ZhTxE pFBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=VNdAmeiW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q26si10682055ejc.433.2020.07.20.10.34.34; Mon, 20 Jul 2020 10:34:57 -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; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=VNdAmeiW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732897AbgGTReL (ORCPT + 99 others); Mon, 20 Jul 2020 13:34:11 -0400 Received: from linux.microsoft.com ([13.77.154.182]:37202 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbgGTReL (ORCPT ); Mon, 20 Jul 2020 13:34:11 -0400 Received: from [192.168.0.104] (c-73-42-176-67.hsd1.wa.comcast.net [73.42.176.67]) by linux.microsoft.com (Postfix) with ESMTPSA id 7E77B20B4909; Mon, 20 Jul 2020 10:34:10 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7E77B20B4909 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1595266450; bh=IZbk6/wtyJwvcs8UDH0IEXfn70iZQSY+5CSfF+kU3Rc=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=VNdAmeiW7jXcjnKnfNMnaEBf/ezZled7360IOAy1VUzHALwt7jjuWoAkwpSXHpul/ 4qfljZOmlJYttBy+0X7xXG+shb+uBTxDvlNY08zkr5FvlqeFMYE2GE92azX5ggHui+ +DsrMVMna+iBrldPtiweIP24gad0m/PYLoQGCPlg= Subject: Re: [PATCH v3 4/5] LSM: Define SELinux function to measure security state To: Stephen Smalley Cc: Mimi Zohar , Casey Schaufler , James Morris , linux-integrity@vger.kernel.org, SElinux list , LSM List , linux-kernel References: <20200717222819.26198-1-nramas@linux.microsoft.com> <20200717222819.26198-5-nramas@linux.microsoft.com> From: Lakshmi Ramasubramanian Message-ID: Date: Mon, 20 Jul 2020 10:34:06 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/20/20 10:06 AM, Stephen Smalley wrote: >> The above will ensure the following sequence will be measured: >> #1 State A - Measured >> #2 Change from State A to State B - Measured >> #3 Change from State B back to State A - Since the measured data is >> same as in #1, the change will be measured only if the event name is >> different between #1 and #3 > > Perhaps the timestamp / sequence number should be part of the hashed > data instead of the event name? If the timestamp/seqno is part of the hashed data, on every call to measure IMA will add a new entry in the IMA log. This would fill up the IMA log - even when there is no change in the measured data. To avoid that I keep the last measurement in SELinux and measure only when there is a change with the timestamp in the event name. > I can see the appraiser wanting to know two things: > 1) The current state of the system (e.g. is it enforcing, is the > currently loaded policy the expected one?). > 2) Has the system ever been in an unexpected state (e.g. was it > temporarily switched to permissive or had an unexpected policy > loaded?) Yes - you are right. The appraiser will have to look at the entire IMA log (and the corresponding TPM PCR data) to know the above. Time t0 => State of the system measured Time tn => State changed and the new state measured Time tm => State changed again and the new state measured. Say, the measurement at "Time tn" was an illegal change, the appraiser would know. > > I applied the patch series on top of the next-integrity branch, added > measure func=LSM_STATE to ima-policy, and booted that kernel. I get > the following entries in ascii_runtime_measurements, but seemingly > missing the final field: > > 10 8a09c48af4f8a817f59b495bd82971e096e2e367 ima-ng > sha256:21c3d7b09b62b4d0b3ed15ba990f816b94808f90b76787bfae755c4b3a44cd24 > selinux-state > 10 e610908931d70990a2855ddb33c16af2d82ce56a ima-ng > sha256:c8898652afd5527ef4eaf8d85f5fee1d91fcccee34bc97f6e55b96746bedb318 > selinux-policy-hash > > Thus, I cannot verify. What am I missing? > Looks like the template used is ima-ng which doesn't include the measured buffer. Please set template to "ima-buf" in the policy. For example, measure func=LSM_STATE template=ima-buf thanks, -lakshmi