kpatch/kpatch-build
Josh Poimboeuf 305ff8a5d8 create-diff-object: include .LCx string literal symbols
A seg fault was reported:

  Program received signal SIGSEGV, Segmentation fault.
  0x00007ffff7f18c8e in __strcmp_avx2 () from /lib64/libc.so.6
  Missing separate debuginfos, use: dnf debuginfo-install elfutils-libelf-0.186-1.fc34.x86_64 zlib-1.2.11-26.fc34.x86_64
  (gdb) bt
  #0  0x00007ffff7f18c8e in __strcmp_avx2 () from /lib64/libc.so.6
  #1  0x000000000040a0f7 in kpatch_is_core_module_symbol (name=0x0) at create-diff-object.c:3060
  #2  0x000000000040a267 in need_dynrela (kelf=0x4669a0, table=0x92af30, sec=0x6d6b20, rela=0x8c7fd0) at create-diff-object.c:3117
  #3  0x000000000040a4cc in kpatch_create_intermediate_sections (kelf=0x4669a0, table=0x92af30, objname=0x7fffffffcfc6 "vmlinux", pmod_name=0x7fffffffd020 "livepatch_a") at create-diff-object.c:3281
  #4  0x000000000040c7c5 in main (argc=8, argv=0x7fffffffca48) at create-diff-object.c:3931

It happened because 'rela->sym->name' was NULL, and
kpatch_is_core_module_symbol() tried to dereference it.

Here's the corresponding relocation:

  Relocation section [455] '.rela.debug_loclists' for section [454] '.debug_loclists' at offset 0xd0478 contains 2432 entries:
    Offset              Type            Value               Addend Name
    ...
    0x000000000000aad6  X86_64_64       000000000000000000     +32 .LC55
    ...

That '.LC55' symbol lives in the following section:

  [104] .rodata.btf_show_end_aggr_type.str1.8 PROGBITS     0000000000000000 00003ef0 00000021  1 AMS    0   0  8

The problem is that the symbol wasn't included in the output file
(though its corresponding section was).  So it got zeroed by
kpatch_elf_teardown(), which was designed to trigger seg faults to help
find bugs like this.

The string literal sections which hold the '.LCx' string symbols are
already being included.  Include their symbols as well.

Fixes #1257.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2022-04-06 13:26:09 -07:00
..
gcc-plugins gcc-plugin: GCC 10 - update local/non local insn names 2020-06-12 13:27:06 +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: include .LCx string literal symbols 2022-04-06 13:26:09 -07:00
create-klp-module.c kpatch-build: Add missing allocation failure checks 2022-01-14 07:32:54 -08:00
create-kpatch-module.c kpatch-elf: pass new ELF output file mode to kpatch_write_output_elf() 2020-09-25 09:30:13 -04:00
kpatch-build kpatch-build: introduce ability to ignore distro-specific checks 2022-01-21 17:29:53 +02:00
kpatch-cc kpatch-build: clang support 2021-02-17 12:59:51 +01:00
kpatch-elf.c kpatch-elf: symtab_shndx support 2022-03-02 09:26:29 +01:00
kpatch-elf.h kpatch-elf: symtab_shndx support 2022-03-02 09:26:29 +01:00
kpatch-intermediate.h lookup: rename 'pos' to 'sympos' 2020-04-06 15:18:58 -05: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 Fix sym->type condition in locals_match() 2022-02-03 11:59:24 +01:00
lookup.h Switch to per-file lookup table pointers. 2021-08-17 09:37:44 +02:00
Makefile Merge pull request #1233 from omatiusha/master 2022-02-14 08:57:36 -05:00