Skip to content

Commit e0328fe

Browse files
Jessica Yuctmarinas
authored andcommitted
arm64/module: set trampoline section flags regardless of CONFIG_DYNAMIC_FTRACE
In the arm64 module linker script, the section .text.ftrace_trampoline is specified unconditionally regardless of whether CONFIG_DYNAMIC_FTRACE is enabled (this is simply due to the limitation that module linker scripts are not preprocessed like the vmlinux one). Normally, for .plt and .text.ftrace_trampoline, the section flags present in the module binary wouldn't matter since module_frob_arch_sections() would assign them manually anyway. However, the arm64 module loader only sets the section flags for .text.ftrace_trampoline when CONFIG_DYNAMIC_FTRACE=y. That's only become problematic recently due to a recent change in binutils-2.35, where the .text.ftrace_trampoline section (along with the .plt section) is now marked writable and executable (WAX). We no longer allow writable and executable sections to be loaded due to commit 5c3a7db ("module: Harden STRICT_MODULE_RWX"), so this is causing all modules linked with binutils-2.35 to be rejected under arm64. Drop the IS_ENABLED(CONFIG_DYNAMIC_FTRACE) check in module_frob_arch_sections() so that the section flags for .text.ftrace_trampoline get properly set to SHF_EXECINSTR|SHF_ALLOC, without SHF_WRITE. Signed-off-by: Jessica Yu <[email protected]> Acked-by: Will Deacon <[email protected]> Acked-by: Ard Biesheuvel <[email protected]> Link: http://lore.kernel.org/r/20200831094651.GA16385@linux-8ccs Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 60295d5 commit e0328fe

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

arch/arm64/kernel/module-plts.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
305305
mod->arch.core.plt_shndx = i;
306306
else if (!strcmp(secstrings + sechdrs[i].sh_name, ".init.plt"))
307307
mod->arch.init.plt_shndx = i;
308-
else if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE) &&
309-
!strcmp(secstrings + sechdrs[i].sh_name,
308+
else if (!strcmp(secstrings + sechdrs[i].sh_name,
310309
".text.ftrace_trampoline"))
311310
tramp = sechdrs + i;
312311
else if (sechdrs[i].sh_type == SHT_SYMTAB)

0 commit comments

Comments
 (0)