Re: [PATCH v2] arm64/module: use plt section indices for relocations

From: Jessica Yu
Date: Mon Nov 05 2018 - 14:49:37 EST


+++ Will Deacon [05/11/18 19:26 +0000]:
On Mon, Nov 05, 2018 at 07:53:23PM +0100, Jessica Yu wrote:
Instead of saving a pointer to the .plt and .init.plt sections to apply
plt-based relocations, save and use their section indices instead.

The mod->arch.{core,init}.plt pointers were problematic for livepatch
because they pointed within temporary section headers (provided by the
module loader via info->sechdrs) that would be freed after module load.
Since livepatch modules may need to apply relocations post-module-load
(for example, to patch a module that is loaded later), using section
indices to offset into the section headers (instead of accessing them
through a saved pointer) allows livepatch modules on arm64 to pass in
their own copy of the section headers to apply_relocate_add() to apply
delayed relocations.

Signed-off-by: Jessica Yu <jeyu@xxxxxxxxxx>
---

v2:

- Do sechdrs[pltsec->plt_shndx].sh_addr instead of pointer math

Note: Addressed Will's comment about the pltsec -> plt_info rename and
removed that change to reduce unnecessary code churn. I didn't include the
Ack's for this reason so let me know if this version is OK as well.

Thanks, Jessica!

Acked-by: Will Deacon <will.deacon@xxxxxxx>

arch/arm64/include/asm/module.h | 8 +++++---
arch/arm64/kernel/module-plts.c | 36 ++++++++++++++++++++----------------
arch/arm64/kernel/module.c | 9 +++++----
3 files changed, 30 insertions(+), 23 deletions(-)

Actually, I guess I should just queue this for 4.21 given that it's
completely self-contained.

Yes, that's fine :-) Then Torsten won't have to include this patch to his
patchset.

Thank you!

Jessica