diff --git a/0001-support-compile-kpatch-on-aarch64.patch b/0001-support-compile-kpatch-on-aarch64.patch index 603b86c97a3e24631d478ca804cd52f8d85ca644..ae5e4e88946e561f2ee73810f81cdcd4b751c7c7 100644 --- a/0001-support-compile-kpatch-on-aarch64.patch +++ b/0001-support-compile-kpatch-on-aarch64.patch @@ -1,35 +1,36 @@ -From 33c4d7a2a31ca10ce943d7ab0603bd814f4ac530 Mon Sep 17 00:00:00 2001 +From 1281e03a115ee04e8ddea9f88d0e4e16b2e5ce57 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Thu, 20 Dec 2018 04:55:38 +0000 -Subject: [PATCH 01/17] support compile kpatch on aarch64 +Subject: [PATCH 01/21] support compile kpatch on aarch64 delete __x86_64__ to support compile kpatch on aarch64. Signed-off-by: Zhipeng Xie --- - kpatch-build/Makefile | 3 +++ + kpatch-build/Makefile | 4 ++++ kpatch-build/create-diff-object.c | 14 +------------- - 2 files changed, 4 insertions(+), 13 deletions(-) + 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/kpatch-build/Makefile b/kpatch-build/Makefile -index 232b336..974e0f2 100644 +index 7505e07..8efae94 100644 --- a/kpatch-build/Makefile +++ b/kpatch-build/Makefile -@@ -12,6 +12,9 @@ SOURCES = create-diff-object.c kpatch-elf.c \ - ifeq ($(ARCH),x86_64) +@@ -14,6 +14,10 @@ ifeq ($(ARCH),x86_64) SOURCES += insn/insn.c insn/inat.c INSN = insn/insn.o insn/inat.o + insn/%.o: CFLAGS := $(filter-out -Wconversion, $(CFLAGS)) +else ifeq ($(ARCH),aarch64) +SOURCES += insn/insn.c insn/inat.c +INSN = insn/insn.o insn/inat.o ++insn/%.o: CFLAGS := $(filter-out -Wconversion, $(CFLAGS)) else ifeq ($(ARCH),ppc64le) SOURCES += gcc-plugins/ppc64le-plugin.c PLUGIN = gcc-plugins/ppc64le-plugin.so diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index c9d2cc6..7b1deb0 100644 +index aedd07d..2707cdb 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -470,7 +470,6 @@ out: +@@ -475,7 +475,6 @@ out: log_debug("section %s has changed\n", sec->name); } @@ -37,7 +38,7 @@ index c9d2cc6..7b1deb0 100644 /* * Determine if a section has changed only due to a WARN* or might_sleep * macro call's embedding of the line number into an instruction operand. -@@ -581,7 +580,7 @@ static int kpatch_line_macro_change_only(struct section *sec) +@@ -586,7 +585,7 @@ static int kpatch_line_macro_change_only(struct section *sec) return 1; } @@ -46,7 +47,7 @@ index c9d2cc6..7b1deb0 100644 #define PPC_INSTR_LEN 4 #define PPC_RA_OFFSET 16 -@@ -647,11 +646,6 @@ static int kpatch_line_macro_change_only(struct section *sec) +@@ -652,11 +651,6 @@ static int kpatch_line_macro_change_only(struct section *sec) return 1; } @@ -58,7 +59,7 @@ index c9d2cc6..7b1deb0 100644 #endif static void kpatch_compare_sections(struct list_head *seclist) -@@ -1202,7 +1196,6 @@ static void kpatch_compare_correlated_elements(struct kpatch_elf *kelf) +@@ -1215,7 +1209,6 @@ static void kpatch_compare_correlated_elements(struct kpatch_elf *kelf) kpatch_compare_symbols(&kelf->symbols); } @@ -66,7 +67,7 @@ index c9d2cc6..7b1deb0 100644 static void rela_insn(const struct section *sec, const struct rela *rela, struct insn *insn) { -@@ -1226,7 +1219,6 @@ static void rela_insn(const struct section *sec, const struct rela *rela, +@@ -1239,7 +1232,6 @@ static void rela_insn(const struct section *sec, const struct rela *rela, return; } } @@ -74,7 +75,7 @@ index c9d2cc6..7b1deb0 100644 static bool is_callback_section(struct section *sec) { -@@ -1771,7 +1763,6 @@ static int jump_table_group_size(struct kpatch_elf *kelf, int offset) +@@ -1785,7 +1777,6 @@ static int jump_table_group_size(struct kpatch_elf *kelf, int offset) return size; } @@ -82,7 +83,7 @@ index c9d2cc6..7b1deb0 100644 static int parainstructions_group_size(struct kpatch_elf *kelf, int offset) { static int size = 0; -@@ -1806,7 +1797,6 @@ static int smp_locks_group_size(struct kpatch_elf *kelf, int offset) +@@ -1820,7 +1811,6 @@ static int smp_locks_group_size(struct kpatch_elf *kelf, int offset) { return 4; } @@ -90,7 +91,7 @@ index c9d2cc6..7b1deb0 100644 #ifdef __powerpc64__ static int fixup_entry_group_size(struct kpatch_elf *kelf, int offset) { -@@ -1901,7 +1891,6 @@ static struct special_section special_sections[] = { +@@ -1915,7 +1905,6 @@ static struct special_section special_sections[] = { .name = "__jump_table", .group_size = jump_table_group_size, }, @@ -98,7 +99,7 @@ index c9d2cc6..7b1deb0 100644 { .name = ".smp_locks", .group_size = smp_locks_group_size, -@@ -1914,7 +1903,6 @@ static struct special_section special_sections[] = { +@@ -1928,7 +1917,6 @@ static struct special_section special_sections[] = { .name = ".altinstructions", .group_size = altinstructions_group_size, }, @@ -108,4 +109,3 @@ index c9d2cc6..7b1deb0 100644 .name = "__ftr_fixup", -- 2.18.1 - diff --git a/0002-kpatch-build-support-build-patch-for-aarch64.patch b/0002-kpatch-build-support-build-patch-for-aarch64.patch index 033602edfe45a05dd70adf3080bfac57a1c3c042..0e986dd2089ce17a7334c25dfc67f376f25f92e1 100644 --- a/0002-kpatch-build-support-build-patch-for-aarch64.patch +++ b/0002-kpatch-build-support-build-patch-for-aarch64.patch @@ -1,7 +1,7 @@ -From 6dd77e9f5bc044a1f80ad89bb9d7f60756b39755 Mon Sep 17 00:00:00 2001 +From 92bb331ce71cfc33d933ebeabdbe9b5721c0ec75 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Wed, 26 Feb 2020 07:09:50 -0500 -Subject: [PATCH 02/17] kpatch-build: support build patch for aarch64 +Subject: [PATCH 02/21] kpatch-build: support build patch for aarch64 use R_AARCH64_ABS64 for aarch64 @@ -16,14 +16,14 @@ support cross compile for aarch64 Signed-off-by: Zhipeng Xie --- - kpatch-build/create-diff-object.c | 216 ++++++++++++++++++++++++---- + kpatch-build/create-diff-object.c | 191 +++++++++++++++++++++++++--- kpatch-build/create-kpatch-module.c | 24 +++- - kpatch-build/kpatch-build | 116 ++++++++++++++- + kpatch-build/kpatch-build | 116 ++++++++++++++++- kpatch-build/kpatch-gcc | 4 +- - 4 files changed, 319 insertions(+), 41 deletions(-) + 4 files changed, 306 insertions(+), 29 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 7b1deb0..58789f1 100644 +index 2707cdb..7a27b58 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -76,6 +76,31 @@ enum subsection { @@ -58,7 +58,7 @@ index 7b1deb0..58789f1 100644 /******************* * Data structures * ****************/ -@@ -647,6 +672,67 @@ static int kpatch_line_macro_change_only(struct section *sec) +@@ -652,6 +677,67 @@ static int kpatch_line_macro_change_only(struct section *sec) return 1; } #endif @@ -126,7 +126,7 @@ index 7b1deb0..58789f1 100644 static void kpatch_compare_sections(struct list_head *seclist) { -@@ -662,7 +748,16 @@ static void kpatch_compare_sections(struct list_head *seclist) +@@ -667,7 +753,16 @@ static void kpatch_compare_sections(struct list_head *seclist) /* exclude WARN-only, might_sleep changes */ list_for_each_entry(sec, seclist, list) { @@ -144,7 +144,7 @@ index 7b1deb0..58789f1 100644 log_debug("reverting macro / line number section %s status to SAME\n", sec->name); sec->status = SAME; -@@ -722,6 +817,8 @@ static void kpatch_compare_correlated_symbol(struct symbol *sym) +@@ -727,6 +822,8 @@ static void kpatch_compare_correlated_symbol(struct symbol *sym) if ((sym2->sec->twin && sym2->sec->twin->ignore) || kpatch_subsection_changed(sym1->sec, sym2->sec)) sym->status = CHANGED; @@ -153,90 +153,72 @@ index 7b1deb0..58789f1 100644 else DIFF_FATAL("symbol changed sections: %s", sym1->name); } -@@ -1289,22 +1386,22 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf) +@@ -1302,9 +1399,8 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf) continue; } -#ifdef __powerpc64__ add_off = 0; -#else -- if (rela->type == R_X86_64_PC32 || -- rela->type == R_X86_64_PLT32) { -- struct insn insn; -- rela_insn(sec, rela, &insn); -- add_off = (long)insn.next_byte - -- (long)sec->base->data->d_buf - -- rela->offset; -- } else if (rela->type == R_X86_64_64 || -- rela->type == R_X86_64_32S) -- add_off = 0; -- else -- continue; ++ if (arch == EM_X86_64) { + if (rela->type == R_X86_64_PC32 || + rela->type == R_X86_64_PLT32) { + struct insn insn; +@@ -1317,7 +1413,7 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf) + add_off = 0; + else + continue; -#endif -+ if (arch == EM_X86_64) { -+ if (rela->type == R_X86_64_PC32 || -+ rela->type == R_X86_64_PLT32) { -+ struct insn insn; -+ rela_insn(sec, rela, &insn); -+ add_off = (long)insn.next_byte - -+ (long)sec->base->data->d_buf - -+ rela->offset; -+ } else if (rela->type == R_X86_64_64 || -+ rela->type == R_X86_64_32S) -+ add_off = 0; -+ else -+ continue; -+ } -+ /* add_off is always equal to 0 on arm64 */ ++ } /* * Attempt to replace references to unbundled sections -@@ -2401,7 +2498,7 @@ static void kpatch_create_kpatch_arch_section(struct kpatch_elf *kelf, char *obj +@@ -2415,7 +2511,7 @@ static void kpatch_create_kpatch_arch_section(struct kpatch_elf *kelf, char *obj /* entries[index].sec */ ALLOC_LINK(rela, &karch_sec->rela->relas); rela->sym = sec->secsym; - rela->type = ABSOLUTE_RELA_TYPE; + rela->type = absolute_rela_type; rela->addend = 0; - rela->offset = index * sizeof(struct kpatch_arch) + \ - offsetof(struct kpatch_arch, sec); -@@ -2409,7 +2506,7 @@ static void kpatch_create_kpatch_arch_section(struct kpatch_elf *kelf, char *obj + rela->offset = (unsigned int)(index * sizeof(struct kpatch_arch) + \ + offsetof(struct kpatch_arch, sec)); +@@ -2423,7 +2519,7 @@ static void kpatch_create_kpatch_arch_section(struct kpatch_elf *kelf, char *obj /* entries[index].objname */ ALLOC_LINK(rela, &karch_sec->rela->relas); rela->sym = strsym; - rela->type = ABSOLUTE_RELA_TYPE; + rela->type = absolute_rela_type; rela->addend = offset_of_string(&kelf->strings, objname); - rela->offset = index * sizeof(struct kpatch_arch) + \ - offsetof(struct kpatch_arch, objname); -@@ -2607,7 +2704,7 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, + rela->offset = (unsigned int)(index * sizeof(struct kpatch_arch) + \ + offsetof(struct kpatch_arch, objname)); +@@ -2622,7 +2718,7 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, */ ALLOC_LINK(rela, &relasec->relas); rela->sym = sym; - rela->type = ABSOLUTE_RELA_TYPE; + rela->type = absolute_rela_type; rela->addend = 0; - rela->offset = index * sizeof(*funcs); + rela->offset = (unsigned int)(index * sizeof(*funcs)); -@@ -2617,7 +2714,7 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, +@@ -2632,7 +2728,7 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, */ ALLOC_LINK(rela, &relasec->relas); rela->sym = strsym; - rela->type = ABSOLUTE_RELA_TYPE; + rela->type = absolute_rela_type; rela->addend = offset_of_string(&kelf->strings, sym->name); - rela->offset = index * sizeof(*funcs) + - offsetof(struct kpatch_patch_func, name); -@@ -2628,7 +2725,7 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, + rela->offset = (unsigned int)(index * sizeof(*funcs) + + offsetof(struct kpatch_patch_func, name)); +@@ -2643,7 +2739,7 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, */ ALLOC_LINK(rela, &relasec->relas); rela->sym = strsym; - rela->type = ABSOLUTE_RELA_TYPE; + rela->type = absolute_rela_type; rela->addend = objname_offset; - rela->offset = index * sizeof(*funcs) + - offsetof(struct kpatch_patch_func,objname); -@@ -2686,7 +2783,10 @@ static int function_ptr_rela(const struct rela *rela) + rela->offset = (unsigned int)(index * sizeof(*funcs) + + offsetof(struct kpatch_patch_func,objname)); +@@ -2701,7 +2797,10 @@ static int function_ptr_rela(const struct rela *rela) rela_toc->addend == (int)rela_toc->sym->sym.st_value && (rela->type == R_X86_64_32S || rela->type == R_PPC64_TOC16_HA || @@ -248,52 +230,52 @@ index 7b1deb0..58789f1 100644 } static int may_need_dynrela(const struct rela *rela) -@@ -2940,7 +3040,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, +@@ -2955,7 +3054,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, /* add rela to fill in ksyms[index].name field */ ALLOC_LINK(rela2, &ksym_sec->rela->relas); rela2->sym = strsym; - rela2->type = ABSOLUTE_RELA_TYPE; + rela2->type = absolute_rela_type; rela2->addend = offset_of_string(&kelf->strings, rela->sym->name); - rela2->offset = index * sizeof(*ksyms) + \ - offsetof(struct kpatch_symbol, name); -@@ -2948,7 +3048,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, + rela2->offset = (unsigned int)(index * sizeof(*ksyms) + \ + offsetof(struct kpatch_symbol, name)); +@@ -2963,7 +3062,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, /* add rela to fill in ksyms[index].objname field */ ALLOC_LINK(rela2, &ksym_sec->rela->relas); rela2->sym = strsym; - rela2->type = ABSOLUTE_RELA_TYPE; + rela2->type = absolute_rela_type; rela2->addend = offset_of_string(&kelf->strings, sym_objname); - rela2->offset = index * sizeof(*ksyms) + \ - offsetof(struct kpatch_symbol, objname); -@@ -2969,7 +3069,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, + rela2->offset = (unsigned int)(index * sizeof(*ksyms) + \ + offsetof(struct kpatch_symbol, objname)); +@@ -2984,7 +3083,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, ERROR("can't create dynrela for section %s (symbol %s): no bundled or section symbol", sec->name, rela->sym->name); - rela2->type = ABSOLUTE_RELA_TYPE; + rela2->type = absolute_rela_type; rela2->addend = rela->offset; - rela2->offset = index * sizeof(*krelas) + \ - offsetof(struct kpatch_relocation, dest); -@@ -2977,7 +3077,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, + rela2->offset = (unsigned int)(index * sizeof(*krelas) + \ + offsetof(struct kpatch_relocation, dest)); +@@ -2992,7 +3091,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, /* add rela to fill in krelas[index].objname field */ ALLOC_LINK(rela2, &krela_sec->rela->relas); rela2->sym = strsym; - rela2->type = ABSOLUTE_RELA_TYPE; + rela2->type = absolute_rela_type; rela2->addend = offset_of_string(&kelf->strings, objname); - rela2->offset = index * sizeof(*krelas) + \ - offsetof(struct kpatch_relocation, objname); -@@ -2985,7 +3085,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, + rela2->offset = (unsigned int)(index * sizeof(*krelas) + \ + offsetof(struct kpatch_relocation, objname)); +@@ -3000,7 +3099,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, /* add rela to fill in krelas[index].ksym field */ ALLOC_LINK(rela2, &krela_sec->rela->relas); rela2->sym = ksym_sec_sym; - rela2->type = ABSOLUTE_RELA_TYPE; + rela2->type = absolute_rela_type; - rela2->addend = index * sizeof(*ksyms); - rela2->offset = index * sizeof(*krelas) + \ - offsetof(struct kpatch_relocation, ksym); -@@ -3048,7 +3148,7 @@ static void kpatch_create_callbacks_objname_rela(struct kpatch_elf *kelf, char * + rela2->addend = (unsigned int)(index * sizeof(*ksyms)); + rela2->offset = (unsigned int)(index * sizeof(*krelas) + \ + offsetof(struct kpatch_relocation, ksym)); +@@ -3063,7 +3162,7 @@ static void kpatch_create_callbacks_objname_rela(struct kpatch_elf *kelf, char * if (!strcmp(callbackp->name, sec->name)) { ALLOC_LINK(rela, &sec->relas); rela->sym = strsym; @@ -302,15 +284,15 @@ index 7b1deb0..58789f1 100644 rela->addend = objname_offset; rela->offset = callbackp->offset; break; -@@ -3101,6 +3201,7 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf) +@@ -3116,6 +3215,7 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf) /* add rela in .rela__mcount_loc to fill in function pointer */ ALLOC_LINK(rela, &relasec->relas); rela->sym = sym; + if (arch == EM_X86_64) { rela->type = R_X86_64_64; rela->addend = 0; - rela->offset = index * sizeof(void*); -@@ -3136,6 +3237,40 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf) + rela->offset = (unsigned int)(index * sizeof(void*)); +@@ -3151,6 +3251,40 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf) rela->type = R_X86_64_PC32; } @@ -319,7 +301,7 @@ index 7b1deb0..58789f1 100644 + rela->type = R_AARCH64_ABS64; + /* bl <__fentry__> is the second insn */ + rela->addend = 4; -+ rela->offset = index * sizeof(void*); ++ rela->offset = (unsigned int)(index * sizeof(void*)); + + newdata = malloc(sym->sec->data->d_size); + if (!newdata) @@ -351,7 +333,7 @@ index 7b1deb0..58789f1 100644 index++; } -@@ -3334,6 +3469,8 @@ int main(int argc, char *argv[]) +@@ -3349,6 +3483,8 @@ int main(int argc, char *argv[]) char *hint = NULL, *orig_obj, *patched_obj, *parent_name; char *parent_symtab, *mod_symvers, *patch_name, *output_obj; struct sym_compare_type *base_locals, *sym_comp; @@ -360,7 +342,7 @@ index 7b1deb0..58789f1 100644 arguments.debug = 0; argp_parse (&argp, argc, argv, 0, NULL, &arguments); -@@ -3354,6 +3491,13 @@ int main(int argc, char *argv[]) +@@ -3369,6 +3505,13 @@ int main(int argc, char *argv[]) kelf_base = kpatch_elf_open(orig_obj); kelf_patched = kpatch_elf_open(patched_obj); @@ -374,7 +356,7 @@ index 7b1deb0..58789f1 100644 kpatch_compare_elf_headers(kelf_base->elf, kelf_patched->elf); kpatch_check_program_headers(kelf_base->elf); -@@ -3392,7 +3536,12 @@ int main(int argc, char *argv[]) +@@ -3407,7 +3550,12 @@ int main(int argc, char *argv[]) */ kpatch_mark_ignored_sections(kelf_patched); kpatch_compare_correlated_elements(kelf_patched); @@ -388,7 +370,7 @@ index 7b1deb0..58789f1 100644 kpatch_elf_teardown(kelf_base); kpatch_elf_free(kelf_base); -@@ -3452,7 +3601,14 @@ int main(int argc, char *argv[]) +@@ -3467,7 +3615,14 @@ int main(int argc, char *argv[]) kpatch_create_callbacks_objname_rela(kelf_out, parent_name); kpatch_build_strings_section_data(kelf_out); @@ -405,7 +387,7 @@ index 7b1deb0..58789f1 100644 /* * At this point, the set of output sections and symbols is diff --git a/kpatch-build/create-kpatch-module.c b/kpatch-build/create-kpatch-module.c -index 43d6809..6f80831 100644 +index 3d197a7..758630b 100644 --- a/kpatch-build/create-kpatch-module.c +++ b/kpatch-build/create-kpatch-module.c @@ -31,6 +31,17 @@ @@ -433,7 +415,7 @@ index 43d6809..6f80831 100644 - rela->type = R_X86_64_64; + rela->type = absolute_rela_type; rela->addend = dest_offset; - rela->offset = index * sizeof(*dynrelas); + rela->offset = (unsigned int)(index * sizeof(*dynrelas)); /* name */ ALLOC_LINK(rela, &dynsec->rela->relas); @@ -441,8 +423,8 @@ index 43d6809..6f80831 100644 - rela->type = R_X86_64_64; + rela->type = absolute_rela_type; rela->addend = name_offset; - rela->offset = index * sizeof(*dynrelas) + \ - offsetof(struct kpatch_patch_dynrela, name); + rela->offset = (unsigned int)(index * sizeof(*dynrelas) + \ + offsetof(struct kpatch_patch_dynrela, name)); @@ -117,7 +128,7 @@ static void create_dynamic_rela_sections(struct kpatch_elf *kelf, struct section /* objname */ ALLOC_LINK(rela, &dynsec->rela->relas); @@ -450,8 +432,8 @@ index 43d6809..6f80831 100644 - rela->type = R_X86_64_64; + rela->type = absolute_rela_type; rela->addend = objname_offset; - rela->offset = index * sizeof(*dynrelas) + \ - offsetof(struct kpatch_patch_dynrela, objname); + rela->offset = (unsigned int)(index * sizeof(*dynrelas) + \ + offsetof(struct kpatch_patch_dynrela, objname)); @@ -200,6 +211,13 @@ int main(int argc, char *argv[]) childobj = basename(arguments.args[0]); @@ -680,5 +662,4 @@ index 9663290..35d7c1c 100755 if [ "$1" = "-o" ]; then obj="$2" -- -2.18.1 - +2.18.1 \ No newline at end of file diff --git a/0003-create-diff-object-new-static-var-should-be-included.patch b/0003-create-diff-object-new-static-var-should-be-included.patch index 5e5078386c088bb95d23489cf01d38322f39e91a..b4acbec647429d085c2a103cdf857314f2c320f1 100644 --- a/0003-create-diff-object-new-static-var-should-be-included.patch +++ b/0003-create-diff-object-new-static-var-should-be-included.patch @@ -1,7 +1,7 @@ -From 3af07fd0f178a4c6e2ae68207c3fedfd10672e65 Mon Sep 17 00:00:00 2001 +From 4511c2f36744529d0298a4d8e56d0b38c2ea5714 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Tue, 25 Feb 2020 22:44:50 -0500 -Subject: [PATCH 03/17] create-diff-object: new static var should be included +Subject: [PATCH 03/21] create-diff-object: new static var should be included Before this patch, only global variables(no referenced) will be included by kpatch-build. But some macros put some static varibles @@ -18,10 +18,10 @@ Signed-off-by: Zhipeng Xie 1 file changed, 15 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 58789f1..93570df 100644 +index 7a27b58..267bd66 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -1689,6 +1689,20 @@ static void kpatch_include_force_elements(struct kpatch_elf *kelf) +@@ -1702,6 +1702,20 @@ static void kpatch_include_force_elements(struct kpatch_elf *kelf) sym->include = 0; } @@ -42,14 +42,13 @@ index 58789f1..93570df 100644 static int kpatch_include_new_globals(struct kpatch_elf *kelf) { struct symbol *sym; -@@ -3554,6 +3568,7 @@ int main(int argc, char *argv[]) +@@ -3567,6 +3581,7 @@ int main(int argc, char *argv[]) callbacks_exist = kpatch_include_callback_elements(kelf_patched); kpatch_include_force_elements(kelf_patched); new_globals_exist = kpatch_include_new_globals(kelf_patched); + kpatch_include_new_static_var(kelf_patched); + kpatch_include_debug_sections(kelf_patched); kpatch_process_special_sections(kelf_patched); - -- 2.18.1 - diff --git a/0004-livepatch-fix-use-THIS-modname-as-the-name-of-ddebug.patch b/0004-livepatch-fix-use-THIS-modname-as-the-name-of-ddebug.patch index 1a5d168caaf02f420a1385519c4b5a0415467a95..ee2db58a1944f24a81bcf3ca05c8d3cfce149b86 100644 --- a/0004-livepatch-fix-use-THIS-modname-as-the-name-of-ddebug.patch +++ b/0004-livepatch-fix-use-THIS-modname-as-the-name-of-ddebug.patch @@ -1,7 +1,7 @@ -From c03772c4e29473eae68009c12efc182238d103c7 Mon Sep 17 00:00:00 2001 +From b407defcd16f6a8a49ed0f66d4902eb0bc1b2021 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Fri, 2 Nov 2018 17:24:42 +0000 -Subject: [PATCH 04/17] livepatch, fix: use THIS modname as the name of +Subject: [PATCH 04/21] livepatch, fix: use THIS modname as the name of ddebug_table We just want a unique name for every module, so put a _ddebug in @@ -29,4 +29,3 @@ index e12fd50..613d037 100644 #endif -- 2.18.1 - diff --git a/0005-create-diff-object-fix-correlate-static-local-variab.patch b/0005-create-diff-object-fix-correlate-static-local-variab.patch index 1d8c46a38655b1fe8c4f5009ef29739673334b4d..df85099464efc61b591ec0fa6cd2fc3c5b5d1cb4 100644 --- a/0005-create-diff-object-fix-correlate-static-local-variab.patch +++ b/0005-create-diff-object-fix-correlate-static-local-variab.patch @@ -1,7 +1,7 @@ -From 5504f36c6de3abae8a4f7ba11f7a2838ddbc5b58 Mon Sep 17 00:00:00 2001 +From e3a9643c7fa2ac5f8093c8ac578ce9dfd45084c7 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Fri, 2 Nov 2018 17:24:51 +0000 -Subject: [PATCH 05/17] create-diff-object: fix correlate static local +Subject: [PATCH 05/21] create-diff-object: fix correlate static local variables for __param section kpatch-build correlate fail when no sections reference @@ -31,10 +31,10 @@ Signed-off-by: Zhipeng Xie 1 file changed, 4 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 93570df..9f1abc0 100644 +index 267bd66..78f5a7e 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -1094,6 +1094,10 @@ static int kpatch_is_normal_static_local(struct symbol *sym) +@@ -1107,6 +1107,10 @@ static int kpatch_is_normal_static_local(struct symbol *sym) if (is_special_static(sym)) return 0; @@ -47,4 +47,3 @@ index 93570df..9f1abc0 100644 -- 2.18.1 - diff --git a/0006-create-diff-object-don-t-create-dynamic-reloc-for-sy.patch b/0006-create-diff-object-don-t-create-dynamic-reloc-for-sy.patch index 6528070a7cf3e62e98d4d6d622aac6f242e498b5..fd2503b3cd8e11d700a68760162a9cf4b0fab438 100644 --- a/0006-create-diff-object-don-t-create-dynamic-reloc-for-sy.patch +++ b/0006-create-diff-object-don-t-create-dynamic-reloc-for-sy.patch @@ -1,7 +1,7 @@ -From 16aa1e59851c29ce63b18f8ef5c570052c6a95af Mon Sep 17 00:00:00 2001 +From 28a1433cc6342ee48cfea60b755c0e746b9ff548 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Fri, 2 Nov 2018 17:24:58 +0000 -Subject: [PATCH 06/17] create-diff-object: don't create dynamic reloc for +Subject: [PATCH 06/21] create-diff-object: don't create dynamic reloc for symbol exported by patch itself when a patch export a new function, ___kcrctab+xxx has a reloc, @@ -13,10 +13,10 @@ Signed-off-by: Zhipeng Xie 1 file changed, 3 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 9f1abc0..18ed1f7 100644 +index 78f5a7e..2cda233 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -3039,6 +3039,9 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, +@@ -3053,6 +3053,9 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, if (!strcmp(sym_objname, "vmlinux")) continue; @@ -28,4 +28,3 @@ index 9f1abc0..18ed1f7 100644 } -- 2.18.1 - diff --git a/0007-create-diff-object-create-dynamic-relocs-for-changed.patch b/0007-create-diff-object-create-dynamic-relocs-for-changed.patch index 684967a2777e39febdd76dab1f32c05b0ce2bb62..e0865111c6ce278b0d4adbc5a4f328ab1de0c602 100644 --- a/0007-create-diff-object-create-dynamic-relocs-for-changed.patch +++ b/0007-create-diff-object-create-dynamic-relocs-for-changed.patch @@ -1,7 +1,7 @@ -From a743990bb6d871fb8cd5ffe6f78ffaa8d5ee7c0a Mon Sep 17 00:00:00 2001 +From f6d53ba1e5d1b8c8e026bd537235e201f8482065 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Fri, 2 Nov 2018 17:25:38 +0000 -Subject: [PATCH 07/17] create-diff-object: create dynamic relocs for changed +Subject: [PATCH 07/21] create-diff-object: create dynamic relocs for changed functions in this object Currently, we only create dynamic relocs for changed functions of @@ -26,10 +26,10 @@ Signed-off-by: Zhipeng Xie 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 18ed1f7..5cdb97b 100644 +index 2cda233..67c062e 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -2883,6 +2883,14 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, +@@ -2897,6 +2897,14 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, */ if (may_need_dynrela(rela)) toc_rela(rela)->need_dynrela = 1; @@ -44,7 +44,7 @@ index 18ed1f7..5cdb97b 100644 } } -@@ -2965,10 +2973,14 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, +@@ -2979,10 +2987,14 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, /* An unchanged local symbol */ ret = lookup_local_symbol(table, rela->sym->name, &result); @@ -65,4 +65,3 @@ index 18ed1f7..5cdb97b 100644 /* -- 2.18.1 - diff --git a/0008-fix-rodata.str-problem.patch b/0008-fix-rodata.str-problem.patch index 535dc8edf613b6d2ff8aa397a09c6df7f5627f18..3df94f256e96feb5e66b7c6e727b44ef23cf2353 100644 --- a/0008-fix-rodata.str-problem.patch +++ b/0008-fix-rodata.str-problem.patch @@ -1,7 +1,7 @@ -From b356b59eb0f4c21ae927b036a45e573899a59378 Mon Sep 17 00:00:00 2001 +From 10370cef2ef3e690355412048d19a88f81fa465b Mon Sep 17 00:00:00 2001 From: Zhiyu Hu Date: Fri, 28 Dec 2018 07:06:38 +0000 -Subject: [PATCH 08/17] fix rodata.str problem +Subject: [PATCH 08/21] fix rodata.str problem fix some rodata.str problem @@ -11,10 +11,10 @@ Signed-off-by: Zhiyu Hu 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 5cdb97b..643ae3e 100644 +index 67c062e..bb2a803 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -1620,7 +1620,7 @@ static void kpatch_include_standard_elements(struct kpatch_elf *kelf) +@@ -1632,7 +1632,7 @@ static void kpatch_include_standard_elements(struct kpatch_elf *kelf) !strcmp(sec->name, ".toc") || !strcmp(sec->name, ".rodata") || (!strncmp(sec->name, ".rodata.", 8) && @@ -25,4 +25,3 @@ index 5cdb97b..643ae3e 100644 } -- 2.18.1 - diff --git a/0009-livepatch-patch-hook-don-t-active-patch-when-insmod.patch b/0009-livepatch-patch-hook-don-t-active-patch-when-insmod.patch index 2c76e8a23766d6f625f2da1c84c9fcd88017d3cf..b3e533ece4edcd63a94a21520a691dc69e6438cb 100644 --- a/0009-livepatch-patch-hook-don-t-active-patch-when-insmod.patch +++ b/0009-livepatch-patch-hook-don-t-active-patch-when-insmod.patch @@ -1,7 +1,7 @@ -From c14444fc4049048abd445462676576cd8b043ea3 Mon Sep 17 00:00:00 2001 +From 66b833f4de9dca62b97f077df962c3702c919664 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Tue, 25 Feb 2020 23:40:37 -0500 -Subject: [PATCH 09/17] livepatch-patch-hook: don't active patch when insmod +Subject: [PATCH 09/21] livepatch-patch-hook: don't active patch when insmod Don't active patch after loading the patch when DISABLE_AFTER_LOAD is set. @@ -49,4 +49,3 @@ index 17a5e11..894f0ab 100755 if [[ -z "$USERSRCDIR" ]] && [[ "$DISTRO" = ubuntu ]]; then -- 2.18.1 - diff --git a/0010-kpatch-build-enhance-for-out-of-tree-module.patch b/0010-kpatch-build-enhance-for-out-of-tree-module.patch index f1ab2a186311c13af29d6fca6a78ad30435ec56c..cc4122e546e1858504bc308e34be755fe44025a6 100644 --- a/0010-kpatch-build-enhance-for-out-of-tree-module.patch +++ b/0010-kpatch-build-enhance-for-out-of-tree-module.patch @@ -1,7 +1,7 @@ -From a8cf8f9bd90e0e7fde437a59715aa21622fad7b6 Mon Sep 17 00:00:00 2001 +From 8486c25a0b94eb9b415572eec58508204d8e5458 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Wed, 26 Feb 2020 06:44:06 -0500 -Subject: [PATCH 10/17] kpatch-build: enhance for out of tree module +Subject: [PATCH 10/21] kpatch-build: enhance for out of tree module support set USERMODBUILDDIR to build patch for out of tree module. @@ -130,4 +130,3 @@ index 894f0ab..4e38412 100755 readelf -s --wide "$KOBJFILE_PATH" > "$SYMTAB" -- 2.18.1 - diff --git a/0011-support-c-plus-kernel-module.patch b/0011-support-c-plus-kernel-module.patch index 8b45ae7b22573da7e7bf3b1e00bf0e965bcb9ab1..306bea141d9db6f37864d44fa5f98297fa8a6c7f 100644 --- a/0011-support-c-plus-kernel-module.patch +++ b/0011-support-c-plus-kernel-module.patch @@ -1,7 +1,7 @@ -From 20de56a8393e6be3b556156124aa4b2139b10733 Mon Sep 17 00:00:00 2001 +From e438d0139d5e0c60b1e8dc78af8825f1a26fa438 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Wed, 26 Feb 2020 07:36:59 -0500 -Subject: [PATCH 11/17] support c plus kernel module +Subject: [PATCH 11/21] support c plus kernel module support GNU_UNIQUE type symbols. support .group section corelation. @@ -17,10 +17,10 @@ Signed-off-by: Zhipeng Xie 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 643ae3e..190753a 100644 +index bb2a803..5f90c6b 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -454,7 +454,7 @@ static void kpatch_compare_correlated_nonrela_section(struct section *sec) +@@ -459,7 +459,7 @@ static void kpatch_compare_correlated_nonrela_section(struct section *sec) { struct section *sec1 = sec, *sec2 = sec->twin; @@ -29,7 +29,7 @@ index 643ae3e..190753a 100644 memcmp(sec1->data->d_buf, sec2->data->d_buf, sec1->data->d_size)) sec->status = CHANGED; else -@@ -470,7 +470,7 @@ static void kpatch_compare_correlated_section(struct section *sec) +@@ -475,7 +475,7 @@ static void kpatch_compare_correlated_section(struct section *sec) sec1->sh.sh_flags != sec2->sh.sh_flags || sec1->sh.sh_entsize != sec2->sh.sh_entsize || (sec1->sh.sh_addralign != sec2->sh.sh_addralign && @@ -38,7 +38,7 @@ index 643ae3e..190753a 100644 DIFF_FATAL("%s section header details differ from %s", sec1->name, sec2->name); /* Short circuit for mcount sections, we rebuild regardless */ -@@ -907,6 +907,33 @@ static void kpatch_correlate_section(struct section *sec1, struct section *sec2) +@@ -912,6 +912,33 @@ static void kpatch_correlate_section(struct section *sec1, struct section *sec2) kpatch_correlate_symbol(sec1->sym, sec2->sym); } @@ -72,7 +72,7 @@ index 643ae3e..190753a 100644 static void kpatch_correlate_sections(struct list_head *seclist1, struct list_head *seclist2) { struct section *sec1, *sec2; -@@ -924,15 +951,19 @@ static void kpatch_correlate_sections(struct list_head *seclist1, struct list_he +@@ -929,15 +956,19 @@ static void kpatch_correlate_sections(struct list_head *seclist1, struct list_he sec1->secsym)) continue; @@ -100,7 +100,7 @@ index 643ae3e..190753a 100644 continue; } -@@ -1507,17 +1538,6 @@ static void kpatch_verify_patchability(struct kpatch_elf *kelf) +@@ -1519,17 +1550,6 @@ static void kpatch_verify_patchability(struct kpatch_elf *kelf) errs++; } @@ -132,10 +132,10 @@ index 4e38412..4896136 100755 cp -f "$TEMPDIR/patch/$MODNAME.ko" "$BASE" || die diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c -index 1c0e099..debf028 100644 +index c6af59e..b3ca7f5 100644 --- a/kpatch-build/kpatch-elf.c +++ b/kpatch-build/kpatch-elf.c -@@ -708,8 +708,14 @@ void kpatch_reindex_elements(struct kpatch_elf *kelf) +@@ -710,8 +710,14 @@ void kpatch_reindex_elements(struct kpatch_elf *kelf) unsigned int index; index = 1; /* elf write function handles NULL section 0 */ @@ -190,4 +190,3 @@ index 8387e8b..4e2fcb9 100644 result->size = sym->size; -- 2.18.1 - diff --git a/0012-symbol-lookup-enhancement.patch b/0012-symbol-lookup-enhancement.patch index c8aa13eba3e6a335a548e220fca0daff0c6a53d1..328d65d23591fbeb89170f49a8d4b51bf399be59 100644 --- a/0012-symbol-lookup-enhancement.patch +++ b/0012-symbol-lookup-enhancement.patch @@ -1,7 +1,7 @@ -From 56ec8b76667fb6c7fbc018a8fe7a77f144232f3f Mon Sep 17 00:00:00 2001 +From cf0a8995e6924d8130087a4859c5bf619515768d Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Wed, 26 Feb 2020 22:03:55 -0500 -Subject: [PATCH 12/17] symbol lookup enhancement +Subject: [PATCH 12/21] symbol lookup enhancement For symbols which have same name in one module or have length longger than KSYM_NAME_LEN(128 bytes). we add @@ -14,15 +14,15 @@ Signed-off-by: Zhipeng Xie --- kmod/patch/kpatch-patch.h | 4 + kpatch-build/create-diff-object.c | 46 ++++++++++- - kpatch-build/create-klp-module.c | 25 +++++- + kpatch-build/create-klp-module.c | 26 ++++-- kpatch-build/kpatch-build | 12 +++ kpatch-build/kpatch-intermediate.h | 2 + kpatch-build/lookup.c | 123 ++++++++++++++++++++++++++++- kpatch-build/lookup.h | 13 +++ - 7 files changed, 217 insertions(+), 8 deletions(-) + 7 files changed, 217 insertions(+), 9 deletions(-) diff --git a/kmod/patch/kpatch-patch.h b/kmod/patch/kpatch-patch.h -index 917ea32..7cd6dae 100644 +index da4f6a0..3530f66 100644 --- a/kmod/patch/kpatch-patch.h +++ b/kmod/patch/kpatch-patch.h @@ -30,6 +30,8 @@ struct kpatch_patch_func { @@ -37,17 +37,17 @@ index 917ea32..7cd6dae 100644 @@ -41,6 +43,8 @@ struct kpatch_patch_dynrela { char *objname; int external; - int addend; -+ char *ref_name; -+ long ref_offset; + long addend; ++ char *ref_name; ++ long ref_offset; }; struct kpatch_pre_patch_callback { diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 190753a..55db18c 100644 +index 5f90c6b..1bec4f4 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -2734,6 +2734,28 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, +@@ -2748,6 +2748,28 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, funcs[index].old_size = result.size; funcs[index].new_size = sym->sym.st_size; funcs[index].sympos = result.pos; @@ -68,24 +68,24 @@ index 190753a..55db18c 100644 + rela->sym = strsym; + rela->type = absolute_rela_type; + rela->addend = offset_of_string(&kelf->strings, refsym.name); -+ rela->offset = index * sizeof(*funcs) + -+ offsetof(struct kpatch_patch_func, ref_name); ++ rela->offset = (unsigned int)(index * sizeof(*funcs) + ++ offsetof(struct kpatch_patch_func, ref_name)); + + } + /* * Add a relocation that will populate -@@ -2753,7 +2775,7 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, +@@ -2767,7 +2789,7 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf, ALLOC_LINK(rela, &relasec->relas); rela->sym = strsym; rela->type = absolute_rela_type; - rela->addend = offset_of_string(&kelf->strings, sym->name); + rela->addend = offset_of_string(&kelf->strings, strndup(sym->name, KSYM_NAME_LEN-1)); - rela->offset = index * sizeof(*funcs) + - offsetof(struct kpatch_patch_func, name); + rela->offset = (unsigned int)(index * sizeof(*funcs) + + offsetof(struct kpatch_patch_func, name)); -@@ -2872,6 +2894,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, +@@ -2886,6 +2908,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, struct lookup_result result; char *sym_objname; int ret, vmlinux, external; @@ -93,7 +93,7 @@ index 190753a..55db18c 100644 vmlinux = !strcmp(objname, "vmlinux"); -@@ -3080,12 +3103,28 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, +@@ -3094,12 +3117,28 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, log_debug("lookup for %s @ 0x%016lx len %lu\n", rela->sym->name, result.value, result.size); @@ -116,23 +116,23 @@ index 190753a..55db18c 100644 + rela2->sym = strsym; + rela2->type = absolute_rela_type; + rela2->addend = offset_of_string(&kelf->strings, refsym.name); -+ rela2->offset = index * sizeof(*krelas) + -+ offsetof(struct kpatch_relocation, ref_name); ++ rela2->offset = (unsigned int)(index * sizeof(*krelas) + ++ offsetof(struct kpatch_relocation, ref_name)); + } + } ksyms[index].pos = result.pos; ksyms[index].type = rela->sym->type; ksyms[index].bind = rela->sym->bind; -@@ -3094,7 +3133,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, +@@ -3108,7 +3147,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, ALLOC_LINK(rela2, &ksym_sec->rela->relas); rela2->sym = strsym; rela2->type = absolute_rela_type; - rela2->addend = offset_of_string(&kelf->strings, rela->sym->name); + rela2->addend = offset_of_string(&kelf->strings, strndup(rela->sym->name, KSYM_NAME_LEN-1)); - rela2->offset = index * sizeof(*ksyms) + \ - offsetof(struct kpatch_symbol, name); + rela2->offset = (unsigned int)(index * sizeof(*ksyms) + \ + offsetof(struct kpatch_symbol, name)); -@@ -3113,6 +3152,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, +@@ -3127,6 +3166,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, krelas[index].addend = rela->addend; krelas[index].type = rela->type; krelas[index].external = external; @@ -141,7 +141,7 @@ index 190753a..55db18c 100644 /* add rela to fill in krelas[index].dest field */ ALLOC_LINK(rela2, &krela_sec->rela->relas); diff --git a/kpatch-build/create-klp-module.c b/kpatch-build/create-klp-module.c -index d995525..5073a04 100644 +index a97b146..0b441fa 100644 --- a/kpatch-build/create-klp-module.c +++ b/kpatch-build/create-klp-module.c @@ -38,7 +38,9 @@ enum loglevel loglevel = NORMAL; @@ -175,18 +175,18 @@ index d995525..5073a04 100644 @@ -176,6 +183,7 @@ static void create_klp_relasecs_and_syms(struct kpatch_elf *kelf, struct section struct rela *rela; char *objname; - int nr, index, offset, dest_off; -+ char *ref_name; + unsigned int nr, index, offset, dest_off; ++ char *ref_name; krelas = krelasec->data->d_buf; - nr = krelasec->data->d_size / sizeof(*krelas); + nr = (unsigned int)(krelasec->data->d_size / sizeof(*krelas)); @@ -200,6 +208,15 @@ static void create_klp_relasecs_and_syms(struct kpatch_elf *kelf, struct section objname = strings + rela->addend; + /* Get the unique ref_name */ + rela = find_rela_by_offset(krelasec->rela, -+ offset + offsetof(struct kpatch_relocation, ref_name)); ++ (unsigned int)(offset + offsetof(struct kpatch_relocation, ref_name))); + if (!rela) + ref_name = NULL; + else { @@ -195,13 +195,14 @@ index d995525..5073a04 100644 + /* Get the .kpatch.symbol entry for the rela src */ rela = find_rela_by_offset(krelasec->rela, - offset + offsetof(struct kpatch_relocation, ksym)); -@@ -207,7 +224,7 @@ static void create_klp_relasecs_and_syms(struct kpatch_elf *kelf, struct section + (unsigned int)(offset + offsetof(struct kpatch_relocation, ksym))); +@@ -207,8 +224,7 @@ static void create_klp_relasecs_and_syms(struct kpatch_elf *kelf, struct section ERROR("find_rela_by_offset"); /* Create (or find) a klp symbol from the rela src entry */ -- sym = find_or_add_ksym_to_symbols(kelf, ksymsec, strings, rela->addend); -+ sym = find_or_add_ksym_to_symbols(kelf, ksymsec, strings, rela->addend, ref_name, krelas[index].ref_offset); +- sym = find_or_add_ksym_to_symbols(kelf, ksymsec, strings, +- (unsigned int)rela->addend); ++ sym = find_or_add_ksym_to_symbols(kelf, ksymsec, strings, (unsigned int)rela->addend, ref_name, krelas[index].ref_offset); if (!sym) ERROR("error finding or adding ksym to symtab"); @@ -229,15 +230,15 @@ index 4896136..8bef7fb 100755 BUILDDIR="/lib/modules/$ARCHVERSION/build/" SYMVERS_FILE="$TEMPDIR/Module.symvers" diff --git a/kpatch-build/kpatch-intermediate.h b/kpatch-build/kpatch-intermediate.h -index 3dea775..59deed0 100644 +index 7230cd4..7247cac 100644 --- a/kpatch-build/kpatch-intermediate.h +++ b/kpatch-build/kpatch-intermediate.h @@ -39,6 +39,8 @@ struct kpatch_relocation { - int external; + long addend; char *objname; /* object to which this rela applies to */ struct kpatch_symbol *ksym; -+ char *ref_name; -+ long ref_offset; ++ char *ref_name; ++ long ref_offset; }; struct kpatch_arch { @@ -451,4 +452,3 @@ index 420d0f0..fed3fe9 100644 #endif /* _LOOKUP_H_ */ -- 2.18.1 - diff --git a/0013-Add-running-kernel-symbol-table-to-help-symbol-looku.patch b/0013-Add-running-kernel-symbol-table-to-help-symbol-looku.patch index 6a47a34a515e192fd075394b184cbd6d4fc204fa..432180387a9d82472f5b619a466903c2ca6aa119 100644 --- a/0013-Add-running-kernel-symbol-table-to-help-symbol-looku.patch +++ b/0013-Add-running-kernel-symbol-table-to-help-symbol-looku.patch @@ -1,7 +1,7 @@ -From 05051ffc7abcb953fb1ec51b0826b41f160ce191 Mon Sep 17 00:00:00 2001 +From 0475b1196c1b5eea3a52e2ff104be91fb27192be Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Wed, 26 Feb 2020 20:28:13 -0500 -Subject: [PATCH 13/17] Add running kernel symbol table to help symbol lookup +Subject: [PATCH 13/21] Add running kernel symbol table to help symbol lookup For some duplicate symbols whose section have no other symbols, we need running kernel symbol table to help @@ -15,10 +15,10 @@ Signed-off-by: Zhipeng Xie 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 55db18c..4589ba4 100644 +index 1bec4f4..10d07ba 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -3564,6 +3564,7 @@ int main(int argc, char *argv[]) +@@ -3578,6 +3578,7 @@ int main(int argc, char *argv[]) struct sym_compare_type *base_locals, *sym_comp; char *no_profiling_calls = NULL; char *gcc_add_option = NULL, *mlongcall = NULL; @@ -26,7 +26,7 @@ index 55db18c..4589ba4 100644 arguments.debug = 0; argp_parse (&argp, argc, argv, 0, NULL, &arguments); -@@ -3677,8 +3678,12 @@ int main(int argc, char *argv[]) +@@ -3691,8 +3692,12 @@ int main(int argc, char *argv[]) */ kpatch_elf_teardown(kelf_patched); @@ -168,4 +168,3 @@ index fed3fe9..00b6ccc 100644 struct lookup_result *result); -- 2.18.1 - diff --git a/0014-livepatch-patch-hook-support-force-enable-disable.patch b/0014-livepatch-patch-hook-support-force-enable-disable.patch index e277e9e0b05e535639521beaf4e29b0aa2cab3c4..515443db87070eef408bb96f509d807f9a314476 100644 --- a/0014-livepatch-patch-hook-support-force-enable-disable.patch +++ b/0014-livepatch-patch-hook-support-force-enable-disable.patch @@ -1,7 +1,7 @@ -From b63c72375420cb098a81167c48d822d596e770a9 Mon Sep 17 00:00:00 2001 +From aacab0b9a2f65adfee8258515cbbb34546f3acc7 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Wed, 26 Feb 2020 20:43:34 -0500 -Subject: [PATCH 14/17] livepatch-patch-hook: support force enable/disable +Subject: [PATCH 14/21] livepatch-patch-hook: support force enable/disable we use force to indicate function which bypass stack check @@ -64,4 +64,3 @@ index 8bef7fb..57487b1 100755 fi -- 2.18.1 - diff --git a/0015-kpatch-build-ignore-debuginfo-in-patch.patch b/0015-kpatch-build-ignore-debuginfo-in-patch.patch index 36caea5848225d50003a31be74b60e72f6b30a18..788f4da9ea76c3d975fb6b7776d14261b9ce1850 100644 --- a/0015-kpatch-build-ignore-debuginfo-in-patch.patch +++ b/0015-kpatch-build-ignore-debuginfo-in-patch.patch @@ -1,7 +1,7 @@ -From 720769ca54d446baf9cbc986fd2a8832da45ce71 Mon Sep 17 00:00:00 2001 +From 4e3c6975dcd0d36509a69bbed1f200f3c49fab23 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Wed, 26 Feb 2020 21:01:02 -0500 -Subject: [PATCH 15/17] kpatch-build: ignore debuginfo in patch +Subject: [PATCH 15/21] kpatch-build: ignore debuginfo in patch Just ignore all .debug_* sections @@ -12,10 +12,10 @@ Signed-off-by: Zhipeng Xie 2 files changed, 19 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 4589ba4..c466eb0 100644 +index 10d07ba..495cce1 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -2396,6 +2396,23 @@ static void kpatch_include_debug_sections(struct kpatch_elf *kelf) +@@ -2409,6 +2409,23 @@ static void kpatch_include_debug_sections(struct kpatch_elf *kelf) } } @@ -39,14 +39,14 @@ index 4589ba4..c466eb0 100644 static void kpatch_mark_ignored_sections(struct kpatch_elf *kelf) { struct section *sec, *strsec, *ignoresec; -@@ -3645,6 +3662,7 @@ int main(int argc, char *argv[]) - kpatch_include_standard_elements(kelf_patched); - num_changed = kpatch_include_changed_functions(kelf_patched); +@@ -3663,6 +3680,7 @@ int main(int argc, char *argv[]) + new_globals_exist = kpatch_include_new_globals(kelf_patched); + kpatch_include_new_static_var(kelf_patched); kpatch_include_debug_sections(kelf_patched); + kpatch_ignore_debug_sections(kelf_patched); - callbacks_exist = kpatch_include_callback_elements(kelf_patched); - kpatch_include_force_elements(kelf_patched); - new_globals_exist = kpatch_include_new_globals(kelf_patched); + + kpatch_process_special_sections(kelf_patched); + diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 57487b1..c109ee3 100755 --- a/kpatch-build/kpatch-build @@ -61,4 +61,3 @@ index 57487b1..c109ee3 100755 if [[ -z "$KPATCH_LDFLAGS" ]]; then -- 2.18.1 - diff --git a/0016-add-object-in-kpatch.patch b/0016-add-object-in-kpatch.patch index 8af8963fc36196c49750a0e65fd656794c75f44f..3b1ca93d63eb0bfec743eb86e0906e9960efaf86 100644 --- a/0016-add-object-in-kpatch.patch +++ b/0016-add-object-in-kpatch.patch @@ -1,7 +1,7 @@ -From dd03a70462783a9e8426ff76e42c41a7eaab644f Mon Sep 17 00:00:00 2001 +From ea1fb4eb836033b33f08047c3a1cb74a1a458fb2 Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Tue, 16 Jul 2019 14:39:27 +0800 -Subject: [PATCH 16/17] add object in kpatch +Subject: [PATCH 16/21] add object in kpatch --- kpatch-build/kpatch-build | 3 +++ @@ -30,4 +30,3 @@ index c109ee3..de448dc 100755 -- 2.18.1 - diff --git a/0017-create-diff-object-fix-.orc_unwind_ip-error.patch b/0017-create-diff-object-fix-.orc_unwind_ip-error.patch index d1e424bcb4a33765c76246008b59adfc9a6f656d..3569f1a5e3a94d58f787f220ea34baa42b8041aa 100644 --- a/0017-create-diff-object-fix-.orc_unwind_ip-error.patch +++ b/0017-create-diff-object-fix-.orc_unwind_ip-error.patch @@ -1,7 +1,7 @@ -From 96e3ca2fbed32589510c800e9efe31bab2f5e58a Mon Sep 17 00:00:00 2001 +From 9fa4a3a0a62a383e635ea7de631176a4513f6db9 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Thu, 27 Feb 2020 15:36:55 -0500 -Subject: [PATCH 17/17] create-diff-object: fix .orc_unwind_ip error +Subject: [PATCH 17/21] create-diff-object: fix .orc_unwind_ip error error: .orc_unwind_ip section header details differ from .orc_unwind_ip @@ -14,10 +14,10 @@ Signed-off-by: Zhipeng Xie 1 file changed, 6 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index c466eb0..320b239 100644 +index 495cce1..45979d6 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -967,6 +967,9 @@ static void kpatch_correlate_sections(struct list_head *seclist1, struct list_he +@@ -972,6 +972,9 @@ static void kpatch_correlate_sections(struct list_head *seclist1, struct list_he continue; } @@ -27,7 +27,7 @@ index c466eb0..320b239 100644 kpatch_correlate_section(sec1, sec2); break; } -@@ -1012,6 +1015,9 @@ static void kpatch_correlate_symbols(struct list_head *symlist1, struct list_hea +@@ -1017,6 +1020,9 @@ static void kpatch_correlate_symbols(struct list_head *symlist1, struct list_hea sym1->sec->twin != sym2->sec) continue; @@ -39,4 +39,3 @@ index c466eb0..320b239 100644 } -- 2.18.1 - diff --git a/0018-use-orignal-reloc-for-symbols-from-modules.patch b/0018-use-orignal-reloc-for-symbols-from-modules.patch index 0b081994988ea19a22972910bf3c665418ed0f6b..fc88c8b882641cf09a91c48f55593d5695f0b7c1 100644 --- a/0018-use-orignal-reloc-for-symbols-from-modules.patch +++ b/0018-use-orignal-reloc-for-symbols-from-modules.patch @@ -1,7 +1,7 @@ -From 4d13c1b29b2172e6758d18b153f149e461c6d9c3 Mon Sep 17 00:00:00 2001 +From 7c7f582a9b051c4570a00f215f5534ff0fdfd9a0 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Thu, 12 Mar 2020 05:10:55 -0400 -Subject: [PATCH] use orignal reloc for symbols from modules +Subject: [PATCH 18/21] use orignal reloc for symbols from modules symbols exported in a patch will generate a symbol version with object module name in Module.symvers, but the symbol is actually @@ -13,10 +13,10 @@ Signed-off-by: Zhipeng Xie 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 320b239..64e5686 100644 +index 45979d6..7d24c7e 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -3117,10 +3117,8 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, +@@ -3131,10 +3131,8 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, if (!strcmp(sym_objname, "vmlinux")) continue; @@ -30,4 +30,3 @@ index 320b239..64e5686 100644 log_debug("lookup for %s @ 0x%016lx len %lu\n", -- 2.18.1 - diff --git a/0019-create-diff-object-add-jump-label-support.patch b/0019-create-diff-object-add-jump-label-support.patch index cd00b1cd7b3553825bc7ede0e02e43ae910a2723..ff6036447ea92a9a6a89b67a04fb440e5752ba74 100644 --- a/0019-create-diff-object-add-jump-label-support.patch +++ b/0019-create-diff-object-add-jump-label-support.patch @@ -1,7 +1,7 @@ -From b3b20140aa243b371f478f325420ecbffd3ee3d6 Mon Sep 17 00:00:00 2001 +From 9233e07a0dfdb3eceb44093feb2e5928a9e391d9 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Mon, 2 Mar 2020 04:35:07 -0500 -Subject: [PATCH] create-diff-object: add jump label support +Subject: [PATCH 19/21] create-diff-object: add jump label support This patch processes the __jump_table special section, and only the jump_lable used by the changed functions will be @@ -15,10 +15,10 @@ Signed-off-by: Zhipeng Xie 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c -index 7230e93..18d6c7f 100644 +index 7d24c7e..448911b 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c -@@ -2116,7 +2116,6 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf, +@@ -2135,7 +2135,6 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf, struct rela *rela, *safe; char *src, *dest; unsigned int group_size, src_offset, dest_offset, include; @@ -26,7 +26,7 @@ index 7230e93..18d6c7f 100644 LIST_HEAD(newrelas); -@@ -2156,49 +2155,6 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf, +@@ -2175,49 +2174,6 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf, if (!include) continue; @@ -76,7 +76,7 @@ index 7230e93..18d6c7f 100644 /* * Copy all relas in the group. It's possible that the relas * aren't sorted (e.g. .rela.fixup), so go through the entire -@@ -2635,8 +2591,7 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf) +@@ -2654,8 +2610,7 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf) * jump labels and enable tracepoints in a patched function. */ list_for_each_entry(sec, &kelf->sections, list) { @@ -88,4 +88,3 @@ index 7230e93..18d6c7f 100644 continue; -- 2.18.1 - diff --git a/0020-kpatch-build-add-compile-flag-fno-reorder-functions.patch b/0020-kpatch-build-add-compile-flag-fno-reorder-functions.patch index dc3f45302705abdfb04d4af6061c9b94e6a1876a..6b75320508341e25816e72a2fac22d8a5c157c54 100644 --- a/0020-kpatch-build-add-compile-flag-fno-reorder-functions.patch +++ b/0020-kpatch-build-add-compile-flag-fno-reorder-functions.patch @@ -1,7 +1,7 @@ -From 65a3ae0c692a22d097f7257ae88bbe6bc2b73de8 Mon Sep 17 00:00:00 2001 +From da47ad5e439e9ba9422cac2ade847463bc8578ee Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Thu, 12 Mar 2020 06:56:21 -0400 -Subject: [PATCH] kpatch-build: add compile flag -fno-reorder-functions +Subject: [PATCH 20/21] kpatch-build: add compile flag -fno-reorder-functions Sometimes function foo with static variables can be put in .text.foo section in original binary and be put in @@ -37,4 +37,3 @@ index de448dc..ad7ab71 100755 echo "Reading special section data" -- 2.18.1 - diff --git a/0021-kpatch-build-don-t-copy-.config-for-out-of-tree-modu.patch b/0021-kpatch-build-don-t-copy-.config-for-out-of-tree-modu.patch index 28b772068198b7e91d382f1dc90bcff5f00443c3..3bca5b416d26ba8c57b0ab1a58a4d88aef3a2365 100644 --- a/0021-kpatch-build-don-t-copy-.config-for-out-of-tree-modu.patch +++ b/0021-kpatch-build-don-t-copy-.config-for-out-of-tree-modu.patch @@ -1,7 +1,7 @@ -From 1155b58be699eb2e55af7757e6b0d0ce03356d63 Mon Sep 17 00:00:00 2001 +From b05aaaf13978393f8e9c2329a80765c0069e7e87 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Thu, 12 Mar 2020 07:37:00 -0400 -Subject: [PATCH] kpatch-build: don't copy .config for out of tree module +Subject: [PATCH 21/21] kpatch-build: don't copy .config for out of tree module Signed-off-by: Zhipeng Xie --- @@ -23,4 +23,3 @@ index ad7ab71..fd34812 100755 # according to .config and kernel version -- 2.18.1 - diff --git a/0022-support-force-enable-disable-for-x86.patch b/0022-support-force-enable-disable-for-x86.patch new file mode 100644 index 0000000000000000000000000000000000000000..eaaea29d69fb0ab08187a80364c0fcef079b28fb --- /dev/null +++ b/0022-support-force-enable-disable-for-x86.patch @@ -0,0 +1,57 @@ +From 4cad4a9ec87736e938ccd13b62c5ef8e595a591e Mon Sep 17 00:00:00 2001 +From: Zhipeng Xie +Date: Wed, 15 Apr 2020 06:37:59 -0400 +Subject: [PATCH 22/22] support force enable/disable for x86 + +detect if the klp_func structure in vmlinux have force +member, if it has, export KLP_SUPPORT_FORCE=y. + +Signed-off-by: Zhipeng Xie +--- + kpatch-build/kpatch-build | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build +index fd34812..523d5df 100755 +--- a/kpatch-build/kpatch-build ++++ b/kpatch-build/kpatch-build +@@ -373,7 +373,7 @@ find_special_section_data() { + # shellcheck disable=SC2086 + SPECIAL_VARS="$(readelf -wi "$VMLINUX" | + gawk --non-decimal-data $AWK_OPTIONS ' +- BEGIN { a = b = p = e = o = j = 0 } ++ BEGIN { a = b = p = e = o = j = c = f = 0 } + + # Set state if name matches + a == 0 && /DW_AT_name.* alt_instr[[:space:]]*$/ {a = 1; next} +@@ -382,6 +382,7 @@ find_special_section_data() { + e == 0 && /DW_AT_name.* exception_table_entry[[:space:]]*$/ {e = 1; next} + o == 0 && /DW_AT_name.* orc_entry[[:space:]]*$/ {o = 1; next} + j == 0 && /DW_AT_name.* jump_entry[[:space:]]*$/ {j = 1; next} ++ c == 0 && /DW_AT_name.* klp_func[[:space:]]*$/ {c = 1; next} + + # Reset state unless this abbrev describes the struct size + a == 1 && !/DW_AT_byte_size/ { a = 0; next } +@@ -390,6 +391,8 @@ find_special_section_data() { + e == 1 && !/DW_AT_byte_size/ { e = 0; next } + o == 1 && !/DW_AT_byte_size/ { o = 0; next } + j == 1 && !/DW_AT_byte_size/ { j = 0; next } ++ c == 1 && /DW_TAG_structure_type/ { c = 3; next } ++ c == 1 && /DW_AT_name.* force[[:space:]]*$/ {f = 2; next} + + # Now that we know the size, stop parsing for it + a == 1 {printf("export ALT_STRUCT_SIZE=%d\n", $4); a = 2} +@@ -398,9 +401,10 @@ find_special_section_data() { + e == 1 {printf("export EX_STRUCT_SIZE=%d\n", $4); e = 2} + o == 1 {printf("export ORC_STRUCT_SIZE=%d\n", $4); o = 2} + j == 1 {printf("export JUMP_STRUCT_SIZE=%d\n", $4); j = 2} ++ f == 2 {printf("export KLP_SUPPORT_FORCE=y\n"); f = 3} + + # Bail out once we have everything +- a == 2 && b == 2 && (p == 2 || skip_p) && e == 2 && (o == 2 || skip_o) && (j == 2 || skip_j) {exit}')" ++ a == 2 && b == 2 && (p == 2 || skip_p) && e == 2 && (o == 2 || skip_o) && (j == 2 || skip_j) && c == 3 {exit}')" + + [[ -n "$SPECIAL_VARS" ]] && eval "$SPECIAL_VARS" + +-- +2.18.1 diff --git a/0023-create-diff-object-fix-duplicate-symbols-for-vmlinux.patch b/0023-create-diff-object-fix-duplicate-symbols-for-vmlinux.patch new file mode 100644 index 0000000000000000000000000000000000000000..77a21f50ce4c5be2dbab3900308304ba19e9edd4 --- /dev/null +++ b/0023-create-diff-object-fix-duplicate-symbols-for-vmlinux.patch @@ -0,0 +1,56 @@ +From 50401005b1a16b93307390983dd61f480492d495 Mon Sep 17 00:00:00 2001 +From: Zhipeng Xie +Date: Wed, 22 Apr 2020 05:55:33 -0400 +Subject: [PATCH] create-diff-object: fix duplicate symbols for vmlinux + +symbol pos in vmlinux may be different with runtime +/proc/kallsyms, use ref_name and ref_offset method too. + +Signed-off-by: Zhipeng Xie +--- + kpatch-build/create-diff-object.c | 28 +++++++++++++++------------- + 1 file changed, 15 insertions(+), 13 deletions(-) + +diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c +index 2b1ee36..c0c8106 100644 +--- a/kpatch-build/create-diff-object.c ++++ b/kpatch-build/create-diff-object.c +@@ -3100,21 +3100,23 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf, + else { + /* for modules, src is discovered at runtime */ + ksyms[index].src = 0; +- if (lookup_is_duplicate_symbol(table, rela->sym->name, objname, result.pos)) { +- struct lookup_refsym refsym; +- +- if (lookup_ref_symbol_offset(table, rela->sym->name, &refsym, objname, &ref_offset)) +- ERROR("unresolvable ambiguity on symbol %s\n", rela->sym->name); +- +- /* add rela to fill in ref_name field */ +- ALLOC_LINK(rela2, &krela_sec->rela->relas); +- rela2->sym = strsym; +- rela2->type = absolute_rela_type; +- rela2->addend = offset_of_string(&kelf->strings, refsym.name); +- rela2->offset = (unsigned int)(index * sizeof(*krelas) + ++ } ++ ++ if (lookup_is_duplicate_symbol(table, rela->sym->name, objname, result.pos)) { ++ struct lookup_refsym refsym; ++ ++ if (lookup_ref_symbol_offset(table, rela->sym->name, &refsym, objname, &ref_offset)) ++ ERROR("unresolvable ambiguity on symbol %s\n", rela->sym->name); ++ ++ /* add rela to fill in ref_name field */ ++ ALLOC_LINK(rela2, &krela_sec->rela->relas); ++ rela2->sym = strsym; ++ rela2->type = absolute_rela_type; ++ rela2->addend = offset_of_string(&kelf->strings, refsym.name); ++ rela2->offset = (unsigned int)(index * sizeof(*krelas) + + offsetof(struct kpatch_relocation, ref_name)); +- } + } ++ + ksyms[index].pos = result.pos; + ksyms[index].type = rela->sym->type; + ksyms[index].bind = rela->sym->bind; +-- +2.18.1 diff --git a/kpatch-0.9.0.tar.gz b/kpatch-0.9.0.tar.gz deleted file mode 100644 index 343d51866c7f96de8c2bcd9009627d4379046480..0000000000000000000000000000000000000000 Binary files a/kpatch-0.9.0.tar.gz and /dev/null differ diff --git a/kpatch-0.9.1.tar.gz b/kpatch-0.9.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..0893f72ee5fc9584cc1d585d9f60fe106098e3d8 Binary files /dev/null and b/kpatch-0.9.1.tar.gz differ diff --git a/kpatch.spec b/kpatch.spec index fb15dc8b38308b0a32da949e3ece47b65a29685c..465ddd6f4a716f9e80a2038ad88cb820043bc554 100644 --- a/kpatch.spec +++ b/kpatch.spec @@ -1,8 +1,9 @@ -%global raw_version 0.9.0 +%global raw_version 0.9.1 Name: kpatch -Version: 2.0 -Release: 3.1.26 +Epoch: 1 +Version: %{raw_version} +Release: 2 Summary: A Linux dynamic kernel patching infrastructure License: GPLv2 @@ -34,8 +35,10 @@ Patch0018:0018-use-orignal-reloc-for-symbols-from-modules.patch Patch0019:0019-create-diff-object-add-jump-label-support.patch Patch0020:0020-kpatch-build-add-compile-flag-fno-reorder-functions.patch Patch0021:0021-kpatch-build-don-t-copy-.config-for-out-of-tree-modu.patch +Patch0022:0022-support-force-enable-disable-for-x86.patch +Patch0023:0023-create-diff-object-fix-duplicate-symbols-for-vmlinux.patch -BuildRequires: gcc elfutils-libelf-devel uname-build-checks kernel kernel-devel +BuildRequires: gcc elfutils-libelf-devel uname-build-checks kernel kernel-devel git Requires: bc %description @@ -55,7 +58,7 @@ Dynamic kernel patching %package_help %prep -%autosetup -n %{name}-%{raw_version} -p1 +%autosetup -n %{name}-%{raw_version} -p1 -Sgit %build export CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS" @@ -92,6 +95,19 @@ popd %{_mandir}/man1/*.1.gz %changelog +* Wed Apr 22 2020 Zhipeng Xie -1:0.9.1-2 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix duplicate symbols in vmlinux + +* Wed Apr 15 2020 Zhipeng Xie -1:0.9.1-1 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC:rebase from upstream version v0.9.1 + Use Epoch to make the version number consistent with the upstream + * Thu Mar 12 2020 Zhipeng Xie -2.0-3.1.26 - Type:bugfix - ID:NA