Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
9db0e530bd
!158 fix rela.init.text section changed due to _BTF_id changed
From: @pshysimon 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2025-03-13 11:32:40 +00:00
PshySimon
1f3bd3f530 fix rela.init.text section changed due to __BTF_id_ changed 2025-03-13 19:21:34 +08:00
openeuler-ci-bot
e847e265f8
!148 修复kpatch制作热补丁时报错symbol xxx at offset 20 within section xxx, expected 0
From: @pshysimon 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2024-11-08 09:36:19 +00:00
PshySimon
bb05c997eb adapt kpatch bundle symbols to kernel change 2024-11-08 17:25:28 +08:00
openeuler-ci-bot
2b82987e64
!143 ignore sssnic module when building hotpatch to fix sssnic wrongly dependency of sssnic
From: @pshysimon 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2024-07-15 10:42:56 +00:00
PhsySimon
13228b4f2f ignore sssnic module when building hotpatch to fix sssnic wrongly dependency of sssnic 2024-07-13 17:22:13 +08:00
openeuler-ci-bot
002e19f098
!131 [sync] PR-112: add gcc-plugin-devel to BuildRequires for ppc64le
From: @openeuler-sync-bot 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2024-06-12 03:43:32 +00:00
邹鹏
4ac68d1c46 add gcc-plugin-devel to BuildRequires for ppc64le
(cherry picked from commit 735d67ea8f8b07127cd6348cc95416339e6318d4)
2024-06-11 20:02:25 +08:00
openeuler-ci-bot
fb36d53e41
!103 fix error in making hotpatch when local_match be empty
From: @wangjiang37 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2023-09-26 06:15:47 +00:00
wangjiang
aee22b3bbb fix error in making hotpatch when local_match be empty 2023-09-25 08:53:52 +00:00
6 changed files with 306 additions and 1 deletions

View File

@ -0,0 +1,69 @@
From 75927e7bbbc81de662755cee9c2e65b975138e06 Mon Sep 17 00:00:00 2001
From: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Tue, 16 May 2023 15:46:18 -0700
Subject: [PATCH] lookup: skip duplicate local symbol table check for files
without locals
If the file doesn't have local object/func symbols, any empty match will
do, and duplicate matching local symbol lists aren't a problem.
Fixes #1345.
Reported-by: lzwycc <lzw32321226@163.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Reference:https://github.com/dynup/kpatch/commit/75927e7bbbc81de662755cee9c2e65b975138e06
Conflict: change 'return true' in fun locals_match to 'return sym_num'
in count_local_symbol
---
kpatch-build/lookup.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c
index 875605d..458b447 100644
--- a/kpatch-build/lookup.c
+++ b/kpatch-build/lookup.c
@@ -182,6 +182,25 @@ static int count_local_symbol(struct list_head *sym_list)
return sym_num;
}
+static bool file_has_locals(struct symbol *file_sym, struct list_head *sym_list)
+{
+ struct symbol *sym = file_sym;
+
+ list_for_each_entry_continue(sym, sym_list, list) {
+ if (sym->type == STT_FILE)
+ break;
+ if (sym->type != STB_LOCAL)
+ continue;
+ if (maybe_discarded_sym(sym->name))
+ continue;
+
+ if (sym->type == STT_FUNC || sym->type == STT_OBJECT)
+ return true;
+ }
+
+ return false;
+}
+
static void find_local_syms(struct lookup_table *table, struct symbol *file_sym,
struct list_head *sym_list)
{
@@ -204,6 +223,14 @@ static void find_local_syms(struct lookup_table *table, struct symbol *file_sym,
file_sym->name, table->objname);
lookup_table_file_sym = sym;
+
+ if (!file_has_locals(file_sym, sym_list)) {
+ /*
+ * If the file doesn't have local symbols, any empty
+ * match will do. Skip the duplicate check.
+ */
+ break;
+ }
}
if (!lookup_table_file_sym)
--
2.33.0

View File

