Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1765610ybn; Thu, 26 Sep 2019 01:45:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWpW3sFTriqfHRuPNEbjMavVQwgWwl0x1CH2HjRXapmyrllNetTJPir5A9U8h/hWQMKGIt X-Received: by 2002:a17:906:278a:: with SMTP id j10mr2018929ejc.228.1569487532101; Thu, 26 Sep 2019 01:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569487532; cv=none; d=google.com; s=arc-20160816; b=nOuhMv4EvVQtIsMC13JvrRWxjrLrj6QnXHlZoZUFw5kz9WH2V+DS+6VW7iaBAkmkZG Xe0HIBt6ULpqSWUFQuk+cKypo7EgHJSoiFjUvyMuhVxPtX7M8H+ldi/BrmIGu0mYePkZ woS9tuTKjYSCvzUcTMOInJYgKhCxbropinQS1sH2tlgJJtmeNISUJE3BdFkp6nxCG8hs OWD2yw8ddZ3lMiZM6Qf4iDMRJGWCQTSdIhWT7WX/F0EMM4hrS2VYOKFaKZvDXh2MttJ0 xkjvaTrliKBlwx5/7aEVOu0/Lj4z8GUTPBlx862Kk7HFyjO1g56wkA+L808UgvmW8ygc JUdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=zbkvAUEtSA/AC4twSrIaMpIlbFehx10gEi4x+zQzfiI=; b=SW2B63el5NYcq922qoFJmXNxIIInYVPbatBwM/347DfXA7nOoyp2DhfYg+CgY0Q+So jZsWlDpWdFMB/RPN308MHyTRg9Sj9KfOsKY05hnV6FOIKURciQ0XsDFu795k8t+6hG0/ WqHbW54TroIPRNzgzqIopTmeyO2WkDAWUaK+kDtMppbVb5Y9qi7yR4fypgCcx5Ej20oM XYO1F4Sqp+pWMTGmt3joGg9xwF84VtNDgAp1wWeLk3zVJiOASMNTDMv351gEpHiV74No ePKaDi8GX1/V/CCailvcymD9Wt4LJUk49Wmk9GTn0igNFYHfWE5plAXw2z+dzrnvLMwx L5ZQ== 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=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si641429eju.3.2019.09.26.01.45.08; Thu, 26 Sep 2019 01:45:32 -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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2633087AbfIXTy2 (ORCPT + 99 others); Tue, 24 Sep 2019 15:54:28 -0400 Received: from linux.microsoft.com ([13.77.154.182]:45846 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727204AbfIXTy2 (ORCPT ); Tue, 24 Sep 2019 15:54:28 -0400 Received: from [10.200.156.146] (unknown [167.220.2.18]) by linux.microsoft.com (Postfix) with ESMTPSA id 7C20620BBF87; Tue, 24 Sep 2019 12:54:26 -0700 (PDT) Subject: Re: [RFC PATCH v1 1/1] Add support for arm64 to carry ima measurement log in kexec_file_load To: Thiago Jung Bauermann Cc: mark.rutland@arm.com, jean-philippe@linaro.org, arnd@arndb.de, takahiro.akashi@linaro.org, sboyd@kernel.org, catalin.marinas@arm.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, zohar@linux.ibm.com, yamada.masahiro@socionext.com, kristina.martsenko@arm.org, duwe@lst.de, allison@lohutok.net, james.morse@arm.org, linux-integrity@vger.kernel.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org References: <20190913225009.3406-1-prsriva@linux.microsoft.com> <20190913225009.3406-2-prsriva@linux.microsoft.com> <87zhiz1x9l.fsf@morokweng.localdomain> From: prsriva Message-ID: <02234482-b095-e064-f4d6-1c6255a4ff9f@linux.microsoft.com> Date: Tue, 24 Sep 2019 12:54:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <87zhiz1x9l.fsf@morokweng.localdomain> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/19/19 8:07 PM, Thiago Jung Bauermann wrote: > Hello Prakhar, > > Prakhar Srivastava writes: > >> During kexec_file_load, carrying forward the ima measurement log allows >> a verifying party to get the entire runtime event log since the last >> full reboot since that is when PCRs were last reset. >> >> Signed-off-by: Prakhar Srivastava >> --- >> arch/arm64/Kconfig | 7 + >> arch/arm64/include/asm/ima.h | 29 ++++ >> arch/arm64/include/asm/kexec.h | 5 + >> arch/arm64/kernel/Makefile | 3 +- >> arch/arm64/kernel/ima_kexec.c | 213 +++++++++++++++++++++++++ >> arch/arm64/kernel/machine_kexec_file.c | 6 + >> 6 files changed, 262 insertions(+), 1 deletion(-) >> create mode 100644 arch/arm64/include/asm/ima.h >> create mode 100644 arch/arm64/kernel/ima_kexec.c >> >> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig >> index 3adcec05b1f6..f39b12dbf9e8 100644 >> --- a/arch/arm64/Kconfig >> +++ b/arch/arm64/Kconfig >> @@ -976,6 +976,13 @@ config KEXEC_VERIFY_SIG >> verification for the corresponding kernel image type being >> loaded in order for this to work. >> >> +config HAVE_IMA_KEXEC >> + bool "Carry over IMA measurement log during kexec_file_load() syscall" >> + depends on KEXEC_FILE >> + help >> + Select this option to carry over IMA measurement log during >> + kexec_file_load. >> + >> config KEXEC_IMAGE_VERIFY_SIG >> bool "Enable Image signature verification support" >> default y > This is not right. As it stands, HAVE_IMA_KEXEC is essentially a synonym > for IMA_KEXEC. > > It's not meant to be user-visible in the config process. Instead, it's > meant to be selected by the arch Kconfig (probably by the ARM64 config > symbol) to signal to IMA's Kconfig that it can offer the IMA_KEXEC > option. > > I also mentioned in my previous review that config HAVE_IMA_KEXEC should > be defined in arch/Kconfig, not separately in both arch/arm64/Kconfig > and arch/powerpc/Kconfig. I see the entry exists in arch/Kconfig and is overwritten. I will remove entries both from powerpc and arm64. How do i cross-compile for powerpc? > >> diff --git a/arch/arm64/include/asm/ima.h b/arch/arm64/include/asm/ima.h >> new file mode 100644 >> index 000000000000..e23cee84729f >> --- /dev/null >> +++ b/arch/arm64/include/asm/ima.h >> @@ -0,0 +1,29 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +#ifndef _ASM_ARM64_IMA_H >> +#define _ASM_ARM64_IMA_H >> + >> +struct kimage; >> + >> +int ima_get_kexec_buffer(void **addr, size_t *size); >> +int ima_free_kexec_buffer(void); >> + >> +#ifdef CONFIG_IMA >> +void remove_ima_buffer(void *fdt, int chosen_node); >> +#else >> +static inline void remove_ima_buffer(void *fdt, int chosen_node) {} >> +#endif > I mentioned in my previous review that remove_ima_buffer() should exist > even if CONFIG_IMA isn't set. Did you arrive at a different conclusion? I made the needed changed in makefile, missed removing the configs here. Thanks for pointing this out. >> + >> +#ifdef CONFIG_IMA_KEXEC >> +int arch_ima_add_kexec_buffer(struct kimage *image, unsigned long load_addr, >> + size_t size); >> + >> +int setup_ima_buffer(const struct kimage *image, void *fdt, int chosen_node); >> +#else >> +static inline int setup_ima_buffer(const struct kimage *image, void *fdt, >> + int chosen_node) >> +{ >> + remove_ima_buffer(fdt, chosen_node); >> + return 0; >> +} >> +#endif /* CONFIG_IMA_KEXEC */ >> +#endif /* _ASM_ARM64_IMA_H */ >> diff --git a/arch/arm64/kernel/ima_kexec.c b/arch/arm64/kernel/ima_kexec.c >> new file mode 100644 >> index 000000000000..b14326d541f3 >> --- /dev/null >> +++ b/arch/arm64/kernel/ima_kexec.c > In the previous patch, you took the powerpc file and made a few > modifications to fit your needs. This file is now somewhat different > than the powerpc version, but I don't understand to what purpose. It's > not different in any significant way. > > Based on review comments from your previous patch, I was expecting to > see code from the powerpc file moved to an arch-independent part of the > the kernel and possibly adapted so that both arm64 and powerpc could use > it. Can you explain why you chose this approach instead? What is the > advantage of having superficially different but basically equivalent > code in the two architectures? > > Actually, there's one change that is significant: instead of a single > linux,ima-kexec-buffer property holding the start address and size of > the buffer, ARM64 is now using two properties (linux,ima-kexec-buffer > and linux,ima-kexec-buffer-end) for the start and end addresses. In my > opinion, unless there's a good reason for it Linux should be consistent > accross architectures when possible. > > -- > Thiago Jung Bauermann > IBM Linux Technology Center > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel