mirror of
https://github.com/dynup/kpatch
synced 2024-12-30 09:12:01 +00:00
f5f5479614
On x86_64, GCC generates the following instruction to compute 'empty_zero_page - __START_KERNEL_map' (__phys_addr_nodebug(), used in the implementation of ZERO_PAGE()): 48 ba 00 00 00 00 00 00 00 00 movabs $0x0,%rdx R_X86_64_64 empty_zero_page+0x80000000 __START_KERNEL_map is 0xffffffff80000000. However, the relocation addend becomes wrong in the patch module: 48 ba 00 00 00 00 00 00 00 00 movabs $0x0,%rdx R_X86_64_64 empty_zero_page-0x80000000 Note the sign of the addend. As a result, ZERO_PAGE(0) returns a wrong value in any function touched by the patch, which may lead to memory corruption and difficult-to-debug kernel crashes. The cause is that 'struct rela' uses 'int' for the addend, which is not enough to store such values. r_addend from Elf64_Rela is int64_t (Elf64_Sxword) for that. Let us use 'long' instead of 'int' for the addend in 'struct rela'. v2: * Moved 'addend' field after 'offset' in struct rela to facilitate structure packing (suggested by Kamalesh Babulal). Fixes https://github.com/dynup/kpatch/issues/1064. Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com> |
||
---|---|---|
.. | ||
gcc-plugins | ||
insn | ||
create-diff-object.c | ||
create-klp-module.c | ||
create-kpatch-module.c | ||
kpatch-build | ||
kpatch-elf.c | ||
kpatch-elf.h | ||
kpatch-gcc | ||
kpatch-intermediate.h | ||
kpatch.h | ||
list.h | ||
log.h | ||
lookup.c | ||
lookup.h | ||
Makefile |