summaryrefslogtreecommitdiffstats
path: root/tools/objtool/check.c
diff options
context:
space:
mode:
authorMichal Kubecek <mkubecek@suse.cz>2023-01-18 11:52:15 +0100
committerPeter Zijlstra <peterz@infradead.org>2023-01-21 10:50:18 +0100
commit03d7a1053cf72372be22b43faada5bca12ff183d (patch)
tree3903eb97e31a26d63bbb21f6bcf608f6f4ba731f /tools/objtool/check.c
parentobjtool: Fix memory leak in create_static_call_sections() (diff)
downloadlinux-03d7a1053cf72372be22b43faada5bca12ff183d.tar.xz
linux-03d7a1053cf72372be22b43faada5bca12ff183d.zip
objtool: Check that module init/exit function is an indirect call target
Some out-of-tree modules still do not use module_init() / module_exit() macros and simply create functions with magic names init_module() and cleanup_module() instead. As a result, these functions are not recognized as indirect call targets by objtool and such module fails to load into an IBT enabled kernel. This old way is not even documented any more but it is cleaner to issue a warning than to let the module fail on load without obvious reason. Signed-off-by: Michal Kubecek <mkubecek@suse.cz> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20230118105215.B9DA960514@lion.mk-sys.cz
Diffstat (limited to '')
-rw-r--r--tools/objtool/check.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index cab1a162781c..7c40bd51c75a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -847,8 +847,15 @@ static int create_ibt_endbr_seal_sections(struct objtool_file *file)
list_for_each_entry(insn, &file->endbr_list, call_node) {
int *site = (int *)sec->data->d_buf + idx;
+ struct symbol *sym = insn->sym;
*site = 0;
+ if (opts.module && sym && sym->type == STT_FUNC &&
+ insn->offset == sym->offset &&
+ (!strcmp(sym->name, "init_module") ||
+ !strcmp(sym->name, "cleanup_module")))
+ WARN("%s(): not an indirect call target", sym->name);
+
if (elf_add_reloc_to_insn(file->elf, sec,
idx * sizeof(int),
R_X86_64_PC32,