kpatch/kpatch-build
Evgenii Shatokhin f5f5479614 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 https://github.com/dynup/kpatch/issues/1064.

Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
2020-01-20 11:41:01 +03:00
..
gcc-plugins gcc-plugin: Include additional header for GCC 8 2018-05-30 19:39:48 +05:30
insn insn: get it to compile in create-diff-object 2014-05-30 15:19:57 -05:00
create-diff-object.c create-diff-object: fix relocations used for ZERO_PAGE(0) 2020-01-20 11:41:01 +03:00
create-klp-module.c create-klp-module: check symtab in main() 2019-08-05 12:10:47 +02:00
create-kpatch-module.c create-kpatch-module: check symtab in main() 2019-08-05 12:10:47 +02:00
kpatch-build kpatch-build: replace all '-' to '_' in KOBJFILE_NAME 2019-12-30 17:48:14 +08:00
kpatch-elf.c create-diff-object: fix relocations used for ZERO_PAGE(0) 2020-01-20 11:41:01 +03:00
kpatch-elf.h create-diff-object: fix relocations used for ZERO_PAGE(0) 2020-01-20 11:41:01 +03:00
kpatch-gcc Making kpatch-build compatible with custom gcc names 2019-05-09 19:15:11 +02:00
kpatch-intermediate.h create-klp-module: get rid of redundant kpatch_relocation.offset field 2017-11-09 19:16:14 -06:00
kpatch.h kpatch-build: add exit status enum 2018-06-15 07:11:48 -04:00
list.h new .fixup group size algorithm 2014-09-15 14:54:57 -05:00
log.h kpatch-build: add exit status enum 2018-06-15 07:11:48 -04:00
lookup.c Make symvers reading code more flexible. 2019-10-25 14:17:11 +02:00
lookup.h kpatch-build: use symbol table instead of kobject 2018-05-18 09:24:40 +02:00
Makefile ppc64le: fix gcc-plugin installation 2018-04-19 10:16:37 +02:00