From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46FA5C433E1 for ; Mon, 20 Jul 2020 18:59:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AAE722BF5 for ; Mon, 20 Jul 2020 18:59:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="CsOM1OTA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729024AbgGTS7x (ORCPT ); Mon, 20 Jul 2020 14:59:53 -0400 Received: from linux.microsoft.com ([13.77.154.182]:48720 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728139AbgGTS7x (ORCPT ); Mon, 20 Jul 2020 14:59:53 -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 3F13620B4909; Mon, 20 Jul 2020 11:59:52 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3F13620B4909 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1595271592; bh=TwTCyPsy3rMqXVnjk9ggTK+QxuipwRRnBBIqMLIAfHU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=CsOM1OTASiRenjavduL6Z/OSbM8MSJRuka+oE3SfwFiUtblFWSKQjh5MKwzLlONqQ L9RuvB8oP0n36cCAFMasvJSqJEWnB0peLm1olX3WYO0JyVLF/C+tGQC7wVF/rAxplY +dcGkrf8Uf0UBYjE2diJjx3YEiuc6RRJ0IglDe3Q= 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: <72af0630-dce0-12af-0977-b4e81c2f99ac@linux.microsoft.com> Date: Mon, 20 Jul 2020 11:59:51 -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-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org On 7/20/20 11:44 AM, Stephen Smalley wrote: >>> >>> Actually, if we used ima-ng template for selinux-policy-hash, then >>> instead of needing to hash the policy >>> first and passing the hash to IMA, we could just pass the policy as >>> the buffer and IMA would take care of the hashing, right? >> >> That is correct. >> >> The IMA hook I've added to measure LSM structures is a generic one that >> can be used by any security module (SM). I feel it would be better to >> not have policy or state or any such SM specific logic in IMA, but leave >> that to the individual SM to handle. >> >> What do you think? > > It is correct to remain security module agnostic. However, I think > you can remain LSM-neutral while still avoiding the double hashing of > the policy here. Can't you just pass in the policy itself as the > buffer and let IMA hash it? Yes - that is an option. If I do that then, as you have stated below, we'll need to two funcs - one that will only add the hash but not the entire data payload in the IMA log (i.e., "ima-ng") and, the other that handles hashing and including date payload (i.e., "ima-buf"). Then you can let the policy author decide > on the template to be used (ima-buf versus ima-ng). If you want to > support the use of different templates for different "kinds" of LSM > state (e.g. state versus policy) you could either provide two funcs > (LSM_STATE, LSM_POLICY) or otherwise support selection based on some > other attribute. > I can do the above. -lakshmi