ARM: module: recognize unwind exit sections
authorMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
Fri, 7 Jun 2019 10:49:12 +0000 (12:49 +0200)
committerJessica Yu <jeyu@kernel.org>
Mon, 24 Jun 2019 12:05:10 +0000 (14:05 +0200)
In addition to the prefix ".exit", ".ARM.extab.exit" and ".ARM.exidx.exit"
must be recognized as exit sections as well. Otherwise, loading modules can
fail without CONFIG_MODULE_UNLOAD depending on the memory layout, when
relocations for the unwind sections refer to the .exit.text section:

  imx_sdma: section 16 reloc 0 sym '': relocation 42 out of range
  (0x7f015260 -> 0xc0f5a5e8)

where 0x7F000000 is the module load area and 0xC0000000 is the vmalloc
area. Relocation 42 refers to R_ARM_PREL31, which is limited to signed
31bit offsets.

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

index 3ff571c2c71ce42f47f31730a477f787f4ff91ee..692001aabb0f557f1eb9338eeec4f4ec1c1c5e18 100644 (file)
@@ -58,6 +58,13 @@ void *module_alloc(unsigned long size)
 }
 #endif
 
+bool module_exit_section(const char *name)
+{
+       return strstarts(name, ".exit") ||
+               strstarts(name, ".ARM.extab.exit") ||
+               strstarts(name, ".ARM.exidx.exit");
+}
+
 int
 apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
               unsigned int relindex, struct module *module)