From patchwork Mon Dec 14 19:18:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lakshmi Ramasubramanian X-Patchwork-Id: 11972839 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=-26.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL 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 603E1C2BB48 for ; Mon, 14 Dec 2020 19:23:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2489224B1 for ; Mon, 14 Dec 2020 19:23:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502179AbgLNTUq (ORCPT ); Mon, 14 Dec 2020 14:20:46 -0500 Received: from linux.microsoft.com ([13.77.154.182]:58468 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440923AbgLNTUf (ORCPT ); Mon, 14 Dec 2020 14:20:35 -0500 Received: from localhost.localdomain (c-73-42-176-67.hsd1.wa.comcast.net [73.42.176.67]) by linux.microsoft.com (Postfix) with ESMTPSA id A805320B718B; Mon, 14 Dec 2020 11:19:10 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A805320B718B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1607973551; bh=Ml39LpLs0H2sT9S4WHQ/qTo2Q8tVMcy8RDdtdsfDnRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WzqTp4rhRJQ/BMMCgn8mYdg/YVeNWh4CobX3oxfoPAZWtsv4VCoPKGqKbzZUN64L1 pZkhUxgBtMwwu31Q0wgsitfDDkJguP+Q6YoltI4Mr+n75am1zxY1yFeSyL+lAQxTUr QWZQ0T6iveF1PR4DXh0a28wEuC5zOThB7OjaPTgc= From: Lakshmi Ramasubramanian To: zohar@linux.ibm.com, bauerman@linux.ibm.com, robh@kernel.org, takahiro.akashi@linaro.org, gregkh@linuxfoundation.org, will@kernel.org, catalin.marinas@arm.com, mpe@ellerman.id.au Cc: james.morse@arm.com, sashal@kernel.org, benh@kernel.crashing.org, paulus@samba.org, frowand.list@gmail.com, vincenzo.frascino@arm.com, mark.rutland@arm.com, dmitry.kasatkin@gmail.com, jmorris@namei.org, serge@hallyn.com, pasha.tatashin@soleen.com, allison@lohutok.net, masahiroy@kernel.org, bhsharma@redhat.com, mbrugger@suse.com, hsinyi@chromium.org, tao.li@vivo.com, christophe.leroy@c-s.fr, prsriva@linux.microsoft.com, balajib@linux.microsoft.com, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH v11 6/8] powerpc: Move arch_ima_add_kexec_buffer to ima Date: Mon, 14 Dec 2020 11:18:52 -0800 Message-Id: <20201214191854.9050-7-nramas@linux.microsoft.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201214191854.9050-1-nramas@linux.microsoft.com> References: <20201214191854.9050-1-nramas@linux.microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org arch_ima_add_kexec_buffer() sets the address and size of the IMA measurement log in the architecture specific field in struct kimage. This function does not have architecture specific code, but is currently limited to powerpc. Move arch_ima_add_kexec_buffer() to security/integrity/ima/ima_kexec.c so that it is accessible for other architectures as well. Signed-off-by: Lakshmi Ramasubramanian --- arch/powerpc/include/asm/ima.h | 3 --- arch/powerpc/kexec/ima.c | 21 --------------------- security/integrity/ima/ima.h | 4 ---- security/integrity/ima/ima_kexec.c | 21 +++++++++++++++++++++ 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/arch/powerpc/include/asm/ima.h b/arch/powerpc/include/asm/ima.h index 3875c9334d64..cb088e442d11 100644 --- a/arch/powerpc/include/asm/ima.h +++ b/arch/powerpc/include/asm/ima.h @@ -5,9 +5,6 @@ #include #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, diff --git a/arch/powerpc/kexec/ima.c b/arch/powerpc/kexec/ima.c index 82730c13a4df..d66ae17c64af 100644 --- a/arch/powerpc/kexec/ima.c +++ b/arch/powerpc/kexec/ima.c @@ -12,27 +12,6 @@ #include #include -/** - * arch_ima_add_kexec_buffer - do arch-specific steps to add the IMA buffer - * - * @image: kimage struct to set IMA buffer data - * @load_addr: Starting address where IMA buffer is loaded at - * @size: Number of bytes in the IMA buffer - * - * Architectures should use this function to pass on the IMA buffer - * information to the next kernel. - * - * Return: 0 on success, negative errno on error. - */ -int arch_ima_add_kexec_buffer(struct kimage *image, unsigned long load_addr, - size_t size) -{ - image->arch.ima_buffer_addr = load_addr; - image->arch.ima_buffer_size = size; - - return 0; -} - static int write_number(void *p, u64 value, int cells) { if (cells == 1) { diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h index 6ebefec616e4..7c3947ad3773 100644 --- a/security/integrity/ima/ima.h +++ b/security/integrity/ima/ima.h @@ -24,10 +24,6 @@ #include "../integrity.h" -#ifdef CONFIG_HAVE_IMA_KEXEC -#include -#endif - enum ima_show_type { IMA_SHOW_BINARY, IMA_SHOW_BINARY_NO_FIELD_LEN, IMA_SHOW_BINARY_OLD_STRING_FMT, IMA_SHOW_ASCII }; enum tpm_pcrs { TPM_PCR0 = 0, TPM_PCR8 = 8, TPM_PCR10 = 10 }; diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c index 9527118939b8..7293eb4545ac 100644 --- a/security/integrity/ima/ima_kexec.c +++ b/security/integrity/ima/ima_kexec.c @@ -75,6 +75,27 @@ static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer, return ret; } +/** + * arch_ima_add_kexec_buffer - do arch-specific steps to add the IMA buffer + * + * @image: kimage struct to set IMA buffer data + * @load_addr: Starting address where IMA buffer is loaded at + * @size: Number of bytes in the IMA buffer + * + * Architectures should use this function to pass on the IMA buffer + * information to the next kernel. + * + * Return: 0 on success, negative errno on error. + */ +static int arch_ima_add_kexec_buffer(struct kimage *image, + unsigned long load_addr, size_t size) +{ + image->arch.ima_buffer_addr = load_addr; + image->arch.ima_buffer_size = size; + + return 0; +} + /* * Called during kexec_file_load so that IMA can add a segment to the kexec * image for the measurement list for the next kernel.