Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp800826pxa; Wed, 5 Aug 2020 13:06:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS0Kz24HCRYb0cH41w7XX6zpPL4uxlmcRLmNO9WL8gJirU9M5XFdz2q2tJnn1ZF0PnmbtL X-Received: by 2002:aa7:c697:: with SMTP id n23mr967278edq.50.1596657999950; Wed, 05 Aug 2020 13:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596657999; cv=none; d=google.com; s=arc-20160816; b=Za1IyitO/IBUX8rWhEm9/30V5PlTXVBj4zmTSi7Eo49mwOC6uOoOavGQsuCEr7hWRW i6iAoLIfLOhUMnait3IVLXfC+vrShSSyDA/upvXAGN7KaFt45rapFNpjTDzK24PYdGlX 4qdQarbJBgMybCVez+wTrDmDT41t8Lee91dCe7cHnxBbXc9rQb/w6FrzpZAMh0UdzKpc y+drNXrbfmWUPBHsZHziUsUjLFjaDTIirOtANoxbCiEOd6jjKsEiMm3tA8busMFM/iiU CaD5RSvpUsPyfc2fwM50IXURJCEHTR/5c1jkbDSvNf/1AufTEJP4kjBRK0GgJ/eUlTMa SVEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Blb5cBgplWWvh2yRMDcotzJrK1boXBQTYj1dnOWWj6w=; b=mEcyfibOmvuUWLkgNOj8yF0vj8GYJxKtWZzFse2n4xYHTS7fUZfRTjT2YRTc7i4ie2 9kHC0QuQj+rdxDhRIQjWmHSU2TPRQG5SjNg3Dil0HLYPMfspNnTrDkcj+cY7hHq1ZtWE GErw1zVd3jKqJk3yoTwQxma1VvcmFPBDMcluhHp9Zdy9hUWp5bAlI5kwYuTZshpANhZJ BzP5MS6O8Js1hK0PAoHpzDYRGj5DTgzYTlQID84NnA9U0Ni8CEmlU+C2Riakw6m/QoVc SrgegOJIHeaQPSeOQ8ensR7oRLQdLcOzJ2Rxb8j9VK2LoPLXVb+8WJvedWt63iOaEkrt xH3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hnBfreEj; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j6si1975138edn.543.2020.08.05.13.06.16; Wed, 05 Aug 2020 13:06:39 -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=@gmail.com header.s=20161025 header.b=hnBfreEj; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727059AbgHEUGF (ORCPT + 99 others); Wed, 5 Aug 2020 16:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727079AbgHEQfG (ORCPT ); Wed, 5 Aug 2020 12:35:06 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A40C008688; Wed, 5 Aug 2020 07:27:54 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id z22so9160331oid.1; Wed, 05 Aug 2020 07:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Blb5cBgplWWvh2yRMDcotzJrK1boXBQTYj1dnOWWj6w=; b=hnBfreEjxoFcyyZNt3AUYdaPJlBEboB8o3t+lXk2upTSKgdswAGiWu9jg/0bjDKIRn IxbZJyTdY5mBsKV2E+uLOpB1HJoAyGRTm3bsB96MFoSVhNKhiGr+4TzQjw9V4R1Au2Rd 614CJo1wYqs8liVDXesynQ6TiV5Ogr8/eto23NlJStfFnxz4eD0KTQeNrmJZ4le97+39 hlWODirNQ18FJITf4CF9EKWyKlGpA0diDIDbqpITq2JLYI1x+EoKQAl6+cQOx2m/EMBm hnqk6nBDt22HVn/BE+HPMZyYdTdZGzk0seX96HYBeTtARnZqpcTYd6vEvqwGsqTwSN0A Nr8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Blb5cBgplWWvh2yRMDcotzJrK1boXBQTYj1dnOWWj6w=; b=Ter8kW3QSibscGmf0NtxclMgqcchavT9cxnI/5pDUm965qj0GRjXXYqt2btLdu3gBb E0VCdreZSXoPzbpbu4ciqRxWWkbrNKLfhvcxXwSh7EBAs+HfaolWYp37PVwOIGOA/DAE XzC1uHyEnIKTtxM3Vjvp4ZacmwU6EsipSsl9gGGSiyl43MarfJbU9vZmc5eAqX5brMzb DKs848CWCB6IRxl156Yp45aHRbRDOT6QzdXQA/cC56us1C4VzHzNy/GVbgM63Nw4U391 Tim2kRjMQaYALAZi2uYvx2KMQQwiOUF5rREJ7tbLiEkWMr/2b05qv2ma1z1EDrC+bdF8 xwHw== X-Gm-Message-State: AOAM531YkgQkUiuLHGQhXRRKNLE8Lp9MpCa2leHMWKRD3bv0LfQG7eS2 5RxMk80BoyGtnFrP46DL03/T9UxuwtT/UcSKFfA= X-Received: by 2002:a54:4817:: with SMTP id j23mr2968773oij.140.1596637674297; Wed, 05 Aug 2020 07:27:54 -0700 (PDT) MIME-Version: 1.0 References: <20200805004331.20652-1-nramas@linux.microsoft.com> <20200805004331.20652-2-nramas@linux.microsoft.com> <4b9d2715d3ef3c8f915ef03867cfb1a39c0abc54.camel@linux.ibm.com> <31d00876438d2652890ab8bf6ba2e80f554ca7a4.camel@linux.ibm.com> In-Reply-To: From: Stephen Smalley Date: Wed, 5 Aug 2020 10:27:43 -0400 Message-ID: Subject: Re: [PATCH v6 1/4] IMA: Add func to measure LSM state and policy To: Mimi Zohar Cc: Lakshmi Ramasubramanian , Casey Schaufler , Tyler Hicks , sashal@kernel.org, James Morris , linux-integrity@vger.kernel.org, SElinux list , LSM List , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 5, 2020 at 9:20 AM Mimi Zohar wrote: > > On Wed, 2020-08-05 at 09:03 -0400, Stephen Smalley wrote: > > On Wed, Aug 5, 2020 at 8:57 AM Mimi Zohar wrote: > > > On Wed, 2020-08-05 at 08:46 -0400, Stephen Smalley wrote: > > > > On 8/4/20 11:25 PM, Mimi Zohar wrote: > > > > > > > > > Hi Lakshmi, > > > > > > > > > > There's still a number of other patch sets needing to be reviewed > > > > > before my getting to this one. The comment below is from a high level. > > > > > > > > > > On Tue, 2020-08-04 at 17:43 -0700, Lakshmi Ramasubramanian wrote: > > > > > > Critical data structures of security modules need to be measured to > > > > > > enable an attestation service to verify if the configuration and > > > > > > policies for the security modules have been setup correctly and > > > > > > that they haven't been tampered with at runtime. A new IMA policy is > > > > > > required for handling this measurement. > > > > > > > > > > > > Define two new IMA policy func namely LSM_STATE and LSM_POLICY to > > > > > > measure the state and the policy provided by the security modules. > > > > > > Update ima_match_rules() and ima_validate_rule() to check for > > > > > > the new func and ima_parse_rule() to handle the new func. > > > > > I can understand wanting to measure the in kernel LSM memory state to > > > > > make sure it hasn't changed, but policies are stored as files. Buffer > > > > > measurements should be limited to those things that are not files. > > > > > > > > > > Changing how data is passed to the kernel has been happening for a > > > > > while. For example, instead of passing the kernel module or kernel > > > > > image in a buffer, the new syscalls - finit_module, kexec_file_load - > > > > > pass an open file descriptor. Similarly, instead of loading the IMA > > > > > policy data, a pathname may be provided. > > > > > > > > > > Pre and post security hooks already exist for reading files. Instead > > > > > of adding IMA support for measuring the policy file data, update the > > > > > mechanism for loading the LSM policy. Then not only will you be able > > > > > to measure the policy, you'll also be able to require the policy be > > > > > signed. > > > > > > > > To clarify, the policy being measured by this patch series is a > > > > serialized representation of the in-memory policy data structures being > > > > enforced by SELinux. Not the file that was loaded. Hence, this > > > > measurement would detect tampering with the in-memory policy data > > > > structures after the policy has been loaded. In the case of SELinux, > > > > one can read this serialized representation via /sys/fs/selinux/policy. > > > > The result is not byte-for-byte identical to the policy file that was > > > > loaded but can be semantically compared via sediff and other tools to > > > > determine whether it is equivalent. > > > > > > Thank you for the clarification. Could the policy hash be included > > > with the other critical data? Does it really need to be measured > > > independently? > > > > They were split into two separate functions because we wanted to be > > able to support using different templates for them (ima-buf for the > > state variables so that the measurement includes the original buffer, > > which is small and relatively fixed-size, and ima-ng for the policy > > because it is large and we just want to capture the hash for later > > comparison against known-good). Also, the state variables are > > available for measurement always from early initialization, whereas > > the policy is only available for measurement once we have loaded an > > initial policy. > > Ok, measuring the policy separately from other critical data makes > sense. Instead of measuring the policy, which is large, measure the > policy hash. I think that was the original approach. However, I had concerns with adding code to SELinux to compute a hash over the policy versus leaving that to IMA's existing policy and mechanism. If that's preferred I guess we can do it that way but seems less flexible and duplicative.