]> git.hungrycats.org Git - linux/commitdiff
integrity: Eliminate weak definition of arch_get_secureboot()
authorNathan Chancellor <nathan@kernel.org>
Mon, 9 Mar 2026 20:37:02 +0000 (13:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Sep 2026 11:36:18 +0000 (13:36 +0200)
[ Upstream commit 7caedbb5ade345df0eec0bf01035c780919a9f56 ]

security/integrity/secure_boot.c contains a single __weak function,
which breaks recordmcount when building with clang:

  $ make -skj"$(nproc)" ARCH=powerpc LLVM=1 ppc64_defconfig security/integrity/secure_boot.o
  Cannot find symbol for section 2: .text.
  security/integrity/secure_boot.o: failed

Introduce a Kconfig symbol, CONFIG_HAVE_ARCH_GET_SECUREBOOT, to indicate
that an architecture provides a definition of arch_get_secureboot().
Provide a static inline stub when this symbol is not defined to achieve
the same effect as the __weak function, allowing secure_boot.c to be
removed altogether. Move the s390 definition of arch_get_secureboot()
out of the CONFIG_KEXEC_FILE block to ensure it is always available, as
it does not actually depend on KEXEC_FILE.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 31a6a07eefeb ("integrity: Make arch_ima_get_secureboot integrity-wide")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/Kconfig
arch/powerpc/Kconfig
arch/s390/Kconfig
arch/s390/kernel/ipl.c
include/linux/secure_boot.h
security/integrity/Makefile
security/integrity/secure_boot.c [deleted file]

index 61130b88964b94eda9be06fc06c58a7b63e251ca..ee9fd0150f487c491d1ffa0637a004832481de8b 100644 (file)
@@ -1841,4 +1841,7 @@ config ARCH_WANTS_PRE_LINK_VMLINUX
 config ARCH_HAS_CPU_ATTACK_VECTORS
        bool
 
+config HAVE_ARCH_GET_SECUREBOOT
+       def_bool EFI
+
 endmenu
index 9537a61ebae02dbfe44918232eb6114c2b763387..7b02fe19d26a973cfd482a3b339f670165670191 100644 (file)
@@ -1059,6 +1059,7 @@ config PPC_SECURE_BOOT
        depends on IMA_ARCH_POLICY
        imply IMA_SECURE_AND_OR_TRUSTED_BOOT
        select PSERIES_PLPKS if PPC_PSERIES
+       select HAVE_ARCH_GET_SECUREBOOT
        help
          Systems with firmware secure boot enabled need to define security
          policies to extend secure boot to the OS. This config allows a user
index d6fa31ce9c2cbb726a5fa434d4326a3c74c00e6c..4a663929ebc311e4e00416a9b28f5801f55d998c 100644 (file)
@@ -174,6 +174,7 @@ config S390
        select GENERIC_IOREMAP if PCI
        select HAVE_ALIGNED_STRUCT_PAGE
        select HAVE_ARCH_AUDITSYSCALL
+       select HAVE_ARCH_GET_SECUREBOOT
        select HAVE_ARCH_JUMP_LABEL
        select HAVE_ARCH_JUMP_LABEL_RELATIVE
        select HAVE_ARCH_KASAN
index 2d01a17139387cdd68aec0e3e06dbd6727dae464..3c346b02ceb9532486a7573283a595adaedc9510 100644 (file)
@@ -2388,6 +2388,11 @@ void __no_stack_protector s390_reset_system(void)
        diag_amode31_ops.diag308_reset();
 }
 
+bool arch_get_secureboot(void)
+{
+       return ipl_secure_flag;
+}
+
 #ifdef CONFIG_KEXEC_FILE
 
 int ipl_report_add_component(struct ipl_report *report, struct kexec_buf *kbuf,
@@ -2505,11 +2510,6 @@ out:
        return buf;
 }
 
-bool arch_get_secureboot(void)
-{
-       return ipl_secure_flag;
-}
-
 int ipl_report_free(struct ipl_report *report)
 {
        struct ipl_report_component *comp, *ncomp;
index 3ded3f03655c354e8cf96dc69d691b0b3a4c0308..d17e9235156724b5fd8f77057037306f16af3abe 100644 (file)
 
 #include <linux/types.h>
 
+#ifdef CONFIG_HAVE_ARCH_GET_SECUREBOOT
 /*
  * Returns true if the platform secure boot is enabled.
  * Returns false if disabled or not supported.
  */
 bool arch_get_secureboot(void);
+#else
+static inline bool arch_get_secureboot(void) { return false; }
+#endif
 
 #endif /* _LINUX_SECURE_BOOT_H */
index 548665e2b702e60c318c02db947666b507583f8f..45dfdedbdad48ecd934a6505dae0d1ca8c934a30 100644 (file)
@@ -5,7 +5,7 @@
 
 obj-$(CONFIG_INTEGRITY) += integrity.o
 
-integrity-y := iint.o secure_boot.o
+integrity-y := iint.o
 integrity-$(CONFIG_INTEGRITY_AUDIT) += integrity_audit.o
 integrity-$(CONFIG_INTEGRITY_SIGNATURE) += digsig.o
 integrity-$(CONFIG_INTEGRITY_ASYMMETRIC_KEYS) += digsig_asymmetric.o
diff --git a/security/integrity/secure_boot.c b/security/integrity/secure_boot.c
deleted file mode 100644 (file)
index fc2693c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2026 Red Hat, Inc. All Rights Reserved.
- *
- * Author: Coiby Xu <coxu@redhat.com>
- */
-#include <linux/secure_boot.h>
-
-/*
- * Default weak implementation.
- * Architectures that support secure boot must override this.
- */
-__weak bool arch_get_secureboot(void)
-{
-       return false;
-}