Received: by 10.223.185.116 with SMTP id b49csp5518862wrg; Wed, 7 Mar 2018 13:13:24 -0800 (PST) X-Google-Smtp-Source: AG47ELtUo4cgpFQJqeqXOg3TwzEQWrH+omiHV8vTX9/QZVewZqryPL9PLSdDYrFsKEdiT89HUJ98 X-Received: by 2002:a17:902:225:: with SMTP id 34-v6mr21788869plc.415.1520457204809; Wed, 07 Mar 2018 13:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520457204; cv=none; d=google.com; s=arc-20160816; b=EOFlDTgsrTdnRKJtURJs7237s6CCPA/baejCuO7pgMdUWyva/u2cVEuBPcnyScPncC lN1DacOXZuOg2/6SCYDhRzkwmdoHnqS4Dv7JIsj9VUF6cWl5Emar+c9XX57WoTKZkCXG 56HcFUzkqq7xCjj24Y88AA6DZAElooXzggaOfSVVVBFp9clEweP5cznm2nurt75qUajp X4rF83X21mX+He/lU1cmGcSmng0zmZl/0GH2ju95q9JFf6/F7KOXpctbM5ZQnaXmKPog cccdW2xdcBpPFP4F0tZ+2pRgFTwvFxDulYFc7XslHeh/RM0QjVCtb9jbQLBxgceDL1x8 Av7g== 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:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=sxI+HLRRarG/hNndzlv8Zg+O2ljid8G5S8r+kY5R9bI=; b=mc8WnO05h56ulFH4jj5+3vsqvdYLhgFlFaazl6PmU40dN0yWPDqtEb0w9sLN/ng7Ev QXEfRmg9nyFvqvbMzfvMVaEqGC+jY/+xZszC9Rm9KySufsqQWtVrY9B4keww6tOOAtse aXo1z7ivv2RbQ3pWr/+96VOeiiP6qHYBuckTgM9RCkPOfIj+uQSE0M6gtc6bhv0drdpt tUwbxpYdmYuB+36xcydKLjvBuySuPxDrlPHDZ8MZxkwEMowQA+21UgwwHB/WBLTB4RP6 Hh/u7Q/tQ2f7oNYPllfeLnoqB+HUDIs7C8A9pzNQ0Zz1GhIiXEu1/0S+46J7lklTJbqp tOVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=owde0MSV; dkim=pass header.i=@codeaurora.org header.s=default header.b=J/yKlmPT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f30-v6si13625008plf.654.2018.03.07.13.13.10; Wed, 07 Mar 2018 13:13:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=owde0MSV; dkim=pass header.i=@codeaurora.org header.s=default header.b=J/yKlmPT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754839AbeCGVMO (ORCPT + 99 others); Wed, 7 Mar 2018 16:12:14 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:57004 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754052AbeCGVMK (ORCPT ); Wed, 7 Mar 2018 16:12:10 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7F5E06053B; Wed, 7 Mar 2018 21:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520457129; bh=IN6T/fDm0TR6+socB2slQhuqQtYhUPxUhp6a6/O99L0=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=owde0MSVNLq/ARtVZdRwA5/QmOulGxyP1A4aDL90AS1zO2aNEeH1UdcdYXDgDjORv PWFYReAeSzL35d+9D8LHXYKXXepRCVk20kyLSSyKuIulAl74BU5mVTiMuNP0h56hl0 fKNElhRafBsAyduoCJ0lmyvjGbMCc3T2chEtWpXo= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.222.143.176] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: anjiandi@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4611D60398; Wed, 7 Mar 2018 21:12:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520457128; bh=IN6T/fDm0TR6+socB2slQhuqQtYhUPxUhp6a6/O99L0=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=J/yKlmPTqxiYn627gCoBrhfgf1m/sVVlHxc3b7RtwOD22GOyIRtzZrOSNWvNeTmXy 30QRQUMgK3SMgmRq43Y0DzSNO0s0Mcm/xfr0Up4U4WUjYwru7FMED0T9+0N02fp1Ph L21xsOU4M6gZQTeBcj8IP8iyjmyCoxMFtIFcR/Og= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4611D60398 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=anjiandi@codeaurora.org Subject: Re: [PATCH] security: Fix IMA Kconfig for dependencies on ARM64 To: James Bottomley , Mimi Zohar , Jason Gunthorpe Cc: dmitry.kasatkin@gmail.com, jmorris@namei.org, serge@hallyn.com, linux-integrity@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org References: <1520400386-17674-1-git-send-email-anjiandi@codeaurora.org> <20180307185132.GA30102@ziepe.ca> <1520448953.10396.565.camel@linux.vnet.ibm.com> <1520449719.5558.28.camel@HansenPartnership.com> <1520450495.10396.587.camel@linux.vnet.ibm.com> <1520451662.24314.5.camel@HansenPartnership.com> From: Jiandi An Message-ID: Date: Wed, 7 Mar 2018 15:12:06 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1520451662.24314.5.camel@HansenPartnership.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/07/2018 01:41 PM, James Bottomley wrote: > On Wed, 2018-03-07 at 14:21 -0500, Mimi Zohar wrote: >> On Wed, 2018-03-07 at 11:08 -0800, James Bottomley wrote: >>> >>> On Wed, 2018-03-07 at 13:55 -0500, Mimi Zohar wrote: >>>> >>>> On Wed, 2018-03-07 at 11:51 -0700, Jason Gunthorpe wrote: >>>>> >>>>> >>>>> On Tue, Mar 06, 2018 at 11:26:26PM -0600, Jiandi An wrote: >>>>>> >>>>>> >>>>>> TPM_CRB driver is the TPM support for ARM64.  If it >>>>>> is built as module, TPM chip is registered after IMA >>>>>> init.  tpm_pcr_read() in IMA driver would fail and >>>>>> display the following message even though eventually >>>>>> there is TPM chip on the system: >>>>>> >>>>>> ima: No TPM chip found, activating TPM-bypass! (rc=-19) >>>>>> >>>>>> Fix IMA Kconfig to select TPM_CRB so TPM_CRB driver is >>>>>> built in kernel and initializes before IMA driver. >>>>>> >>>>>> Signed-off-by: Jiandi An >>>>>>  security/integrity/ima/Kconfig | 1 + >>>>>>  1 file changed, 1 insertion(+) >>>>>> >>>>>> diff --git a/security/integrity/ima/Kconfig >>>>>> b/security/integrity/ima/Kconfig >>>>>> index 35ef693..6a8f677 100644 >>>>>> +++ b/security/integrity/ima/Kconfig >>>>>> @@ -10,6 +10,7 @@ config IMA >>>>>>   select CRYPTO_HASH_INFO >>>>>>   select TCG_TPM if HAS_IOMEM && !UML >>>>>>   select TCG_TIS if TCG_TPM && X86 >>> >>> Well, this explains why IMA doesn't work on one of my X86 systems: >>> it's got a non i2c infineon TPM. >>> >>>> >>>>> >>>>>> >>>>>> + select TCG_CRB if TCG_TPM && ACPI >>>>>>   select TCG_IBMVTPM if TCG_TPM && PPC_PSERIES >>>>>>   help >>>>>>     The Trusted Computing Group(TCG) runtime Integrity >>>>> >>>>> This seems really weird, why are any specific TPM drivers >>>>> linked to IMA config, we have lots of drivers.. >>>>> >>>>> I don't think I've ever seen this pattern in Kconfig before? >>>> >>>> As you've seen by the current discussions, the TPM driver needs >>>> to be initialized prior to IMA.  Otherwise IMA goes into TPM- >>>> bypass mode.  That implies that the TPM must be builtin to the >>>> kernel, and not as a kernel module. >>> >>> Actually, that's not necessarily true:  If we don't begin appraisal >>> until after the initrd phase, then the initrd can load TPM modules >>> before IMA starts. >>> >>> This would involve a bit of code rejigging to not require a TPM >>> until IMA wants to write its first measurement, but it looks doable >>> and would get us out of having to second guess TPM selections. >> >> The question is about measurement, not appraisal.  Although the >> initramfs might be measured, the initramfs can access files on the >> real root filesystem.  Those files need to be measured, before they >> are used/accessed. > > Isn't it a question of threat model?  Because the initrd is measured, > you know it's the one you specified and you should know its security > properties, so measurement doesn't really need to begin until the root > pivots.  At that point you pick up the boot aggregate so the log now is > tied to the initrd measurement.  Conversely, I can't really see a > threat model where you could trick a correctly measured initrd into > subverting IMA, especially because listening network daemons aren't > usually active at this stage. > > I'm not saying there isn't a use case for wanting your TPM built in, > I'm just saying I don't think it needs to be required for everyone who > uses IMA. > > James > ima_init() first calls tpm_pcr_read() which tries to use underlying registered TPM chip driver and send read PCR TPM command to the TPM chip. If IMA driver is enabled and ima_init() happens, we see this. In security/integrity/ima/ima_main.c, init_ima() is in late_initcall. And it calls ima_init(). late_initcall(init_ima); /* Start IMA after the TPM is available */ So as long as init_ima() is called, need to at least enable the TPM driver for the platform right? I'm just following current IMA Kconfig where it's selecting different underlying TPM chip drivers for various platforms respectively when CONFIG_IMA is set to Y because IMA driver init calls tpm_pcr_read() which needs to use TPM. -- Jiandi An Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.