@ -0,0 +1,26 @@
From 44026d09697e612c2bc6f08b1a219f09c40a1e11 Mon Sep 17 00:00:00 2001
From: Cai Xiaomeng <caixiaomeng2@huawei.com>
Date: Sat, 13 Jul 2024 14:53:06 +0800
Subject: [PATCH] fix sssnic module always changes, kpatch relying on sssnic
problem
---
kpatch-build/kpatch-cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kpatch-build/kpatch-cc b/kpatch-build/kpatch-cc
index 80d310c..688d92b 100755
--- a/kpatch-build/kpatch-cc
+++ b/kpatch-build/kpatch-cc
@@ -49,7 +49,8 @@ if [[ "$TOOLCHAINCMD" =~ ^(.*-)?gcc$ ||
arch/powerpc/kernel/vdso64/*|\
lib/*|\
.*.o|\
- */.lib_exports.o)
+ */.lib_exports.o|\
+ drivers/net/ethernet/3snic/sssnic/*)
break
;;
*.o)
--
2.33.0

View File

@ -0,0 +1,75 @@
From 717db96e56118b4a457f7bf6988cb7c3d1af6b12 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Fri, 8 Nov 2024 11:52:51 +0800
Subject: [PATCH] adapt kpatch_bundle_symbols to kernel change and fix function
ptr relocation
---
kpatch-build/create-diff-object.c | 10 ++++++++--
kpatch-build/kpatch-build | 1 +
kpatch-build/lookup.c | 5 +++++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 6f3937f..fc756f3 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -229,7 +229,8 @@ static void kpatch_bundle_symbols(struct kpatch_elf *kelf)
list_for_each_entry(sym, &kelf->symbols, list) {
if (is_bundleable(sym)) {
if (sym->sym.st_value != 0 &&
- !is_gcc6_localentry_bundled_sym(sym)) {
+ !is_gcc6_localentry_bundled_sym(sym) &&
+ !(getenv("CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS") && sym->sym.st_value == 20)) {
ERROR("symbol %s at offset %lu within section %s, expected 0",
sym->name, sym->sym.st_value,
sym->sec->name);
@@ -3228,10 +3229,15 @@ static int kpatch_is_core_module_symbol(char *name)
static int function_ptr_rela(const struct rela *rela)
{
const struct rela *rela_toc = toc_rela(rela);
+ int entry_offset = 0;
+
+ if (getenv("CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS"))
+ entry_offset = 20;
return (rela_toc && rela_toc->sym->type == STT_FUNC &&
!rela_toc->sym->parent &&
- rela_toc->addend == (int)rela_toc->sym->sym.st_value &&
+ (rela_toc->addend == (int)rela_toc->sym->sym.st_value ||
+ rela_toc->addend == (int)rela_toc->sym->sym.st_value - entry_offset) &&
(rela->type == R_X86_64_32S ||
rela->type == R_PPC64_TOC16_HA ||
rela->type == R_PPC64_TOC16_LO_DS ||
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 6a0645a..782007e 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -930,6 +930,7 @@ grep -q "CONFIG_JUMP_LABEL=y" "" && CONFIG_JUMP_LABEL=1
grep -q "CONFIG_MODVERSIONS=y" "$CONFIGFILE" && CONFIG_MODVERSIONS=1
grep -q "CONFIG_CC_IS_CLANG=y" "$CONFIGFILE" && CONFIG_CC_IS_CLANG=1
grep -q "CONFIG_LD_IS_LLD=y" "$CONFIGFILE" && CONFIG_LD_IS_LLD=1
+grep -q "CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=y" "$CONFIGFILE" && export CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=1
# unsupported kernel option checking
grep -q "CONFIG_DEBUG_INFO_SPLIT=y" "$CONFIGFILE" && die "kernel option 'CONFIG_DEBUG_INFO_SPLIT' not supported"
diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c
index 458b447..2fe1fd0 100644
--- a/kpatch-build/lookup.c
+++ b/kpatch-build/lookup.c
@@ -107,6 +107,11 @@ static bool locals_match(struct lookup_table *table, int idx,
continue;
if (table_sym->type != STT_FUNC && table_sym->type != STT_OBJECT)
continue;
+ /*
+ * BTF info may not be enabled when compiling kernel, but exists in vmlinux symtab
+ */
+ if (!strncmp(table_sym->name, "__BTF_ID__", 10))
+ continue;
found = 0;
sym = file_sym;
--
2.33.0

View File

@ -0,0 +1,69 @@
From 901445a54fcecbd6852b79878e67153c5048602e Mon Sep 17 00:00:00 2001
From: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon, 21 Nov 2022 19:32:18 -0800
Subject: [PATCH] create-diff-object: fix __UNIQUE_ID() variable correlation
kpatch_mangled_strcmp() only ignores the digits after the period, but in
the case of __UNIQUE_ID(), the symbol names have random digits before
the period due to the use of . Make sure such symbols are
properly correlated.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Reference:https://github.com/dynup/kpatch/commit/901445a54fcecbd6852b79878e67153c5048602e
Conflict:NA
---
kpatch-build/create-diff-object.c | 32 +++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 1967bd80..839eba66 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -396,6 +396,35 @@ static bool has_digit_tail(char *tail)
return false;
}
+/*
+ * Hack for __UNIQUE_ID(). The following should match:
+ *
+ * __UNIQUE_ID_ddebug1131.186
+ * __UNIQUE_ID_ddebug1132.187
+ */
+static int __kpatch_unique_id_strcmp(char *s1, char *s2)
+{
+ /* match '__UNIQUE_ID_ddebug' */
+ while (*s1 == *s2) {
+ if (!*s1)
+ return 0;
+ s1++;
+ s2++;
+ }
+
+ /* skip digits before '.' or EOL */
+ while (isdigit(*s1))
+ s1++;
+ while (isdigit(*s2))
+ s2++;
+
+ if ((!*s1 || has_digit_tail(s1)) &&
+ (!*s2 || has_digit_tail(s2)))
+ return 0;
+
+ return 1;
+}
+
/*
* This is like strcmp, but for gcc-mangled symbols. It skips the comparison
* of any substring which consists of '.' followed by any number of digits.
@@ -409,6 +438,9 @@ static int kpatch_mangled_strcmp(char *s1, char *s2)
if (strstr(s1, ".str1."))
return strcmp(s1, s2);
+ if (!strncmp(s1, "__UNIQUE_ID_", 12))
+ return __kpatch_unique_id_strcmp(s1, s2);
+
while (*s1 == *s2) {
if (!*s1)
return 0;

View File

@ -0,0 +1,28 @@
From a79ebac2bf9e1d9e01b8641f1139c5b812a846d6 Mon Sep 17 00:00:00 2001
From: caixiaomeng <caixiaomeng2@huawei.com>
Date: Fri, 28 Feb 2025 09:47:06 +0800
Subject: [PATCH] fix rela.init.text section changed due to __BTF_id_ symbol
changed
---
kpatch-build/create-diff-object.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index d5126f8..2dceef9 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -428,7 +428,7 @@ static int kpatch_mangled_strcmp(char *s1, char *s2)
if (strstr(s1, ".str1."))
return strcmp(s1, s2);
- if (!strncmp(s1, "__UNIQUE_ID_", 12))
+ if (!strncmp(s1, "__UNIQUE_ID_", 12) || !strncmp(s1, "__BTF_ID_", 9))
return __kpatch_unique_id_strcmp(s1, s2);
while (*s1 == *s2) {
--
2.33.0

View File

@ -1,7 +1,7 @@
Name: kpatch
Epoch: 1
Version: 0.9.5
Release: 7
Release: 12
Summary: A Linux dynamic kernel patching infrastructure
License: GPLv2
@ -59,8 +59,16 @@ 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
Patch0047:0047-lookup-skip-duplicate-local-symbol-table-check-for-f.patch
Patch0048:0048-fix-sssnic-module-always-changes-kpatch-relying-on-s.patch
Patch0049:0049-adapt-kpatch_bundle_symbols-to-kernel-change-and-fix.patch
Patch0050:0050-create-diff-object-fix-__UNIQUE_ID-variable-correlation.patch
Patch0051:0051-fix-rela.init.text-section-changed-due-to-__BTF_id_-changed.patch
BuildRequires: gcc elfutils-libelf-devel kernel-devel git
%ifarch ppc64le
BuildRequires: gcc-plugin-devel
%endif
Requires: bc make gcc patch bison flex openssl-devel
Recommends: %{name}-help = %{version}-%{release}
@ -119,6 +127,36 @@ popd
%{_mandir}/man1/*.1.gz
%changelog
* Thu Mar 13 2025 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.5-12
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:backport upstream patch and fix rela.init.text section changed due to __BTF_id_ changed
* Fri Nov 8 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.5-11
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:adapt kpatch bundle symbols to kernel change
* Sat Jul 13 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.5-10
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:ignore sssnic module when building hotpatch to fix sssnic wrongly dependency of sssnic
* Wed Mar 13 2024 peng.zou <peng.zou@shingroup.cn> - 1:0.9.5-9
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:add gcc-plugin-devel to BuildRequires for ppc64le
* Mon Sep 25 2023 wangjiang <wangjiang37@h-partners.com> - 1:0.9.5-8
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix error in making hotpatch when local_match be empty
* Mon Oct 17 2022 Bin Hu<hubin73@huawei.com> -1:0.9.5-7
- Type:bugfix
- ID:NA