From b19ca18ab0aa8062f4dd68db3cd0b35094369185 Mon Sep 17 00:00:00 2001 From: hubin Date: Sun, 9 Oct 2022 17:34:29 +0800 Subject: [PATCH] create-diff-object: add support for .return_sites section Signed-off-by: hubin --- ...ct-add-support-for-.return_sites-sec.patch | 43 +++++++++++++++++++ ...ct-ignore-entsize-change-of-.return_.patch | 35 +++++++++++++++ kpatch.spec | 10 ++++- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 0045-backport-create-diff-object-add-support-for-.return_sites-sec.patch create mode 100644 0046-create-diff-object-ignore-entsize-change-of-.return_.patch diff --git a/0045-backport-create-diff-object-add-support-for-.return_sites-sec.patch b/0045-backport-create-diff-object-add-support-for-.return_sites-sec.patch new file mode 100644 index 0000000..f47947c --- /dev/null +++ b/0045-backport-create-diff-object-add-support-for-.return_sites-sec.patch @@ -0,0 +1,43 @@ +From 764baf9f38c15d48a7cacbafcad9b83b7a23d842 Mon Sep 17 00:00:00 2001 +From: hubin +Date: Thu, 1 Sep 2022 06:13:03 +0800 +Subject: [PATCH] create-diff-object: add support for .return_sites section + +Signed-off-by: Jonathan Dobson + +Reference:https://github.com/dynup/kpatch/commit/33368a88cdf875b0edd02b0dfd3356a7e93b24db +Conflict:kpatch-build/create-diff-object.c +--- + kpatch-build/create-diff-object.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c +index 58d4763..3c55013 100644 +--- a/kpatch-build/create-diff-object.c ++++ b/kpatch-build/create-diff-object.c +@@ -2242,6 +2242,11 @@ static int retpoline_sites_group_size(struct kpatch_elf *kelf, int offset) + { + return 4; + } ++ ++static int return_sites_group_size(struct kpatch_elf *kelf, int offset) ++{ ++ return 4; ++} + #endif + #ifdef __powerpc64__ + static int fixup_entry_group_size(struct kpatch_elf *kelf, int offset) +@@ -2362,6 +2367,10 @@ static struct special_section special_sections[] = { + .name = ".retpoline_sites", + .group_size = retpoline_sites_group_size, + }, ++ { ++ .name = ".return_sites", ++ .group_size = return_sites_group_size, ++ }, + #endif + #ifdef __powerpc64__ + { +-- +2.33.0 + diff --git a/0046-create-diff-object-ignore-entsize-change-of-.return_.patch b/0046-create-diff-object-ignore-entsize-change-of-.return_.patch new file mode 100644 index 0000000..6ee7a72 --- /dev/null +++ b/0046-create-diff-object-ignore-entsize-change-of-.return_.patch @@ -0,0 +1,35 @@ +From 594f0810329ca074d53399f6d1927aa87607c34a Mon Sep 17 00:00:00 2001 +From: hubin +Date: Sun, 9 Oct 2022 14:33:13 +0800 +Subject: [PATCH] create-diff-object: ignore entsize change of .return_sites + section + +If a patch contains newly exported function, kernel Makefile.build +script will add one ld step when generating object file, which +causes the entsize of patched object's .return_sites section changed +to 0, and differs from the original entsize 4. + +For this change, currently just ignore it. + +Signed-off-by: hubin +--- + kpatch-build/create-diff-object.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c +index d7a6789..77ee7b2 100644 +--- a/kpatch-build/create-diff-object.c ++++ b/kpatch-build/create-diff-object.c +@@ -555,7 +555,8 @@ static void kpatch_compare_correlated_section(struct section *sec) + /* Compare section headers (must match or fatal) */ + if (sec1->sh.sh_type != sec2->sh.sh_type || + sec1->sh.sh_flags != sec2->sh.sh_flags || +- sec1->sh.sh_entsize != sec2->sh.sh_entsize || ++ (sec1->sh.sh_entsize != sec2->sh.sh_entsize && ++ strcmp(sec1->name, ".return_sites")) || + (sec1->sh.sh_addralign != sec2->sh.sh_addralign && + !is_text_section(sec1) && strcmp(sec1->name, ".rodata"))) + DIFF_FATAL("%s section header details differ from %s", sec1->name, sec2->name); +-- +2.27.0 + diff --git a/kpatch.spec b/kpatch.spec index e2916d9..5b0cca6 100644 --- a/kpatch.spec +++ b/kpatch.spec @@ -1,7 +1,7 @@ Name: kpatch Epoch: 1 Version: 0.9.5 -Release: 14 +Release: 15 Summary: A Linux dynamic kernel patching infrastructure License: GPLv2 @@ -57,6 +57,8 @@ Patch0041:0041-livepatch-patch-hook-fix-kpatch-build-error-which-do.patch Patch0042:0042-kpatch-build-fix-loading-error-in-aarch64.patch Patch0043:0043-kpatch-build-Remove-duplicate-functions.patch Patch0044:0044-lookup-skip-finding-local-symbols-for-object-with-no.patch +Patch0045:0045-backport-create-diff-object-add-support-for-.return_sites-sec.patch +Patch0046:0046-create-diff-object-ignore-entsize-change-of-.return_.patch BuildRequires: gcc elfutils-libelf-devel kernel-devel git Requires: bc make gcc patch bison flex openssl-devel @@ -117,6 +119,12 @@ popd %{_mandir}/man1/*.1.gz %changelog +* Sun Oct 9 2022 Bin Hu -1:0.9.5-15 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:create-diff-object: add support for .return_sites section + * Sun Oct 9 2022 Bin Hu -1:0.9.5-14 - Type:bugfix - ID:NA