From 284e07e60bf9e1b50018f5e6edced15d3578fb25 Mon Sep 17 00:00:00 2001 From: c00662745 Date: Wed, 22 May 2024 20:53:57 +0800 Subject: [PATCH] adapt arm64 dynamic ftrace call with 2 nops --- ...rm64-dynamic-ftrace-call-with-2-nops.patch | 55 +++++++++++++++++++ kpatch.spec | 9 ++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 huawei-adapt-arm64-dynamic-ftrace-call-with-2-nops.patch diff --git a/huawei-adapt-arm64-dynamic-ftrace-call-with-2-nops.patch b/huawei-adapt-arm64-dynamic-ftrace-call-with-2-nops.patch new file mode 100644 index 0000000..a0f4f78 --- /dev/null +++ b/huawei-adapt-arm64-dynamic-ftrace-call-with-2-nops.patch @@ -0,0 +1,55 @@ +From e8674bab4db104357780db9b960b78938fac5a6d Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Wed, 22 May 2024 20:31:59 +0800 +Subject: [PATCH] huawei adapt arm64 dynamic ftrace call with 2 nops + +--- + kpatch-build/create-diff-object.c | 5 +++++ + kpatch-build/kpatch-build | 1 + + 2 files changed, 6 insertions(+) + +diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c +index 73b8337..f1dfc1d 100644 +--- a/kpatch-build/create-diff-object.c ++++ b/kpatch-build/create-diff-object.c +@@ -242,6 +242,7 @@ static void kpatch_bundle_symbols(struct kpatch_elf *kelf) + struct symbol *sym; + unsigned int expected_offset; + unsigned int directcall_offset = 16; ++ unsigned int dynamic_ftracecall_offset = 8; + + list_for_each_entry(sym, &kelf->symbols, list) { + if (is_bundleable(sym)) { +@@ -253,6 +254,7 @@ static void kpatch_bundle_symbols(struct kpatch_elf *kelf) + expected_offset = 0; + + if (sym->sym.st_value != expected_offset && ++ !(getenv("CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS") && sym->sym.st_value == dynamic_ftracecall_offset) && + !(getenv("CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS") && sym->sym.st_value == directcall_offset)) { + ERROR("symbol %s at offset %lu within section %s, expected %u", + sym->name, sym->sym.st_value, +@@ -3446,6 +3448,9 @@ static int function_ptr_rela(const struct rela *rela) + if (getenv("CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS")) + entry_offset = 16; + ++ if (getenv("CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS")) ++ entry_offset = 8; ++ + return (rela_toc && rela_toc->sym->type == STT_FUNC && + !rela_toc->sym->parent && + (rela_toc->addend == (int)rela_toc->sym->sym.st_value || +diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build +index edc05b3..886a753 100755 +--- a/kpatch-build/kpatch-build ++++ b/kpatch-build/kpatch-build +@@ -1181,6 +1181,7 @@ else + fi + + grep -q "CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=y" "$CONFIGFILE" && export CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=1 ++grep -q "CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS=y" "$CONFIGFILE" && export CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS=1 + + # unsupported kernel option checking + [[ -n "$CONFIG_DEBUG_INFO_SPLIT" ]] && die "kernel option 'CONFIG_DEBUG_INFO_SPLIT' not supported" +-- +2.33.0 + diff --git a/kpatch.spec b/kpatch.spec index 14cae90..6cbb255 100644 --- a/kpatch.spec +++ b/kpatch.spec @@ -1,7 +1,7 @@ Name: kpatch Epoch: 1 Version: 0.9.9 -Release: 5 +Release: 6 Summary: A Linux dynamic kernel patching infrastructure License: GPLv2 @@ -57,6 +57,7 @@ Patch9001:huawei-fix-function-ptr-relocation.patch Patch9002:huawei-lookup.c-ignore-BTF-ID-when-matching-locals.patch Patch9003:huawei-adapt-kpatch-to-6.6-kernel-and-fix-bundle-symbols-ch.patch Patch9004:huawei-fix-function-ptr-relocation-and-strip-.BTF-section-f.patch +Patch9005:huawei-adapt-arm64-dynamic-ftrace-call-with-2-nops.patch BuildRequires: gcc elfutils-libelf-devel kernel-devel git %ifarch ppc64le @@ -120,6 +121,12 @@ popd %{_mandir}/man1/*.1.gz %changelog +* Wed May 22 2024 caixiaomeng - 1:0.9.9-6 +- Type: bugfix +- CVE:NA +- SUG:NA +- DESC:adapt arm64 dynamic ftrace call with 2 nops + * Mon May 6 2024 caixiaomeng - 1:0.9.9-5 - Type: bugfix - CVE:NA