Skip to content

Conversation

@jpoimboe
Copy link
Member

Add build caching and flesh out kpatch-build so that it's a one-step process.

This is just a first step, I'll have much better makefiles and user interface soon.

This makes it somewhat easy to use.  From the root git dir, just:

  sudo scripts/kpatch-build ~/foo.patch

and it'll take care of everything, eventually spitting out the base
module (kpatch.ko) and the hotpatch module kpatch-foo.ko.

This is still all very crude, but a better user interface is coming
soon.
@jpoimboe
Copy link
Member Author

Added a commit to clarify that kpatch should work on non-Fedora

Organize the files functionally:
- kmod/core: core kmod source
- kmod/patch: patch kmod source
- kpatch: kpatch script
- kpatch-build: kpatch build script and supporting tools
- contrib: distro-related files
Saves about 2G disk space per kernel version
sjenning added a commit that referenced this pull request Feb 13, 2014
@sjenning sjenning merged commit c8b41f8 into dynup:master Feb 13, 2014
@jpoimboe jpoimboe deleted the usability branch February 13, 2014 21:27
jpoimboe pushed a commit to jpoimboe/kpatch that referenced this pull request Feb 6, 2019
ppc64le: Add test object for section addralign
sm00th added a commit to sm00th/kpatch that referenced this pull request Feb 14, 2022
Yet another hack, which needs to be addressed properly. Without this create-diff-object segfaults in kpatch_is_core_module_symbol() trying
to compare rela->sym->name which has been zeroed by kelf_patched teardown.

 #0  0x00007ffff7f10c0e in __strcmp_avx2 () from /lib64/libc.so.6
 dynup#1  0x000000000040a09d in kpatch_is_core_module_symbol (name=0x0)
     at create-diff-object.c:3130
 dynup#2  0x000000000040a209 in need_dynrela (table=0x95c52c80,
     sec=0x95c52300, rela=0xa7648330)
     at create-diff-object.c:3186
 dynup#3  0x000000000040a463 in kpatch_create_intermediate_sections
     (kelf=0x4dbc940,
         table=0x95c52c80, objname=0x7fffffffd8a1 "vmlinux",
             pmod_name=0x7fffffffd8f9
             "livepatch_0001_cmdline_test_patch")
         at create-diff-object.c:3350
 dynup#4  0x000000000040c206 in main (argc=8, argv=0x7fffffffd428) at
     create-diff-object.c:3954

Signed-off-by: Artem Savkov <asavkov@redhat.com>
jpoimboe added a commit to jpoimboe/kpatch that referenced this pull request Apr 6, 2022
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
  dynup#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
  dynup#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 dynup#1257.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
jpoimboe added a commit to jpoimboe/kpatch that referenced this pull request Apr 6, 2022
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
  dynup#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
  dynup#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 dynup#1257.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants