Skip to content

Commit

Permalink
HACK: postpone kelf_patched teardown
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sm00th committed Feb 14, 2022
1 parent 35d48eb commit 656e776
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions kpatch-build/create-diff-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -3936,6 +3936,13 @@ int main(int argc, char *argv[])
/* this is destructive to kelf_patched */
kpatch_migrate_included_elements(kelf_patched, &kelf_out);

kpatch_no_sibling_calls_ppc64le(kelf_out);

/* create strings, patches, and dynrelas sections */
kpatch_create_strings_elements(kelf_out);
kpatch_create_patches_sections(kelf_out, lookup, parent_name);
kpatch_create_intermediate_sections(kelf_out, lookup, parent_name, patch_name);

/*
* Teardown kelf_patched since we shouldn't access sections or symbols
* through it anymore. Don't free however, since our section and symbol
Expand All @@ -3944,12 +3951,6 @@ int main(int argc, char *argv[])
*/
kpatch_elf_teardown(kelf_patched);

kpatch_no_sibling_calls_ppc64le(kelf_out);

/* create strings, patches, and dynrelas sections */
kpatch_create_strings_elements(kelf_out);
kpatch_create_patches_sections(kelf_out, lookup, parent_name);
kpatch_create_intermediate_sections(kelf_out, lookup, parent_name, patch_name);
kpatch_create_kpatch_arch_section(kelf_out, parent_name);
kpatch_create_callbacks_objname_rela(kelf_out, parent_name);
kpatch_build_strings_section_data(kelf_out);
Expand Down

0 comments on commit 656e776

Please sign in to comment.