Message ID | 20200707114608.24197-1-richard.peng@oppo.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm64/module-plts: Consider the special case where plt_max_entries is 0 | expand |
[+Ard] On Tue, Jul 07, 2020 at 07:46:08AM -0400, Peng Hao wrote: > If plt_max_entries is 0, a warning is triggered. > WARNING: CPU: 200 PID: 3000 at arch/arm64/kernel/module-plts.c:97 module_emit_plt_entry+0xa4/0x150 Which kernel are you seeing this with? There is a PLT-related change in for-next/core, and I'd like to rule if out if possible. > Signed-off-by: Peng Hao <richard.peng@oppo.com> > --- > arch/arm64/kernel/module-plts.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/module-plts.c b/arch/arm64/kernel/module-plts.c > index 65b08a74aec6..1868c9ac13f2 100644 > --- a/arch/arm64/kernel/module-plts.c > +++ b/arch/arm64/kernel/module-plts.c > @@ -79,7 +79,8 @@ u64 module_emit_plt_entry(struct module *mod, Elf64_Shdr *sechdrs, > int i = pltsec->plt_num_entries; > int j = i - 1; > u64 val = sym->st_value + rela->r_addend; > - > + if (pltsec->plt_max_entries == 0) > + return 0; Hmm, but if there aren't any PLTs then how do we end up here? Will
On Wed, 8 Jul 2020 at 11:25, Will Deacon <will@kernel.org> wrote: > > [+Ard] > > On Tue, Jul 07, 2020 at 07:46:08AM -0400, Peng Hao wrote: > > If plt_max_entries is 0, a warning is triggered. > > WARNING: CPU: 200 PID: 3000 at arch/arm64/kernel/module-plts.c:97 module_emit_plt_entry+0xa4/0x150 > > Which kernel are you seeing this with? There is a PLT-related change in > for-next/core, and I'd like to rule if out if possible. > > > Signed-off-by: Peng Hao <richard.peng@oppo.com> > > --- > > arch/arm64/kernel/module-plts.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/kernel/module-plts.c b/arch/arm64/kernel/module-plts.c > > index 65b08a74aec6..1868c9ac13f2 100644 > > --- a/arch/arm64/kernel/module-plts.c > > +++ b/arch/arm64/kernel/module-plts.c > > @@ -79,7 +79,8 @@ u64 module_emit_plt_entry(struct module *mod, Elf64_Shdr *sechdrs, > > int i = pltsec->plt_num_entries; > > int j = i - 1; > > u64 val = sym->st_value + rela->r_addend; > > - > > + if (pltsec->plt_max_entries == 0) > > + return 0; > > Hmm, but if there aren't any PLTs then how do we end up here? > Indeed. module_emit_plt_entry() is only invoked if we encounter a call or jump relocation that is out of range, and so we failed to allocate enough PLT entries in module_frob_arch_sections() if you are entering module_emit_plt_entry() with max_entries set to 0x0. The only other way to trigger this is when the .text section of your module is so large that branches go out of range, but PLTs won't help there.
diff --git a/arch/arm64/kernel/module-plts.c b/arch/arm64/kernel/module-plts.c index 65b08a74aec6..1868c9ac13f2 100644 --- a/arch/arm64/kernel/module-plts.c +++ b/arch/arm64/kernel/module-plts.c @@ -79,7 +79,8 @@ u64 module_emit_plt_entry(struct module *mod, Elf64_Shdr *sechdrs, int i = pltsec->plt_num_entries; int j = i - 1; u64 val = sym->st_value + rela->r_addend; - + if (pltsec->plt_max_entries == 0) + return 0; if (is_forbidden_offset_for_adrp(&plt[i].adrp)) i++;
If plt_max_entries is 0, a warning is triggered. WARNING: CPU: 200 PID: 3000 at arch/arm64/kernel/module-plts.c:97 module_emit_plt_entry+0xa4/0x150 Signed-off-by: Peng Hao <richard.peng@oppo.com> --- arch/arm64/kernel/module-plts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)