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=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 31BAAC4363A for ; Fri, 30 Oct 2020 11:53:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C961E20706 for ; Fri, 30 Oct 2020 11:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604058820; bh=d3fuMxWlzDmtJJrL2Md7MIp8HAK24XJci5Rj9/IXNek=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=FD2WgFswELT5CzDPR8vI78lxYk76I48cBL1/reaezNbZaAFt01hz/Z2RZtH7DbOHc qTUDIIh4N5ILoRVPpq1qP7mU7nKEREbsGXR/ceBWPzvDg/8KHSJhMUpL3QuxfSVvbx 6zbmXlfPxowU1ygW6BufLRfUqwY+H9+LBaMDWAeE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726297AbgJ3Lxj (ORCPT ); Fri, 30 Oct 2020 07:53:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:39656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbgJ3Lxj (ORCPT ); Fri, 30 Oct 2020 07:53:39 -0400 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 930B022245; Fri, 30 Oct 2020 11:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604058817; bh=d3fuMxWlzDmtJJrL2Md7MIp8HAK24XJci5Rj9/IXNek=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=P639Eq7j8YcRl1gPHu3NalkhSdzAgeREjxAHYFtNfZ7GJFEfqabKpISxNCUeguPj7 tZgHFaKIfT87mpWK9ZLJoqfZWoOyDjXLApMaO+AwJEcDLRVR5Bf8F3bmwtOxa2bZpB 8xT/YuQW+hpuGxNSXYwIqPBoBUrv0dLxFI5amGD0= Received: by mail-oi1-f173.google.com with SMTP id l62so716474oig.1; Fri, 30 Oct 2020 04:53:37 -0700 (PDT) X-Gm-Message-State: AOAM5339tVq8wMSQN7Jm0IkReW1ohWt1p1aVl8Nu5UplDPBmRl0JS2Xv iqn02xnjhuaXrOr11DsVhLUyUpQ/Bx1GW8zMRHg= X-Google-Smtp-Source: ABdhPJzgiMhx0rV2JinMkA8Ww1A1B72xR8FBexBi9QJsDuwAWFMOSjFL8BwlpiIHRIAnVKfRfajVNQgJV1+RiQPhRDo= X-Received: by 2002:aca:5c82:: with SMTP id q124mr1316465oib.33.1604058816714; Fri, 30 Oct 2020 04:53:36 -0700 (PDT) MIME-Version: 1.0 References: <20201030060840.1810-1-clin@suse.com> <20201030060840.1810-4-clin@suse.com> In-Reply-To: <20201030060840.1810-4-clin@suse.com> From: Ard Biesheuvel Date: Fri, 30 Oct 2020 12:53:25 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 3/3] arm64/ima: add ima_arch support To: Chester Lin Cc: Mimi Zohar , James Morris , "Serge E. Hallyn" , Dmitry Kasatkin , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Linux Kernel Mailing List , Linux ARM , linux-efi , linux-integrity , linux-security-module@vger.kernel.org, X86 ML , "Lee, Chun-Yi" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org On Fri, 30 Oct 2020 at 07:09, Chester Lin wrote: > > Add arm64 IMA arch support. The code and arch policy is mainly inherited > from x86. > > Signed-off-by: Chester Lin > --- > arch/arm64/Kconfig | 1 + > arch/arm64/kernel/Makefile | 2 ++ > arch/arm64/kernel/ima_arch.c | 43 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 46 insertions(+) > create mode 100644 arch/arm64/kernel/ima_arch.c > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index a42e8d13cc88..496a4a26afc6 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -201,6 +201,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 bbaf0bc4ad60..0f6cbb50668c 100644 > --- a/arch/arm64/kernel/Makefile > +++ b/arch/arm64/kernel/Makefile > @@ -69,3 +69,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..564236d77adc > --- /dev/null > +++ b/arch/arm64/kernel/ima_arch.c > @@ -0,0 +1,43 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Copyright (C) 2018 IBM Corporation > + */ > +#include > +#include > +#include > + > +bool arch_ima_get_secureboot(void) > +{ > + static bool sb_enabled; > + static bool initialized; > + > + if (!initialized & efi_enabled(EFI_BOOT)) { > + sb_enabled = ima_get_efi_secureboot(); > + initialized = true; > + } > + > + return sb_enabled; > +} > + > +/* secure and trusted boot 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; > +} > -- > 2.28.0 > Can we move all this stuff into security/integrity/ima/ima_efi.c instead?