Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1740848rdb; Thu, 7 Dec 2023 07:37:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyJJekMQQvjv7qleMtcz1dcpZ80WPC1uZmtQ/9Cfisjv/7e8QTrPsfJ4AHDK7pxForf3UV X-Received: by 2002:a17:903:187:b0:1cf:d2c5:ae87 with SMTP id z7-20020a170903018700b001cfd2c5ae87mr2818817plg.11.1701963473260; Thu, 07 Dec 2023 07:37:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701963473; cv=none; d=google.com; s=arc-20160816; b=F3aYa249CTfcGS89l80fasejtQCs3CTz9uJfC7kxqVBdUB8wCDF4OGHItkY0PuMuzS bRDG10AIoj41D5GDiDtQ9sEcDb2RRh0TGge33RVY7EZQb2czpCMo00KrzDAmVKyYBwqj fvIOAlfyDkvyjcSIN10iK5qX1Mq0gDp4IXdjY7YAehu9pXO7+SF+BUO2ib9Z1YQUg0c6 ziwft+KbLvUWbuAGGEM3SsNccqEsurJff8cZByVs+OSaWoJANHvuiyxKdg1beDmKcO1v BzOUDjMRcBWnEOOiAqp1PCRxm77jGoErwu5PimJEL1H7PTIsw1Sh8I9JttbnzNbT2JDP kZuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xn1H5mTnpg3uTJ1F7m2cMmNE/b/2yxHLD6nEjiGa3WU=; fh=olUnnNbCNO6oc7jUK9qAAYJGpIByyDaZzUxHnQ4XdUk=; b=ggcjrTY7THu5UQW1qvt56FTqiW2/2QqgwJE/mChE+w9NSJ04DqffYOo8C1mAe3BtXT cIJ9J9xCl0IAAD/RyeMpUX20maKNUEcb0G/tkmKX7/628btNnjEyKI0vhzciuYGHuWOd mFSDS5bHzRSrkUubbIxQMBzm36wOZca9G0GC/pAzejmZsw6Ol9K7mHZAWzadxxl+hMjk ddnorNioI/xt9GmNX+ijkRwMowLlww7WtuWjmz4v7HqlZcW8GGhC7Hm2GtrmqFm2NoI7 aE0DXXcAM73FBPPhqhz7KqQ8bhESPLrSYZyEwE7DeLioN+qfpotmo/L4IsndpBc0f/L0 4TtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IZ1SiA1f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id cm4-20020a056a020a0400b005c63a36938fsi1272906pgb.809.2023.12.07.07.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 07:37:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IZ1SiA1f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6285B80BC538; Thu, 7 Dec 2023 07:37:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443511AbjLGPhg (ORCPT + 99 others); Thu, 7 Dec 2023 10:37:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443495AbjLGPhf (ORCPT ); Thu, 7 Dec 2023 10:37:35 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1BEF10CA for ; Thu, 7 Dec 2023 07:37:41 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B9C8C433C9; Thu, 7 Dec 2023 15:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701963461; bh=Y1Iv0HzuzWq6SDtWi2zLmZf5F4ZxjGawlQfjfRbYTcs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IZ1SiA1fMex+Cn7sZ3mGGgEsQKycl5xuVs2tZt/3FPy61GHzqniU+vEQZxwGSH+Tu pI2U/BMzazWiCu8DHJoQ2L+mn+Lt9a0YkM8DCU32dDfqp8yvCtSKz0vXhUG7Q147FX L9SHw78pQUo/ZoowK+uSMn22QGo6vITEtTcQBch+VcBFDF7jGHDxhwqOeoOG0ltCrW 2iU1aglSiOqM5aFENWC+WnUvyYg5vH4jjjVPf3pXa0h82woGpBGEzg9gyO+Agyucd5 tagdj7TpAQ0zolL2oRFRNuHD51gm+ink2JEI/ChIK2Fp4AP3qQD6wc4xPzC9jK6v/i pwitTJCTgzNpw== Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2c9f413d6b2so11240261fa.1; Thu, 07 Dec 2023 07:37:41 -0800 (PST) X-Gm-Message-State: AOJu0Yyuf0GDbXtxsO64+931uIWV/uaxuZ9+K+vtYzeBo4bHkqs6tRYc /woRH7PFwWXiVIq5mwhIgIBrCS+1TsQ0WQYZYN0= X-Received: by 2002:a2e:8053:0:b0:2c9:eda1:cd1 with SMTP id p19-20020a2e8053000000b002c9eda10cd1mr1146473ljg.85.1701963459467; Thu, 07 Dec 2023 07:37:39 -0800 (PST) MIME-Version: 1.0 References: <20231206125433.18420-1-tzimmermann@suse.de> <20231206125433.18420-3-tzimmermann@suse.de> In-Reply-To: <20231206125433.18420-3-tzimmermann@suse.de> From: Ard Biesheuvel Date: Thu, 7 Dec 2023 16:37:28 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] arch/x86: Add for arch_ima_efi_boot_mode To: Thomas Zimmermann Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, bhelgaas@google.com, arnd@arndb.de, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, javierm@redhat.com, linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 07 Dec 2023 07:37:50 -0800 (PST) On Wed, 6 Dec 2023 at 13:54, Thomas Zimmermann wrote: > > The header file contains the macro arch_ima_efi_boot_mode, > which expands to use struct boot_params from . Many > drivers include , but do not use boot parameters. Changes > to bootparam.h or its included headers can easily trigger large, > unnessary rebuilds of the kernel. > > Moving x86's arch_ima_efi_boot_mode to and including > separates that dependency from the rest of the EFI > interfaces. The only user is in ima_efi.c. As the file already declares > a default value for arch_ima_efi_boot_mode, move this define into > asm-generic for all other architectures. > > With arch_ima_efi_boot_mode removed from efi.h, can > later be removed from further x86 header files. > > Signed-off-by: Thomas Zimmermann > --- > arch/x86/include/asm/efi.h | 3 --- > arch/x86/include/asm/ima-efi.h | 12 ++++++++++++ > include/asm-generic/Kbuild | 1 + > include/asm-generic/ima-efi.h | 16 ++++++++++++++++ > security/integrity/ima/ima_efi.c | 5 +---- > 5 files changed, 30 insertions(+), 7 deletions(-) > create mode 100644 arch/x86/include/asm/ima-efi.h > create mode 100644 include/asm-generic/ima-efi.h > > diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h > index c4555b269a1b..99f31176c892 100644 > --- a/arch/x86/include/asm/efi.h > +++ b/arch/x86/include/asm/efi.h > @@ -418,9 +418,6 @@ extern int __init efi_memmap_split_count(efi_memory_desc_t *md, > extern void __init efi_memmap_insert(struct efi_memory_map *old_memmap, > void *buf, struct efi_mem_range *mem); > > -#define arch_ima_efi_boot_mode \ > - ({ extern struct boot_params boot_params; boot_params.secure_boot; }) > - > #ifdef CONFIG_EFI_RUNTIME_MAP > int efi_get_runtime_map_size(void); > int efi_get_runtime_map_desc_size(void); > diff --git a/arch/x86/include/asm/ima-efi.h b/arch/x86/include/asm/ima-efi.h > new file mode 100644 > index 000000000000..3fe054937077 > --- /dev/null > +++ b/arch/x86/include/asm/ima-efi.h > @@ -0,0 +1,12 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _ASM_X86_IMA_EFI_H > +#define _ASM_X86_IMA_EFI_H > + > +#include > + > +#define arch_ima_efi_boot_mode \ > + ({ extern struct boot_params boot_params; boot_params.secure_boot; }) > + Could you please check whether this kludge is still needed now that we no longer have conflicting declarations of boot_params? (i.e., drop the ({ }) and the extern declaration) > +#include > + > +#endif /* _ASM_X86_IMA_EFI_H */ > diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild > index def242528b1d..4fd16e71e8cd 100644 > --- a/include/asm-generic/Kbuild > +++ b/include/asm-generic/Kbuild > @@ -26,6 +26,7 @@ mandatory-y += ftrace.h > mandatory-y += futex.h > mandatory-y += hardirq.h > mandatory-y += hw_irq.h > +mandatory-y += ima-efi.h > mandatory-y += io.h > mandatory-y += irq.h > mandatory-y += irq_regs.h > diff --git a/include/asm-generic/ima-efi.h b/include/asm-generic/ima-efi.h > new file mode 100644 > index 000000000000..f87f5edef440 > --- /dev/null > +++ b/include/asm-generic/ima-efi.h > @@ -0,0 +1,16 @@ > +/* SPDX-License-Identifier: GPL-2.0+ */ > + > +#ifndef __ASM_GENERIC_IMA_EFI_H_ > +#define __ASM_GENERIC_IMA_EFI_H_ > + > +#include > + > +/* > + * Only include this header file from your architecture's . > + */ > + > +#ifndef arch_ima_efi_boot_mode > +#define arch_ima_efi_boot_mode efi_secureboot_mode_unset > +#endif > + > +#endif /* __ASM_GENERIC_FB_H_ */ > diff --git a/security/integrity/ima/ima_efi.c b/security/integrity/ima/ima_efi.c > index 138029bfcce1..56bbee271cec 100644 > --- a/security/integrity/ima/ima_efi.c > +++ b/security/integrity/ima/ima_efi.c > @@ -6,10 +6,7 @@ > #include > #include > #include > - > -#ifndef arch_ima_efi_boot_mode > -#define arch_ima_efi_boot_mode efi_secureboot_mode_unset > -#endif > +#include > > static enum efi_secureboot_mode get_sb_mode(void) > { > -- > 2.43.0 >