From patchwork Fri Sep 4 07:29:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 254238 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, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 5F527C43461 for ; Fri, 4 Sep 2020 07:30:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D55F206D4 for ; Fri, 4 Sep 2020 07:30:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Up0PJggF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728507AbgIDHae (ORCPT ); Fri, 4 Sep 2020 03:30:34 -0400 Received: from de-smtp-delivery-102.mimecast.com ([51.163.158.102]:35589 "EHLO de-smtp-delivery-102.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729765AbgIDH3r (ORCPT ); Fri, 4 Sep 2020 03:29:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1599204584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KMwzl/DFU5QVU1c3TC0j+2xuvQVhQLCy2L6n4az4kc0=; b=Up0PJggF+/lJ8xyt4GyuCI1eYnJN2R5jnnOJGFKUsd+oha8vKuK7HNf/Nnlj0vr4+UrCKR 4OcBMh7cLnXNbpVh/2oPyIKNCgPZi2aV9U848cbzud4z8zFWz4SIXzHD/sEmy4kT11aJxX c24e/WVRzW/9sIePP2ZxIMpNJTSFLP8= Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2052.outbound.protection.outlook.com [104.47.14.52]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-19-3omLnChZP3C5OR4cARrjwA-1; Fri, 04 Sep 2020 09:29:42 +0200 X-MC-Unique: 3omLnChZP3C5OR4cARrjwA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QA0cLtl6rainHpGlWqUlypt8FBdwQZbRGZeNr7Aeqb5+5xYTv25cFl4Mj6T5WLEbx+rhz9MYAvO+IZsj4kjx3pbnAcClIrMZfCKiUQ6SjvbDQGclDqbS+C4YUz4NizL353VSX7ZbVapkLLdhf+vTJp2cgA30CbQ4vY4Rf2Psnh/WDBYYE+u3Y5tEZbXUuAvVyZ5Gica0mnsFrue1ETe13p5NeyUVvHItu4zPwKqlJMk2J1pD1IMJlP2KSgEtwreoGcz+IXtiRPAfVQkw3IRHiBIPgUUTFS6xyPw1xiPNLJHdFkP9fEwAL4Eb7yUCv/00/hGNq+tVcjXhYq1yj+jElg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YEYlWLpOl/XRQn0kyzMOn7W6PG7RxQna7dkoagYegxc=; b=noRUmguEfZ25ALH8opU8r/Dt7wRrr4Ty0ZozpmUifKQ6jJSundZpabIE+LDEeDVI//tRY1bw3J7LPwqTdflRnwTjSrvS+huMlOtmZQWf7ieouk5tUs9mtx8NwiyQfipjwJE2reuq3bazgcDcfqaosGztYDU0OB/OVbxTLudhZVYnWlPanmOxIumIQ+/RDWxC0PJYt9NqP5Y3dPL17IRFiMWnWTl9bz7PMLD1evTfB99k0U83K5CECN2n8Cje+tx8z0TLYXDV3PhZI+9bQIunQDwl7CIckzgEsLYUBRowJlQDwADBcH0g8mn7sfmLXIPq81w05rmkyn5iIPDoMlGsHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=suse.com; Received: from VI1PR04MB4928.eurprd04.prod.outlook.com (2603:10a6:803:57::13) by VI1PR04MB5534.eurprd04.prod.outlook.com (2603:10a6:803:d2::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.16; Fri, 4 Sep 2020 07:29:41 +0000 Received: from VI1PR04MB4928.eurprd04.prod.outlook.com ([fe80::859b:fe60:4cfd:efa3]) by VI1PR04MB4928.eurprd04.prod.outlook.com ([fe80::859b:fe60:4cfd:efa3%2]) with mapi id 15.20.3348.016; Fri, 4 Sep 2020 07:29:41 +0000 From: Chester Lin To: ardb@kernel.org, catalin.marinas@arm.com, will@kernel.org, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, corbet@lwn.net, mark.rutland@arm.com, vincenzo.frascino@arm.com, samitolvanen@google.com, masahiroy@kernel.org, mingo@kernel.org CC: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, jlee@suse.com, clin@suse.com Subject: [PATCH 1/6] efistub: pass uefi secureboot flag via fdt params Date: Fri, 4 Sep 2020 15:29:00 +0800 Message-ID: <20200904072905.25332-2-clin@suse.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200904072905.25332-1-clin@suse.com> References: <20200904072905.25332-1-clin@suse.com> X-ClientProxiedBy: AM0PR02CA0073.eurprd02.prod.outlook.com (2603:10a6:208:154::14) To VI1PR04MB4928.eurprd04.prod.outlook.com (2603:10a6:803:57::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-8mug.suse.de (114.24.10.103) by AM0PR02CA0073.eurprd02.prod.outlook.com (2603:10a6:208:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.15 via Frontend Transport; Fri, 4 Sep 2020 07:29:36 +0000 X-Mailer: git-send-email 2.26.1 X-Originating-IP: [114.24.10.103] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 56b8656e-1d6f-4dd3-2aca-08d850a44995 X-MS-TrafficTypeDiagnostic: VI1PR04MB5534: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /XXOKfKx8lqrr12MHzSzqLfCXrTwnXAclEcd5/3Rs4AN9GIayomQ89+wjxha8IIucM9LO36JUfcM3mwo/Wj20K0dRrittiAEpBCYmFcY1ZNRdnJdchyxN6GF3nPCToXjN/iit0b6KmObeyciWR6Bsggu3LZShdSjbdNqvPxX91FBAnQxtk4VLuQr7ozuEP1Ilfb/QVRINHi7mPE/RX6bnLh+zf7/OD5AhcU7nCkOPUwfBE1vGMh/5yaerY9Uj9wVfsB+XFs3dMq+Jy0eKibMKmlSGa9Zuto7Azt0suySCXegJWXZYG3hykfhxnP4Xxn07LJSZloSDykL5CEccidOAQdbjJwiOQuohSBXejSDNBo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4928.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(376002)(136003)(39860400002)(366004)(396003)(5660300002)(2906002)(956004)(316002)(66476007)(66946007)(107886003)(66556008)(6506007)(36756003)(8676002)(16526019)(52116002)(186003)(7416002)(83380400001)(6512007)(1076003)(4326008)(8936002)(26005)(2616005)(478600001)(6666004)(86362001)(6486002)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: NABScR6D6u20RkZ6fnWEh2qfvIS6BGuc+qhgX4q2sajgvTIaGRatvDlxmCMZ3z4kUZCcvKK8xdgVh0JMezdFQh/VUi7CM1kRWIlv6CmipTR7HyLldhoViRtEjM+9JzrHO8pnI3OCKb49ABEw0OMtyw0elrogYu8aNb2Lg0gbbbHV7LF096qu2g0LNZkOYnXc9CENsII5XF7ZqU5UFjb9bbVeG8pOby99ebGaOMdwj8VJ3SXO/CH5PIrP/075+bBhOYesU/fwagm9FaYmPx0uLyDLF3I+eLJm2sr1liscWHzN1T8UZ1beZdk3DcVjojN/7uANoo4A+3CHMcxyOrS6hjuYOyLzWbBZXAM4EiKaP/EL2sd8g5YVYaNtkzEYdVhvn0jKhY/hvvBCsyeZHCTEc3MQ8mlSwVoQKHjcD5OXkVou+XbO4jQ4rzo2K8nKtP4tq2U7O7pJCGJ1y7JRAEdXdcx2kTnbOsiYUckyQhTsPfjT8XDHyf3SIefF4KSkCxseZmmVaeDS35h3NHRV5bsz2CyTJGy3ztktWjG+vrzXULRN0QjwtWNbf35tmtvBlUVVJwP0jRPxSCqcXzc77HT6VIzyhC+JQG/VVhVMak5t9jCOODNCWMpAzq2UjlPAr8Td/nYxhAEA4DGr2klgaqezfg== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56b8656e-1d6f-4dd3-2aca-08d850a44995 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4928.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2020 07:29:41.5804 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +APCQ5UJnImSaveX4hl/DnXuN7DzM65Kjw+H8p2+BE+1B8f3j+pnROJIxGPSkBTq X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5534 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add a new UEFI parameter: "linux,uefi-secure-boot" in fdt boot params as other architectures have done in their own boot data. For example, the boot_params->secure_boot in x86. Signed-off-by: Chester Lin --- drivers/firmware/efi/libstub/fdt.c | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index 11ecf3c4640e..c9a341e4715f 100644 --- a/drivers/firmware/efi/libstub/fdt.c +++ b/drivers/firmware/efi/libstub/fdt.c @@ -136,6 +136,10 @@ static efi_status_t update_fdt(void *orig_fdt, unsigned long orig_fdt_size, if (status) goto fdt_set_fail; + status = fdt_setprop_var(fdt, node, "linux,uefi-secure-boot", fdt_val32); + if (status) + goto fdt_set_fail; + if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) { efi_status_t efi_status; @@ -199,6 +203,24 @@ static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map) return EFI_SUCCESS; } +static efi_status_t update_fdt_secboot(void *fdt, u32 secboot) +{ + int node = fdt_path_offset(fdt, "/chosen"); + u32 fdt_val32; + int err; + + if (node < 0) + return EFI_LOAD_ERROR; + + fdt_val32 = cpu_to_fdt32(secboot); + + err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-secure-boot", fdt_val32); + if (err) + return EFI_LOAD_ERROR; + + return EFI_SUCCESS; +} + struct exit_boot_struct { efi_memory_desc_t *runtime_map; int *runtime_entry_count; @@ -208,6 +230,9 @@ struct exit_boot_struct { static efi_status_t exit_boot_func(struct efi_boot_memmap *map, void *priv) { + efi_status_t status; + enum efi_secureboot_mode secboot_status; + u32 secboot_var = 0; struct exit_boot_struct *p = priv; /* * Update the memory map with virtual addresses. The function will also @@ -217,7 +242,19 @@ static efi_status_t exit_boot_func(struct efi_boot_memmap *map, efi_get_virtmap(*map->map, *map->map_size, *map->desc_size, p->runtime_map, p->runtime_entry_count); - return update_fdt_memmap(p->new_fdt_addr, map); + status = update_fdt_memmap(p->new_fdt_addr, map); + + if (status != EFI_SUCCESS) + return status; + + secboot_status = efi_get_secureboot(); + + if (secboot_status == efi_secureboot_mode_enabled) + secboot_var = 1; + + status = update_fdt_secboot(p->new_fdt_addr, secboot_var); + + return status; } #ifndef MAX_FDT_SIZE From patchwork Fri Sep 4 07:29:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 254240 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, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 A2CD9C433E2 for ; Fri, 4 Sep 2020 07:30:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7401C2084D for ; Fri, 4 Sep 2020 07:30:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="gYItN4li" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729822AbgIDHaL (ORCPT ); Fri, 4 Sep 2020 03:30:11 -0400 Received: from de-smtp-delivery-102.mimecast.com ([62.140.7.102]:37695 "EHLO de-smtp-delivery-102.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729829AbgIDHaI (ORCPT ); Fri, 4 Sep 2020 03:30:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1599204605; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U329ikPO3HVYNh1OH0VUnhnpXFcIAjmLqB0KgFWrbVM=; b=gYItN4lifFjvZY7jKiPxXV+8v+FxRYC2g5YbV8O8dbuoU6o3jKRSeEB8rPDl9bIdnN4idA kjat5/qekiUODf6UHcIN9OsfYkv9R8zzM4RAxTdeuXcLLIPRh3UWDnpjqtibB2FfdR6GKa Rlxq3+QtT5FhPoWHHx4vm4z/+XIScd0= Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2052.outbound.protection.outlook.com [104.47.14.52]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-6-rXl1I6ZQP6iD4UgB4mRV7g-1; Fri, 04 Sep 2020 09:30:04 +0200 X-MC-Unique: rXl1I6ZQP6iD4UgB4mRV7g-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=buwks09S+RJRGpidWTLWJfkI9Vhu+yebJmGKQ1VTNnddQsaxkKD9QRBKx77kjILvatvRu7l0XLrLbp1jXoIPB+STuHatCob+ERhV98cDQhgbaao9I7Q1rRSI54DsOtctOOEG6Ap/dOs/q71tGXfoKupbsh9EXrmvXPuDeFOIvK33d19EZBJH/jDWO0brVyWl87qIwtiuQzixfEtrm3tQHaXwKEY8crdw6znsQZIE1H2dPMyP9ENxVHOD2DPnMDj9DJbAYzirty+KEatMCBy2FMetenEc4l5fT+cVD6hBGizwa8yDWmZxppbnYYi+FX8CdaB++airQl4ppZb5BrsSJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5wT8B5U05PQmYomhfbWDQFbQz27bz9PR6cv3cjhQuNA=; b=FT/j3Cbf/CAYTIVF22W5y9B3NgMrh0maUgmGI6Y2x8DNpK4zibmMHETma26VxxIBNORNqZozgr2DpK/6R1yEZFtcIjFiHOvgnfxAqaLpcl1HRWcsPMdWASp/f4599pCZphBDry6VQW60EdJxCrnx12U7ZpWT5adwCUWb+nlOh4gFturso2WbJKp4jzINLS/k+9Q5Y/aEyK56imL+25T521q6MwK6vIzVEWnp6SuGx8Fq7qGLwL2x8tc7Wh+oq+cAtw98HsSL/Dbk1R+cjAA1QMCa6dLykERwMFijvZgeBY7OuaCumMBaJiUX5bN+xdDRT+V72fCjBVnVgMZLtfMzhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=suse.com; Received: from VI1PR04MB4928.eurprd04.prod.outlook.com (2603:10a6:803:57::13) by VI1PR04MB5534.eurprd04.prod.outlook.com (2603:10a6:803:d2::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.16; Fri, 4 Sep 2020 07:30:03 +0000 Received: from VI1PR04MB4928.eurprd04.prod.outlook.com ([fe80::859b:fe60:4cfd:efa3]) by VI1PR04MB4928.eurprd04.prod.outlook.com ([fe80::859b:fe60:4cfd:efa3%2]) with mapi id 15.20.3348.016; Fri, 4 Sep 2020 07:30:03 +0000 From: Chester Lin To: ardb@kernel.org, catalin.marinas@arm.com, will@kernel.org, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, corbet@lwn.net, mark.rutland@arm.com, vincenzo.frascino@arm.com, samitolvanen@google.com, masahiroy@kernel.org, mingo@kernel.org CC: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, jlee@suse.com, clin@suse.com Subject: [PATCH 4/6] efi/arm: check secure boot status in efi init Date: Fri, 4 Sep 2020 15:29:03 +0800 Message-ID: <20200904072905.25332-5-clin@suse.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200904072905.25332-1-clin@suse.com> References: <20200904072905.25332-1-clin@suse.com> X-ClientProxiedBy: AM0PR02CA0073.eurprd02.prod.outlook.com (2603:10a6:208:154::14) To VI1PR04MB4928.eurprd04.prod.outlook.com (2603:10a6:803:57::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-8mug.suse.de (114.24.10.103) by AM0PR02CA0073.eurprd02.prod.outlook.com (2603:10a6:208:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.15 via Frontend Transport; Fri, 4 Sep 2020 07:29:58 +0000 X-Mailer: git-send-email 2.26.1 X-Originating-IP: [114.24.10.103] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b99f771-6d57-4fec-9e12-08d850a45663 X-MS-TrafficTypeDiagnostic: VI1PR04MB5534: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1201; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EVATG4yCjeJcgAFn/ZoDfLKnGYNxdzBe7n8FSrS4zJilk/mzHd3DPb+DsS3W6N8lF3oI9lHsH2IXiZhptwunjkfUZTkBrml1xmQdUJG58D8Fp9ByKGSUXHd/h2p+QbKM2W64jxuzJFzeiDSmNY21CMlmOY36DHv8Qz3LvsX8nPjMEwqykVj5HoUhG9gNe7YphNWpeB1LtPVs5y7UJGZlKBR9j40dmt87K8Q/WJ9Hw27QURVI8bFXYMvEgYCK2LriskIxiXL+FtByhCskGk8xPls7SiVse5M9WSohgPvbv5mDk7xtdxRxfF+Ugswb2sEojae1aHtPc9yk2/3WMnm8FYJKgIdgLWle8q77U8pjuzu4pQEFSi98VQh6VKldhq8r X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4928.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(376002)(136003)(39860400002)(366004)(396003)(5660300002)(2906002)(4744005)(956004)(316002)(66476007)(66946007)(107886003)(66556008)(6506007)(36756003)(8676002)(16526019)(52116002)(186003)(7416002)(6512007)(1076003)(4326008)(8936002)(26005)(2616005)(478600001)(6666004)(86362001)(6486002)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: SRM5UVWkxeo/MsiH3xiKSqZROhxPe8eIctHNC26ORetHvDb9dXdM9cMi5zWK8R9cu/mMoXCRfW/9fFvJMG+ZI4g6oX4RdNIugv7PsDl+UlAE0b1kr6GiRSjAd+ckrt1i+xQ51zc9ndDtvS/X8KIJdzDvSNsnP45osD9ZgtMa04/KEsvxnNW2DugMlo1FtlmqgUEh9S3UVVq7h9rR1wZDJai6STcHwzWB/Xbp9IaPoM+Gbhe6H0+0UB6Vm9rXJI4j7QMOlLU5LYLX4DmT88wtwxDIilgQrmwJiR2c5TjTillprAnM69gAYLiRmLxmAFfjxON8UKMMJp0qUmoLt6i0gPR4u3/GCMv9WORoserqJ3qwj4YvgluP09k1DDjo+sILhfxDked1xKP7LE2XPz5QVrmcpaFJWxiwulHg5RWXtjg7hCnW3yQR5YjnfF1y3uK2L0HXyFkwE20W19OKl68p86Z1kudmZC3EY5xLQbML3vsSP39RVTCZooiHojIBc4TnL6RWYAhT/9jlqkCNFDtOvHcSyC4HT9ZGkOAqGtV1DJeMmy8CM1ABCjjfkh+Tulqf2w6xHuDWxHfKT3oJPBp+4OtpSbXYhugAnAc7BehBmmljN4GO76KHi7QPx13XgY6jzqZmSQm1vtdX6uTCapFFdA== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b99f771-6d57-4fec-9e12-08d850a45663 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4928.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2020 07:30:03.0850 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YInKUozO/YFr/G3ehpfrC3x8zVMRm/Fpx+TrBsDxfRoQHptZUI2oTz6Kqmq4Q4lu X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5534 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org set EFI_SECURE_BOOT flag when UEFI secure boot is eanbled on ARM. Signed-off-by: Chester Lin --- drivers/firmware/efi/arm-init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c index 71c445d20258..70f2eaf5fb1a 100644 --- a/drivers/firmware/efi/arm-init.c +++ b/drivers/firmware/efi/arm-init.c @@ -234,6 +234,9 @@ void __init efi_init(void) return; } + if (efi_secureboot_enabled_in_fdt()) + set_bit(EFI_SECURE_BOOT, &efi.flags); + reserve_regions(); efi_esrt_init(); From patchwork Fri Sep 4 07:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chester Lin X-Patchwork-Id: 254239 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, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 30F63C2D0E0 for ; Fri, 4 Sep 2020 07:30:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F127B20BED for ; Fri, 4 Sep 2020 07:30:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="DNQJlbFW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729850AbgIDHaS (ORCPT ); Fri, 4 Sep 2020 03:30:18 -0400 Received: from de-smtp-delivery-102.mimecast.com ([51.163.158.102]:42440 "EHLO de-smtp-delivery-102.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729847AbgIDHaP (ORCPT ); Fri, 4 Sep 2020 03:30:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1599204612; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VzgVshd56Vq9MQ/cQ9RvLUiZRyIZb0RWZt9G+3aDwbY=; b=DNQJlbFW96kQ0SH7rQKIwpRO0LfWC7K+7V8oLFA1RxjPU5YF/z/qjuMjWn3GDDIwHcZGOj KfTRbhH0L6jd8Z7Vo0VkQTUbcokctnT6WszuLyLgrGxGYWTfC6HWDniCSk1Wc5FecwDO/S j/pJNGZrERTGP7KiHJO1utOefIxeKdg= Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2055.outbound.protection.outlook.com [104.47.14.55]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-11-GUOXjaPKPk6kprPcsGICTA-1; Fri, 04 Sep 2020 09:30:10 +0200 X-MC-Unique: GUOXjaPKPk6kprPcsGICTA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LRMhXDbLv9ZY4OpZTMIxl2m6nQXJeOKfm5Sr90OKpj1PPBVjAXt92VTkZdrQJHolqM4ldRptOgI3VUFkQtvjQrXBpmJlGtPUVXLd72jYqlnVMfH2sVaUNHz14crCEUVWmhaOgbMUZ1En7TPogebrHHJA0+9KKAKkzMQorOAFSRupQRGGjcBoLWsvLvN4Sl+VuVklSCUPNlrtwDP5YvuaZbyZOu45V50vxGmkCwPVTowYuFG0C0vPM43/HhbKfl3LhXO0g/uCiF6YwGJW9ukjrfEV6lZUkuEFpMNMp1AJeCYKT//inh+XsqLECs0jDDkcIw4YOsVnwEo9BagE2/1TVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l8AYOZUop5MQL12KNroK6RfIHwwOgtVLCQe+Fc9DQeI=; b=G8iHAFHPRdaJwxiHNaXpyvXbDLCDKTmZ6nPT0tCFY1m1jBNctWmUWqb0htYf8o731/F8SYbziFtjmVNVzmo0z6xDa8ASH3Fh+jkwnMxqIZj//QNZTRNvwDubUBvlxbyV2hu5WXtEHnMPSf0UUaqC5PJnjoV75KgAB7X02fFmNZDwLZXE1SRAMjcvB0by/g9I9x1P73BJ7vVePZk9/XnUJ1X4vMbG8YnYsj2Z+RHpVM1p4hrv4TXVOErD5IDAHEQ1q9XZ1mBLHmWoK9t8bglMqNddMHOezISkL37tqCk09cL/v8Wig6iep9aR8kVe88oGDY+U7dMd4efd7DGLWNgMDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=suse.com; Received: from VI1PR04MB4928.eurprd04.prod.outlook.com (2603:10a6:803:57::13) by VI1PR04MB5534.eurprd04.prod.outlook.com (2603:10a6:803:d2::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.16; Fri, 4 Sep 2020 07:30:09 +0000 Received: from VI1PR04MB4928.eurprd04.prod.outlook.com ([fe80::859b:fe60:4cfd:efa3]) by VI1PR04MB4928.eurprd04.prod.outlook.com ([fe80::859b:fe60:4cfd:efa3%2]) with mapi id 15.20.3348.016; Fri, 4 Sep 2020 07:30:09 +0000 From: Chester Lin To: ardb@kernel.org, catalin.marinas@arm.com, will@kernel.org, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, corbet@lwn.net, mark.rutland@arm.com, vincenzo.frascino@arm.com, samitolvanen@google.com, masahiroy@kernel.org, mingo@kernel.org CC: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, jlee@suse.com, clin@suse.com Subject: [PATCH 5/6] arm64/ima: add ima arch support Date: Fri, 4 Sep 2020 15:29:04 +0800 Message-ID: <20200904072905.25332-6-clin@suse.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200904072905.25332-1-clin@suse.com> References: <20200904072905.25332-1-clin@suse.com> X-ClientProxiedBy: AM0PR02CA0073.eurprd02.prod.outlook.com (2603:10a6:208:154::14) To VI1PR04MB4928.eurprd04.prod.outlook.com (2603:10a6:803:57::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-8mug.suse.de (114.24.10.103) by AM0PR02CA0073.eurprd02.prod.outlook.com (2603:10a6:208:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.15 via Frontend Transport; Fri, 4 Sep 2020 07:30:04 +0000 X-Mailer: git-send-email 2.26.1 X-Originating-IP: [114.24.10.103] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69bebcd5-1a96-4b6f-2587-08d850a45a2c X-MS-TrafficTypeDiagnostic: VI1PR04MB5534: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:126; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Epvmhi0mwlKkv2bBmuGUaGZXWUSvGhqypI+XgGdkn2jVOskWba3UPG9Gt3xiBdjcP2E6LlyHazCm6paHeoEmfGBTBz7q0K+2Kama66KtTOe6djeXoA3zAeIAr/tqizl+6GgiIEIBJQBZLDUOmQ2f7+XswHt6eKNzqo2X8HHg+kjfSb9lWAs7oV3eONy2NXYKPGNwdvuEKwLIxkaWcofMkEI7VLSeN2lAn2d3wlUEmXkKPTrHT62HVE7oU9ShMV5YrSQ+PcAG4iF3iyExEl9otx8dmlrLvVif2WGWdApqkKZiiqyowFe3JdJ7jHtvIFcHoyeG1H4BraENZ7k30ToBU46ilKcZtSZdgccWwJXWEEeWx77bEpKh25+6U+5tY67S X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4928.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(376002)(136003)(39860400002)(366004)(396003)(5660300002)(2906002)(956004)(316002)(66476007)(66946007)(107886003)(66556008)(6506007)(36756003)(8676002)(16526019)(52116002)(186003)(7416002)(6512007)(1076003)(4326008)(8936002)(26005)(2616005)(478600001)(86362001)(6486002)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ZpAGHIATZJl3EHPUm9WTJW7es1zsgM+hYaziCzd99ffFoJt2Pdoh1UsxEE+b7Ec04b9gCnXSMVxcXIiuw7rifWWlij4glaBJ1NNqb8NOUaSJSb0uj0RsTRe3z6z8UWjA0A6uceW8RlDI9iTxwwcBiv7dhVQReF7elMiTctobpIjPMVx7QAVDtk/CESp9yWpEpbWfuulpiDlkXg9vSR4PJc7rbRjHJV2Qv5SV/yT+f7XxY+KjFYwksZLFjj0RfkdaGvtVYYFXcyrjg71zoX+Ciayly9SkFpABRm0I/PD3FvF+Pm1W7E7g+OaPBFjKBJDIgpCHUncyvmxWITy5/C/sFhQGJDB4A5olUQPzcKihKySIWehDttmYTy+I7Gp3rl6HvXW8vrRcdxMzLzXboa5L91Yw6RglZi4pi15M2mLiqlzAyv+ZPn4Iyrxx9MhDtDHq8PfeNu+sFYMk5vAaP6oL6CbEXn64plsAWSauLSVC8qu7XkTh8PrsGq/zDzdiUzsI1s0OyhKmCpMzd6ZuH1q17x7UCHLUyFX28/7p5sYlJ6AO7zm3q2xsDWujKEVnYUY6uX+oH75ZPG5bMYNUdsQOLXklmJGJrWfpme7NPjzVpBm4QaWxo9T9UjA6KIUoYMayPR1GjdCivxFmsG51aT87RQ== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69bebcd5-1a96-4b6f-2587-08d850a45a2c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4928.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2020 07:30:09.3614 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: P4hEx8LZL7SpAJf6RTbfuwABUODj2X2e9ZxOMhjJ+srO5em3DBsao90HLctiHueB X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5534 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add arm64 IMA arch support. The arch policy is inherited from x86. Signed-off-by: Chester Lin --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/Makefile | 2 ++ arch/arm64/kernel/ima_arch.c | 37 ++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 arch/arm64/kernel/ima_arch.c diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 6d232837cbee..b5518e7b604d 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -196,6 +196,7 @@ config ARM64 select SWIOTLB select SYSCTL_EXCEPTION_TRACE select THREAD_INFO_IN_TASK + imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI help ARM 64-bit (AArch64) Linux support. diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index a561cbb91d4d..0300ab60785d 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -71,3 +71,5 @@ extra-y += $(head-y) vmlinux.lds ifeq ($(CONFIG_DEBUG_EFI),y) AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\"" endif + +obj-$(CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT) += ima_arch.o diff --git a/arch/arm64/kernel/ima_arch.c b/arch/arm64/kernel/ima_arch.c new file mode 100644 index 000000000000..46f5641c3da5 --- /dev/null +++ b/arch/arm64/kernel/ima_arch.c @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2018 IBM Corporation + */ +#include +#include + +bool arch_ima_get_secureboot(void) +{ + if (efi_enabled(EFI_SECURE_BOOT)) + return true; + + return false; +} + +/* secureboot arch rules */ +static const char * const sb_arch_rules[] = { +#if !IS_ENABLED(CONFIG_KEXEC_SIG) + "appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig", +#endif /* CONFIG_KEXEC_SIG */ + "measure func=KEXEC_KERNEL_CHECK", +#if !IS_ENABLED(CONFIG_MODULE_SIG) + "appraise func=MODULE_CHECK appraise_type=imasig", +#endif + "measure func=MODULE_CHECK", + NULL +}; + +const char * const *arch_get_ima_policy(void) +{ + if (IS_ENABLED(CONFIG_IMA_ARCH_POLICY) && arch_ima_get_secureboot()) { + if (IS_ENABLED(CONFIG_MODULE_SIG)) + set_module_sig_enforced(); + return sb_arch_rules; + } + return NULL; +}