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=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 6A613C433DB for ; Wed, 23 Dec 2020 00:42:31 +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 0C699206E5 for ; Wed, 23 Dec 2020 00:42:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C699206E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.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-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:In-reply-to:Subject:To: From:References:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RqN0XZqwHdOYO6nnYHscSCJ39DnkFEbLbRPJ9lwD5AQ=; b=m6HogTJ+sQlWiFkxN63T1hZx5 mFzMv8AWMYvqccVJ2IoigBRInJMwXliNZLVgzOOsrdQbTdtLzJDVV79N7iOlyQa0b855cgr/XVNeH U0envNQuQeAdngQFIty4W1GVP2N7Tquuar0/dAcKSqBrtBA0gcGSfw4eriogwOgCwTQARkPOoysFb 7+hTrS3yWwoL84eKC5OmxU9WsZ5QpeOOM2TCQIlxnAWBE/GoLkAr/cbYNmyenTyFuFOKhTx+52MS4 nlUVrIJsT6qEQSD2V0fCO2Ryk2JcbS05wICHBMgdMyp20Ihm2F/CnPmEX5Blv20LVJrS7K+Q3PHoc xFCMEhDYQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1krsD9-0005L1-Dt; Wed, 23 Dec 2020 00:41:03 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1krsD6-0005Ke-Fg for linux-arm-kernel@lists.infradead.org; Wed, 23 Dec 2020 00:41:01 +0000 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0BN0VvdO159797; Tue, 22 Dec 2020 19:40:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=references : from : to : cc : subject : in-reply-to : date : message-id : mime-version : content-type; s=pp1; bh=LQNrZt7cXaf8edxCI1c85/3rx53hHhlzwFwn6ESYwPA=; b=F3zc6jfoE6T5bwHaXkaVqB70dnNzDYKuD1o+vB9/mAI21EY3+0O3yoF89cx0jQmsCy94 lGSdCljH8wSrRfZQgTi9OJ1H1U93BW3rG/moAwRKoDDg+7fD4waKtC62jfTI3vrMhUdN H/ktE6VioQmvH/Ihybq8kz+TeVxKH2BFWx8a+BQGyuaw7ST3JPSCIuwtZIVDZjfvhZhL 82ZxLysO+kupDFuS1v/YV/l+aXjOa1x2vG1U9tqnXqUcXu2fb7zf2S2BF+OUSrJUaM0I Szo9iCTIEJNXVzoWLuKhKaKDdzReRV++KrycJsnpjYKzr5eKcIm/DWs4/iwXZllzwjRN NA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35kt0a1tu9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 19:40:45 -0500 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0BN0YAqq164499; Tue, 22 Dec 2020 19:40:44 -0500 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 35kt0a1ttu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 19:40:44 -0500 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0BN0XMbc011912; Wed, 23 Dec 2020 00:40:43 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma05wdc.us.ibm.com with ESMTP id 35kferccxh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Dec 2020 00:40:43 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0BN0eg6t16974200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Dec 2020 00:40:43 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0AEBBE056; Wed, 23 Dec 2020 00:40:42 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01D7FBE053; Wed, 23 Dec 2020 00:40:34 +0000 (GMT) Received: from manicouagan.localdomain (unknown [9.80.219.136]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTPS; Wed, 23 Dec 2020 00:40:34 +0000 (GMT) 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> User-agent: mu4e 1.4.10; emacs 27.1 From: Thiago Jung Bauermann To: Lakshmi Ramasubramanian Subject: Re: [PATCH v13 2/6] powerpc: Move arch independent ima kexec functions to drivers/of/kexec.c In-reply-to: <71764175-4007-2828-f882-9215c062330a@linux.microsoft.com> Date: Tue, 22 Dec 2020 21:40:32 -0300 Message-ID: <878s9pl5hb.fsf@manicouagan.localdomain> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-22_13:2020-12-21, 2020-12-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012220175 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201222_194100_610133_9A065654 X-CRM114-Status: GOOD ( 25.26 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. -- 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