]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
of: kexec: Mark ima_{free,stable}_kexec_buffer() as __init
authorNathan Chancellor <nathan@kernel.org>
Tue, 5 Sep 2023 20:36:11 +0000 (13:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Sep 2023 10:22:30 +0000 (12:22 +0200)
This commit has no direct upstream equivalent.

After commit d48016d74836 ("mm,ima,kexec,of: use memblock_free_late from
ima_free_kexec_buffer") in 5.15, there is a modpost warning for certain
configurations:

  WARNING: modpost: vmlinux.o(.text+0xb14064): Section mismatch in reference from the function ima_free_kexec_buffer() to the function .init.text:__memblock_free_late()
  The function ima_free_kexec_buffer() references
  the function __init __memblock_free_late().
  This is often because ima_free_kexec_buffer lacks a __init
  annotation or the annotation of __memblock_free_late is wrong.

In mainline, there is no issue because ima_free_kexec_buffer() is marked
as __init, which was done as part of commit b69a2afd5afc ("x86/kexec:
Carry forward IMA measurement log on kexec") in 6.0, which is not
suitable for stable.

Mark ima_free_kexec_buffer() and its single caller
ima_load_kexec_buffer() as __init in 5.15, as ima_load_kexec_buffer() is
only called from ima_init(), which is __init, clearing up the warning.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/of/kexec.c
include/linux/of.h
security/integrity/ima/ima.h
security/integrity/ima/ima_kexec.c

index 3a07cc58e7d7a408dc6fc08b7f3051aa6df34e13..d10fd54415c2c2366a870496c45929c8416aa232 100644 (file)
@@ -165,7 +165,7 @@ int ima_get_kexec_buffer(void **addr, size_t *size)
 /**
  * ima_free_kexec_buffer - free memory used by the IMA buffer
  */
-int ima_free_kexec_buffer(void)
+int __init ima_free_kexec_buffer(void)
 {
        int ret;
        unsigned long addr;
index 140671cb746a29e5e3cfd4cbf25fff45ff8b0399..6f15e8b0f9d108a0d245a7ee87d9212010e57935 100644 (file)
@@ -574,7 +574,7 @@ void *of_kexec_alloc_and_setup_fdt(const struct kimage *image,
                                   unsigned long initrd_len,
                                   const char *cmdline, size_t extra_fdt_size);
 int ima_get_kexec_buffer(void **addr, size_t *size);
-int ima_free_kexec_buffer(void);
+int __init ima_free_kexec_buffer(void);
 #else /* CONFIG_OF */
 
 static inline void of_core_init(void)
index be965a8715e4e2404120b408ab168fc17a81a5a0..0afe413dda683ab09ff605b3dbfc51f6c414a964 100644 (file)
@@ -122,7 +122,7 @@ struct ima_kexec_hdr {
 extern const int read_idmap[];
 
 #ifdef CONFIG_HAVE_IMA_KEXEC
-void ima_load_kexec_buffer(void);
+void __init ima_load_kexec_buffer(void);
 #else
 static inline void ima_load_kexec_buffer(void) {}
 #endif /* CONFIG_HAVE_IMA_KEXEC */
index f799cc278a9a84e7c61cef2c8d96cca52ecc5e68..f3b10851bbbfd111eba175889f7cb5ab44052146 100644 (file)
@@ -137,7 +137,7 @@ void ima_add_kexec_buffer(struct kimage *image)
 /*
  * Restore the measurement list from the previous kernel.
  */
-void ima_load_kexec_buffer(void)
+void __init ima_load_kexec_buffer(void)
 {
        void *kexec_buffer = NULL;
        size_t kexec_buffer_size = 0;