Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create-diff-object: fix relocations used for ZERO_PAGE(0)
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 #1064. Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
- Loading branch information
Evgenii Shatokhin
committed
Jan 20, 2020
1 parent
34a45ba
commit f5f5479
Showing
3 changed files
with
12 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters