Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1205912pxx; Fri, 30 Oct 2020 04:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgcICh+TIrjso7gxyyu1oLoiLR0Y41VYLsuAnD61Z5wcz1ht4IX7Ee8nkvzf3tGdTQ7Fog X-Received: by 2002:aa7:cb8f:: with SMTP id r15mr1916923edt.356.1604058945860; Fri, 30 Oct 2020 04:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604058945; cv=none; d=google.com; s=arc-20160816; b=p1PSwMvONb0pt9Q8IhCfOkuZpjcgAtNqYTdxgeRFT6YhAoc+SPYBfPInOCzv8qeGV7 UbIx9nnuR6rZIgxaRdXAV7vCnc6DgybSDcAka07IjaCu8Ov9kFgO5Rp2ABcq6aIOdoer 9gfZfA9pLDrMLqbU0nTkEZlIKofkiWfWKZRqBlxwZX5m7s/Ns3Tycha5H2en314Le8Aw +GU4mTcuaYZ6jB3L3G6ePoG0mV/mHa4aHAjaqpP9dthwmo1rfUPErsDM4mh/XgG1Uwyb E3XAR/oec9TFhTObp9y1nMNPycbs82KJew/umAN2Pe9g59GgCJtE8JLnhbuU8BPNd4fh G+WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KNdnnqvUQl08F/GLwmjA06tfTPOzDknpkf3RDbv2gBc=; b=oI+CglSOyNc9JFMwduz/Ox5oVI5eqapUDK1NFxC2G0ehB9lGnriPL/21evvzlX0SU7 WSJfH+GRFTPaFCua0Ax6KwYX3UKCcn12DCCLkApvJ69tT/r2m37LPk3YeUD1xZ2ZHWv0 tpJXw99BH0Q+S0BwJlQXPahkxbEUne6EbJNYVZPTRuJaxtI8s8ctOBdpy4JyJVMlJsek TiKcSLY7JMOhVXI8FInVyV5kHlP5BHClGbuRySdriKf6HYtm2W02PB49QZb/CfEhK7Al gm3Ue3puiFFyWaX8AIxHMQEZ95Xk2fhnxO/MjQJ/mEfaDau1U7PLxjcw91Hv4UCn3Y+e uKrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P639Eq7j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a64si4129900edf.234.2020.10.30.04.55.23; Fri, 30 Oct 2020 04:55:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P639Eq7j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726508AbgJ3Lxj (ORCPT + 99 others); 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-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-kernel@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?