summaryrefslogtreecommitdiffstats
path: root/arch/arm64/kernel/module-plts.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2018-03-06 17:15:31 +0000
committerWill Deacon <will.deacon@arm.com>2018-03-08 13:49:26 +0000
commit5e8307b9c6f40526f290663e5a4de0f78bb0446a (patch)
tree405c3d4fbb2083f6141061faa5b8acd0cf5b7331 /arch/arm64/kernel/module-plts.c
parente03e61c3173c1079058920210ab40c458a0e0899 (diff)
downloadlinux-5e8307b9c6f40526f290663e5a4de0f78bb0446a.tar.bz2
arm64: module: don't BUG when exceeding preallocated PLT count
When PLTs are emitted at relocation time, we really should not exceed the number that we counted when parsing the relocation tables, and so currently, we BUG() on this condition. However, even though this is a clear bug in this particular piece of code, we can easily recover by failing to load the module. So instead, return 0 from module_emit_plt_entry() if this condition occurs, which is not a valid kernel address, and can hence serve as a flag value that makes the relocation routine bail out. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/kernel/module-plts.c')
-rw-r--r--arch/arm64/kernel/module-plts.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/arm64/kernel/module-plts.c b/arch/arm64/kernel/module-plts.c
index ea640f92fe5a..6bf07c602bd4 100644
--- a/arch/arm64/kernel/module-plts.c
+++ b/arch/arm64/kernel/module-plts.c
@@ -36,7 +36,8 @@ u64 module_emit_plt_entry(struct module *mod, void *loc, const Elf64_Rela *rela,
return (u64)&plt[i - 1];
pltsec->plt_num_entries++;
- BUG_ON(pltsec->plt_num_entries > pltsec->plt_max_entries);
+ if (WARN_ON(pltsec->plt_num_entries > pltsec->plt_max_entries))
+ return 0;
return (u64)&plt[i];
}