]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
module: allow arch overrides for .exit section names
authorMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
Fri, 7 Jun 2019 10:49:11 +0000 (12:49 +0200)
committerJessica Yu <jeyu@kernel.org>
Mon, 24 Jun 2019 12:00:32 +0000 (14:00 +0200)
Some archs like ARM store unwind information for .exit.text in sections
with unusual names. As this unwind information refers to .exit.text, it
must not be loaded when .exit.text is not loaded (when CONFIG_MODULE_UNLOAD
is unset); otherwise, loading a module can fail due to relocation failures.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
include/linux/moduleloader.h
kernel/module.c

index 31013c2effd3d5c7b148d601dff665e8ed10e7b1..5229c18025e97166245b7eb048fc8903d14b07e5 100644 (file)
@@ -29,6 +29,11 @@ void *module_alloc(unsigned long size);
 /* Free memory returned from module_alloc. */
 void module_memfree(void *module_region);
 
+/* Determines if the section name is an exit section (that is only used during
+ * module unloading)
+ */
+bool module_exit_section(const char *name);
+
 /*
  * Apply the given relocation to the (simplified) ELF.  Return -error
  * or 0.
index 41258bab24f119d812bf16b1b661caa48fb1246d..537c456ce3ee002e3f5907eaafa62f477534d4b3 100644 (file)
@@ -2748,6 +2748,11 @@ void * __weak module_alloc(unsigned long size)
        return vmalloc_exec(size);
 }
 
+bool __weak module_exit_section(const char *name)
+{
+       return strstarts(name, ".exit");
+}
+
 #ifdef CONFIG_DEBUG_KMEMLEAK
 static void kmemleak_load_module(const struct module *mod,
                                 const struct load_info *info)
@@ -2937,7 +2942,7 @@ static int rewrite_section_headers(struct load_info *info, int flags)
 
 #ifndef CONFIG_MODULE_UNLOAD
                /* Don't load .exit sections */
-               if (strstarts(info->secstrings+shdr->sh_name, ".exit"))
+               if (module_exit_section(info->secstrings+shdr->sh_name))
                        shdr->sh_flags &= ~(unsigned long)SHF_ALLOC;
 #endif
        }