arm64/module: use plt section indices for relocations
authorJessica Yu <jeyu@kernel.org>
Mon, 5 Nov 2018 18:53:23 +0000 (19:53 +0100)
committerWill Deacon <will.deacon@arm.com>
Tue, 20 Nov 2018 11:38:26 +0000 (11:38 +0000)
commitc8ebf64eab743130fe404dc6679c2ff0cbc01615
tree5fbae96f2dbb03d1ea65fa778ba96455c3ac4eab
parentc55191e96caa9d787e8f682c5e525b7f8172a3b4
arm64/module: use plt section indices for relocations

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.

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/include/asm/module.h
arch/arm64/kernel/module-plts.c
arch/arm64/kernel/module.c