Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2599893ybg; Thu, 24 Oct 2019 12:10:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMyrSWtGqncWaLh5CAXY5cXFw1v/IoY49s56XkvQXRg4XyB8t/sr5/52MwVWMCzkMUeJmI X-Received: by 2002:a17:906:70c7:: with SMTP id g7mr40179596ejk.9.1571944244571; Thu, 24 Oct 2019 12:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571944244; cv=none; d=google.com; s=arc-20160816; b=BcKpABce2zXP5LfyMnt+tCBFWXjFSGqoBIPn6F+7n6bI/5BvMwCIlUHRQjSg1crfMg eiEZpDCmipKF6nJ4fnBobPwNhLNYgvKh9+dqySNI41XAGMoGW5EZzcbzINQtbiFdO3Ry 7v+1yXEa2SIraWl6V6UzVnvu3QtHPVu99J5NSapuKg7GTyFq8bN3en2c2sKjMjO/MhC4 2rMWSw4p6DGi8xoI2DQn6c9ubH+qzYpaFaK0pz1k0L3iza0qXV1NJakdsuFEodmXINIt zZoc9uGjzR+lu8BDVQZb0g2OJrV2wMOOVjwdw2jw1/nU8FDX3dsF9RUQc6TRdaYVL77H L+1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=BYsCn2TqzBNP2+cvEQ9FEJWHAD/aEGLUYMgklg1I8AM=; b=nSu19aePLGOEAAcz5bv0Scwryot7U62QY/+G9GdfJABGnh5wrkEbYFU+iDcCezy+ln IwjvPf2Dv3vnHkF63jqO9rIQcwly2GzlLNTesSAJU2iPQez3EX2dg196Py9RK8TNoqYw NqVJQGKy6BN+mKfdT/ls0IWD4SayJ9HnocgBUbCGTnSWPxXE2/6LHR+LT/o9KThQGTLA rh7cJFqiGelv3TXcT4Vh6Kq0PCm3oqHJm/te08DS7zwpvH6EPcF4sZlNPGwEJz4Mn439 tUPA2+ni6j42hX6og1m3eN7wn8bL1ykRU1eDgSCa4vI3pDWA5PpfCPiyd0+A77ew2FxM qeIA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s58si11693166edm.45.2019.10.24.12.10.20; Thu, 24 Oct 2019 12:10:44 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437366AbfJXDr4 (ORCPT + 99 others); Wed, 23 Oct 2019 23:47:56 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:26800 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437359AbfJXDrz (ORCPT ); Wed, 23 Oct 2019 23:47:55 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x9O3l4Il116737 for ; Wed, 23 Oct 2019 23:47:54 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vt3kjgpwb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 23 Oct 2019 23:47:54 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 24 Oct 2019 04:47:52 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 24 Oct 2019 04:47:46 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9O3lipj54591500 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 03:47:44 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9F1F2AE045; Thu, 24 Oct 2019 03:47:44 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D42F8AE051; Thu, 24 Oct 2019 03:47:41 +0000 (GMT) Received: from localhost.localdomain (unknown [9.40.192.65]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 24 Oct 2019 03:47:41 +0000 (GMT) From: Nayna Jain To: linuxppc-dev@ozlabs.org, linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Ard Biesheuvel , Jeremy Kerr , Matthew Garret , Mimi Zohar , Greg Kroah-Hartman , Claudio Carvalho , George Wilson , Elaine Palmer , Eric Ricther , "Oliver O'Halloran" , Nayna Jain , Prakhar Srivastava , Lakshmi Ramasubramanian Subject: [PATCH v9 3/8] powerpc: detect the trusted boot state of the system Date: Wed, 23 Oct 2019 22:47:12 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024034717.70552-1-nayna@linux.ibm.com> References: <20191024034717.70552-1-nayna@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19102403-0016-0000-0000-000002BC7C2F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19102403-0017-0000-0000-0000331DBEC2 Message-Id: <20191024034717.70552-4-nayna@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-24_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=639 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240033 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While secure boot permits only properly verified signed kernels to be booted, trusted boot calculates the file hash of the kernel image and stores the measurement prior to boot, that can be subsequently compared against good known values via attestation services. This patch reads the trusted boot state of a PowerNV system. The state is used to conditionally enable additional measurement rules in the IMA arch-specific policies. Signed-off-by: Nayna Jain --- arch/powerpc/include/asm/secure_boot.h | 6 ++++++ arch/powerpc/kernel/secure_boot.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/arch/powerpc/include/asm/secure_boot.h b/arch/powerpc/include/asm/secure_boot.h index 07d0fe0ca81f..a2ff556916c6 100644 --- a/arch/powerpc/include/asm/secure_boot.h +++ b/arch/powerpc/include/asm/secure_boot.h @@ -11,6 +11,7 @@ #ifdef CONFIG_PPC_SECURE_BOOT bool is_ppc_secureboot_enabled(void); +bool is_ppc_trustedboot_enabled(void); #else @@ -19,5 +20,10 @@ static inline bool is_ppc_secureboot_enabled(void) return false; } +static inline bool is_ppc_trustedboot_enabled(void) +{ + return false; +} + #endif #endif diff --git a/arch/powerpc/kernel/secure_boot.c b/arch/powerpc/kernel/secure_boot.c index 63dc82c50862..a6a5f17ede03 100644 --- a/arch/powerpc/kernel/secure_boot.c +++ b/arch/powerpc/kernel/secure_boot.c @@ -7,6 +7,17 @@ #include #include +static struct device_node *get_ppc_fw_sb_node(void) +{ + static const struct of_device_id ids[] = { + { .compatible = "ibm,secureboot-v1", }, + { .compatible = "ibm,secureboot-v2", }, + {}, + }; + + return of_find_matching_node(NULL, ids); +} + bool is_ppc_secureboot_enabled(void) { struct device_node *node; @@ -30,3 +41,18 @@ bool is_ppc_secureboot_enabled(void) pr_info("Secure boot mode %s\n", enabled ? "enabled" : "disabled"); return enabled; } + +bool is_ppc_trustedboot_enabled(void) +{ + struct device_node *node; + bool enabled = false; + + node = get_ppc_fw_sb_node(); + enabled = of_property_read_bool(node, "trusted-enabled"); + + of_node_put(node); + + pr_info("Trusted boot mode %s\n", enabled ? "enabled" : "disabled"); + + return enabled; +} -- 2.20.1