!158 fix rela.init.text section changed due to _BTF_id changed
From: @pshysimon Reviewed-by: @hubin95 Signed-off-by: @hubin95
This commit is contained in:
commit
9db0e530bd
@ -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;
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
10
kpatch.spec
10
kpatch.spec
@ -1,7 +1,7 @@
|
|||||||
Name: kpatch
|
Name: kpatch
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Version: 0.9.5
|
Version: 0.9.5
|
||||||
Release: 11
|
Release: 12
|
||||||
Summary: A Linux dynamic kernel patching infrastructure
|
Summary: A Linux dynamic kernel patching infrastructure
|
||||||
|
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
@ -62,6 +62,8 @@ Patch0046:0046-create-diff-object-ignore-entsize-change-of-.return_.patch
|
|||||||
Patch0047:0047-lookup-skip-duplicate-local-symbol-table-check-for-f.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
|
Patch0048:0048-fix-sssnic-module-always-changes-kpatch-relying-on-s.patch
|
||||||
Patch0049:0049-adapt-kpatch_bundle_symbols-to-kernel-change-and-fix.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
|
BuildRequires: gcc elfutils-libelf-devel kernel-devel git
|
||||||
%ifarch ppc64le
|
%ifarch ppc64le
|
||||||
@ -125,6 +127,12 @@ popd
|
|||||||
%{_mandir}/man1/*.1.gz
|
%{_mandir}/man1/*.1.gz
|
||||||
|
|
||||||
%changelog
|
%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
|
* Fri Nov 8 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1:0.9.5-11
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user