On some architectures modules (and the kernel itself) may have different ELF properties than native userspace executables. In that case elf_check_arch() can't be used for both. Add a new helper module_elf_check_arch() which architectures can override if they need to check different ELF properties on modules. In a subsequent patch this will be used for PCuABI kernels. No functional change at this point.
Signed-off-by: Kristina Martsenko kristina.martsenko@arm.com --- include/linux/moduleloader.h | 4 ++++ kernel/module/main.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h index 9e09d11ffe5b..56f8d8dd0f6b 100644 --- a/include/linux/moduleloader.h +++ b/include/linux/moduleloader.h @@ -13,6 +13,10 @@ * must be implemented by each architecture. */
+#ifndef module_elf_check_arch +#define module_elf_check_arch(x) elf_check_arch(x) +#endif + /* Adjust arch-specific sections. Return 0 on success. */ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, diff --git a/kernel/module/main.c b/kernel/module/main.c index d02d39c7174e..792ae226af5d 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -1669,7 +1669,7 @@ static int elf_validity_check(struct load_info *info) info->hdr->e_type, ET_REL); goto no_exec; } - if (!elf_check_arch(info->hdr)) { + if (!module_elf_check_arch(info->hdr)) { pr_err("Invalid architecture in ELF header: %u\n", info->hdr->e_machine); goto no_exec;