Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2073761pxu; Sun, 6 Dec 2020 18:05:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCEG3pOMMMhZc1tRTjTizENV20RmOfzXfx5K8tOGnyt2wvlV1a57uYjZfYRXGAQmR7hhTj X-Received: by 2002:a05:6402:30ac:: with SMTP id df12mr2172071edb.175.1607306739607; Sun, 06 Dec 2020 18:05:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607306739; cv=none; d=google.com; s=arc-20160816; b=kRKTIObO8K22w5/a4g44l5dGxJUqmf1+/Udaithij/4jz6Ky8489XjZawjzmDF8uxd 1g0VS8RJS5UWF7Be6y1t4CavlVXGgWq7mYnKgeytAXdUvzbKt3K3BDOP/3Z4ewp9yiAV h+WDG8jLDu389VozcHOlwNu6h71WmGoXvERKyfIVPBBBrJyAGlUqtpgiykfEJBEbSIr7 TWZdLnhjNv+WTeCyCiUprDs4zl2MYf1Lj4eunolFIRbzJU+VFLFH2iZgF6icDAGktg37 JCrpStFm1ATRgRWRxZKn3AZcN1AHtD+8Y3Cr7k09tHoWbQULPuK02DHr+imMD8NBlBst 5e4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-filter; bh=wNXjR79DfZouD5kjHAVglpUTtFseXZpcPOkj3ZGki20=; b=LmTVVXSnX2ge3V6xw2vujnJkIUMD586/U4qMMXNkzzDr79DRiY4rIWgasT9A864TXS s+vFXlb9tKGJFBckon7Z3Rdey0GEmIc2qq9JwRmIWVDJABZhOKC1yPxYXa/zN8Olvg5T JCbnVnwDZPDsN4d7dKik6P8k9i/MsMT5GZ3hWmXxQRjpIzLlvhw3LvDloV+QkJoaBOJR 0TWOeYXh93SGO6R5X4Wxv0RGFCXkU00NVmBCMgxGpX9D5xuVOKrPqbmMqNykbi59Gvt2 jXww9Ug45nDHCWVo/LeEh36naeVBeS7fUu48Kv//ouDV675XwCjFxtfZ92JvNS7hMnzl 8ICA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=IXegge9e; 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=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k16si7241799edr.236.2020.12.06.18.05.16; Sun, 06 Dec 2020 18:05:39 -0800 (PST) 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=@linux.microsoft.com header.s=default header.b=IXegge9e; 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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728457AbgLGCDy (ORCPT + 99 others); Sun, 6 Dec 2020 21:03:54 -0500 Received: from linux.microsoft.com ([13.77.154.182]:51106 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726858AbgLGCDx (ORCPT ); Sun, 6 Dec 2020 21:03:53 -0500 Received: from [192.168.0.104] (c-73-42-176-67.hsd1.wa.comcast.net [73.42.176.67]) by linux.microsoft.com (Postfix) with ESMTPSA id 3DBE120B717A; Sun, 6 Dec 2020 18:03:11 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3DBE120B717A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1607306591; bh=wNXjR79DfZouD5kjHAVglpUTtFseXZpcPOkj3ZGki20=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=IXegge9eZpr5RicWYXAS/1EreO/D8z5mCjdxt/WxC/uTu+9xAW7ci+SSE4WycAPYH u2E41ku7hlxBF1k0gheSZte/9YCEoQwOkIUzHFBIRY7AkiaTRi5+ZLGB4RG2FP2/FJ DqnVJGneW/IcVWtq5b/QIE5lrrK7Br0uHeKksh4w= Subject: Re: [PATCH v10 7/8] powerpc: Move arch_ima_add_kexec_buffer to ima To: Thiago Jung Bauermann Cc: zohar@linux.ibm.com, robh@kernel.org, gregkh@linuxfoundation.org, james.morse@arm.com, catalin.marinas@arm.com, sashal@kernel.org, will@kernel.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, robh+dt@kernel.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, kstewart@linuxfoundation.org, takahiro.akashi@linaro.org, tglx@linutronix.de, masahiroy@kernel.org, bhsharma@redhat.com, mbrugger@suse.com, hsinyi@chromium.org, tao.li@vivo.com, christophe.leroy@c-s.fr, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, prsriva@linux.microsoft.com, balajib@linux.microsoft.com References: <20201204195149.611-1-nramas@linux.microsoft.com> <20201204195149.611-8-nramas@linux.microsoft.com> <87k0twlytt.fsf@manicouagan.localdomain> From: Lakshmi Ramasubramanian Message-ID: <0f60b35e-eff6-20c6-363d-82f0b10a1c1f@linux.microsoft.com> Date: Sun, 6 Dec 2020 18:03:10 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <87k0twlytt.fsf@manicouagan.localdomain> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/5/20 1:36 PM, Thiago Jung Bauermann wrote: > > Lakshmi Ramasubramanian writes: > >> 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 > > Not sure if the maintainers will agree with me (see below), but FWIW: > > Reviewed-by: Thiago Jung Bauermann > >> --- >> arch/powerpc/include/asm/ima.h | 3 --- >> arch/powerpc/kexec/ima.c | 21 --------------------- >> security/integrity/ima/ima_kexec.c | 22 ++++++++++++++++++++++ >> 3 files changed, 22 insertions(+), 24 deletions(-) >> >> diff --git a/arch/powerpc/include/asm/ima.h b/arch/powerpc/include/asm/ima.h >> index d8444d27f0d8..d6ab5d944dcd 100644 >> --- a/arch/powerpc/include/asm/ima.h >> +++ b/arch/powerpc/include/asm/ima.h >> @@ -7,9 +7,6 @@ >> struct kimage; >> >> #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 bf7084c0c4da..b2793be353a9 100644 >> --- a/arch/powerpc/kexec/ima.c >> +++ b/arch/powerpc/kexec/ima.c >> @@ -13,27 +13,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_kexec.c b/security/integrity/ima/ima_kexec.c >> index 4d354593aecf..5263dafe8f4d 100644 >> --- a/security/integrity/ima/ima_kexec.c >> +++ b/security/integrity/ima/ima_kexec.c >> @@ -74,6 +74,28 @@ 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; >> +} >> + > > Both powerpc and arm64 use the definition above for > arch_ima_add_kexec_buffer(), so it makes sense to share them as you do > in this patch. This file isn't the best one to put arch-specific code > which happens to be identical among architectures, but I can't think of > somewhere else to put it. > > For now this isn't an issue since powerpc and arm64 are the only arches > implementing tihs feature. If a third arch implemented it and also used > the same function definition as above, it wouldn't be an issue either so > perhaps this is good enough for the time being? :-) If Mimi doesn't have any objection, I'll leave this function in this file. The other option is to move this function also to "drivers/of/kexec.c". Please let me know. > > With this patch, the `#include ` in > security/integrity/ima/ima.h can be removed. It was there just to > provide a declaration of arch_ima_add_kexec_buffer(). > Sure - will remove this #include. thanks, -lakshmi