Skip to content

Commit e41b104

Browse files
zhouchengming1Jiri Kosina
authored andcommitted
livepatch: x86: fix relocation computation with kASLR
With kASLR enabled, old_addr provided by patch module is being shifted accrodingly so that the symbol lookups work. To have module relocations handled properly as well, the same transformation needs to be perfomed on relocation address information. [jkosina@suse.cz: extended / reworded changelog a bit] Reported-by: Cyril B. <cbay@alwaysdata.com> Signed-off-by: Zhou Chengming <zhouchengming1@huawei.com> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 99aaa9c commit e41b104

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎kernel/livepatch/core.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ static int klp_write_object_relocations(struct module *pmod,
294294

295295
for (reloc = obj->relocs; reloc->name; reloc++) {
296296
if (!klp_is_module(obj)) {
297+
298+
#if defined(CONFIG_RANDOMIZE_BASE)
299+
/* If KASLR has been enabled, adjust old value accordingly */
300+
if (kaslr_enabled())
301+
reloc->val += kaslr_offset();
302+
#endif
297303
ret = klp_verify_vmlinux_symbol(reloc->name,
298304
reloc->val);
299305
if (ret)

0 commit comments

Comments
 (0)