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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 A2062C433E0 for ; Wed, 23 Dec 2020 05:04:21 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5ACE2223E0 for ; Wed, 23 Dec 2020 05:04:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5ACE2223E0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZYccDyPQcgIcj0ol2EAib7N/u9oQOK6fUraAVknoa4M=; b=DMNNxMTT/Dkb7pjlQyJhio323 ZCNz4ij/XAy2lSM7ucMCXCSNSOlJ88g18H98ju3b1aXlPs2TWaASpQWZhvC92+BWBL9TTAImEQW0d figoQhNfaRiaAgawO8ogAoRwdTxfMBlBHLRxNZEn+RXz7zQW8hqoB7LEq83shipB+hbit6Yk7p1MX m9DGOreS89WtdpEh1PM9owFEwp91d6uSsXp/D4IyMjWo1+BKzCPY8ca4H+TTr/8ABdU5+cesNMtrd DabP3jw9v8kk2PlDDDUziUoablCd+xMzmfdGM4JvH+WC9fzmfmuIAnGNjim33dzpotqiKayVgLrc5 +ZP4FtXlQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1krwIn-0007fW-Lz; Wed, 23 Dec 2020 05:03:09 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1krwIl-0007ew-0z for linux-arm-kernel@lists.infradead.org; Wed, 23 Dec 2020 05:03:07 +0000 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 770C720B7192; Tue, 22 Dec 2020 21:03:05 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 770C720B7192 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1608699786; bh=+qWMHabIV1b5Ec2AcABEWGXQMINxp/AybIKM5slhmIo=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=RvRaYi+lR7Ume2OZNoW3hfzn2O5eGgvqlWIoJv30sqrbOS/BvtZRtYsGRv7OfAIym +aN98PTpZnMYs7NrZm8wwLKx4C25mcMEpU+WxT3fz2ehDNFaGRv2SsRbZ7ZAg71paq EhS2Bc+r8Jv51WMQu9GTy72e/ZNj44EpZDWT5Oes= Subject: Re: [PATCH v13 2/6] powerpc: Move arch independent ima kexec functions to drivers/of/kexec.c To: Thiago Jung Bauermann References: <20201219175713.18888-1-nramas@linux.microsoft.com> <20201219175713.18888-3-nramas@linux.microsoft.com> <7a347c8f2a76fc80551a3dfcb66b0eec9b024a90.camel@linux.ibm.com> <71764175-4007-2828-f882-9215c062330a@linux.microsoft.com> <878s9pl5hb.fsf@manicouagan.localdomain> From: Lakshmi Ramasubramanian Message-ID: <159c7e4d-0cad-158f-6f5b-9f3b60159b38@linux.microsoft.com> Date: Tue, 22 Dec 2020 21:03:05 -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: <878s9pl5hb.fsf@manicouagan.localdomain> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201223_000307_208552_C97F6C0E X-CRM114-Status: GOOD ( 23.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, benh@kernel.crashing.org, bhsharma@redhat.com, tao.li@vivo.com, Mimi Zohar , paulus@samba.org, vincenzo.frascino@arm.com, frowand.list@gmail.com, sashal@kernel.org, mpe@ellerman.id.au, masahiroy@kernel.org, jmorris@namei.org, takahiro.akashi@linaro.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, serge@hallyn.com, devicetree@vger.kernel.org, pasha.tatashin@soleen.com, will@kernel.org, prsriva@linux.microsoft.com, hsinyi@chromium.org, allison@lohutok.net, christophe.leroy@c-s.fr, mbrugger@suse.com, balajib@linux.microsoft.com, dmitry.kasatkin@gmail.com, linux-kernel@vger.kernel.org, james.morse@arm.com, gregkh@linuxfoundation.org, linux-integrity@vger.kernel.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 12/22/20 4:40 PM, Thiago Jung Bauermann wrote: > > Lakshmi Ramasubramanian writes: > >> On 12/22/20 11:45 AM, Mimi Zohar wrote: >>> On Tue, 2020-12-22 at 10:53 -0800, Lakshmi Ramasubramanian wrote: >>>> On 12/22/20 6:26 AM, Mimi Zohar wrote: >>>> >>>> Hi Mimi, >>>> >>>>> >>>>> On Sat, 2020-12-19 at 09:57 -0800, Lakshmi Ramasubramanian wrote: >>>>>> >>>>>> diff --git a/arch/powerpc/kexec/Makefile b/arch/powerpc/kexec/Makefile >>>>>> index 4aff6846c772..b6c52608cb49 100644 >>>>>> --- a/arch/powerpc/kexec/Makefile >>>>>> +++ b/arch/powerpc/kexec/Makefile >>>>>> @@ -9,13 +9,6 @@ obj-$(CONFIG_PPC32) += relocate_32.o >>>>>> obj-$(CONFIG_KEXEC_FILE) += file_load.o ranges.o >>>>>> file_load_$(BITS).o elf_$(BITS).o >>>>>> -ifdef CONFIG_HAVE_IMA_KEXEC >>>>>> -ifdef CONFIG_IMA >>>>>> -obj-y += ima.o >>>>>> -endif >>>>>> -endif >>>>> >>>>> Notice how "kexec/ima.o" is only included if the architecture supports >>>>> it and IMA is configured. In addition only if CONFIG_IMA_KEXEC is >>>>> configured, is the IMA measurement list carried across kexec. After >>>>> moving the rest of ima.c to drivers/of/kexec.c, this changes. Notice >>>>> how drivers/of/Kconfig includes kexec.o: >>>>> >>>>> obj-$(CONFIG_KEXEC_FILE) += kexec.o >>>>> >>>>> It is not dependent on CONFIG_HAVE_IMA_KEXEC. Shouldn't all of the >>>>> functions defined in ima.c being moved to kexec.o be defined within a >>>>> CONFIG_HAVE_IMA_KEXEC ifdef? >>>>> >>>> >>>> Thanks for reviewing the changes. >>>> >>>> In "drivers/of/kexec.c" the function remove_ima_buffer() is defined >>>> under "#ifdef CONFIG_HAVE_IMA_KEXEC" >>>> >>>> setup_ima_buffer() is defined under "#ifdef CONFIG_IMA_KEXEC" - the same >>>> way it was defined in "arch/powerpc/kexec/ima.c". >>>> >>>> As you know, CONFIG_IMA_KEXEC depends on CONFIG_HAVE_IMA_KEXEC (as >>>> defined in "security/integrity/ima/Kconfig"). >>>> >>>> ima_get_kexec_buffer() and ima_free_kexec_buffer() are unconditionally >>>> defined in "drivers/of/kexec.c" even though they are called only when >>>> CONFIG_HAVE_IMA_KEXEC is enabled. I will update these two functions to >>>> be moved under "#ifdef CONFIG_HAVE_IMA_KEXEC" >>> The issue is the reverse. CONFIG_HAVE_IMA_KEXEC may be enabled without >>> CONFIG_IMA_KEXEC being enabled. This allows the architecture to >>> support carrying the measurement list across kexec, but requires >>> enabling it at build time. >>> Only if CONFIG_HAVE_IMA_KEXEC is enabled should any of these functions >>> be compiled at build. This allows restoring the previous IMA >>> measurement list, even if CONFIG_IMA_KEXEC is not enabled. >>> Only if CONFIG_IMA_KEXEC is enabled, should carrying the measurement >>> list across kexec be enabled. See how arch_ima_add_kexec_buffer, >>> write_number, setup_ima_buffer are ifdef'ed in >>> arch/powerpc/kexec/ima.c. >>> >> >> Yes - I agree. I will make the following changes: >> >> => Enable the functions moved from "arch/powerpc/kexec/ima.c" to >> "drivers/of/kexec.c" only when CONFIG_HAVE_IMA_KEXEC is enabled. >> >> => Also, compile write_number() and setup_ima_buffer() only when >> CONFIG_IMA_KEXEC is enabled. > > Sounds good, with one additional change: > > So far, CONFIG_HAVE_IMA_KEXEC was tested only in files that were built > when CONFIG_IMA was set. With this series this is not the case anymore > (in drivers/of/kexec.c). The simplest way to keep this consistent is to > only enable CONFIG_HAVE_IMA_KEXEC if CONFIG_IMA is also set. > > For example, with this: > > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig > index e9f13fe08492..4ddd17215ecf 100644 > --- a/arch/powerpc/Kconfig > +++ b/arch/powerpc/Kconfig > @@ -548,7 +548,7 @@ config KEXEC > config KEXEC_FILE > bool "kexec file based system call" > select KEXEC_CORE > - select HAVE_IMA_KEXEC > + select HAVE_IMA_KEXEC if IMA > select BUILD_BIN2C > select KEXEC_ELF > depends on PPC64 > > And then the same thing on the arm64 patch. This is a good idea Thiago - I will make this change in the Kconfig for both powerpc and arm64. thanks, -lakshmi _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel