!40 create-diff-object: error on detect new/changed ALTINSTR_ENTRY_CB

From: @xiezhipeng1
Reviewed-by: @pecs
Signed-off-by: @pecs
This commit is contained in:
openeuler-ci-bot 2021-08-21 08:54:38 +00:00 committed by Gitee
commit 6dd42c9ee8
2 changed files with 60 additions and 2 deletions

View File

@ -0,0 +1,51 @@
From 6acafe200135f0299f4834ba7dcea5d582d75a0a Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Sat, 21 Aug 2021 04:07:33 -0400
Subject: [PATCH] create-diff-object: error on detect new/changed
ALTINSTR_ENTRY_CB
ALTINSTR_ENTRY_CB have callback which reference to other function
in .altinstructions, currently kpatch don't support new/changed
ALTINSTR_ENTRY_CB, so error on detect this case.
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
---
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 d20f2f1..07a1815 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -2227,6 +2227,8 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf,
* aren't sorted (e.g. .rela.fixup), so go through the entire
* rela list each time.
*/
+ int i = 0;
+ struct rela *lastrela = NULL;
list_for_each_entry_safe(rela, safe, &sec->relas, list) {
if (rela->offset >= src_offset &&
rela->offset < src_offset + group_size) {
@@ -2239,12 +2241,19 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf,
rela->sym->include = 1;
+ if (!strcmp(special->name, ".altinstructions")) {
+ if (i % 2 == 1 && strcmp(rela->sym->name , ".altinstr_replacement")) {
+ DIFF_FATAL("%s have entry in .altinstructions which have callback %s instead of new instruction", lastrela->sym->name, rela->sym->name);
+ }
+ }
if (!strcmp(special->name, ".fixup"))
kpatch_update_ex_table_addend(kelf, special,
src_offset,
dest_offset,
group_size);
+ lastrela = rela;
+ i++;
}
}
--
2.27.0

View File

@ -1,7 +1,7 @@
Name: kpatch
Epoch: 1
Version: 0.9.1
Release: 15
Release: 16
Summary: A Linux dynamic kernel patching infrastructure
License: GPLv2
@ -40,6 +40,7 @@ Patch0025:0025-Fix-relocation-not-resolved-when-new-functions-expor.patch
Patch0026:0026-support-remove-static-variables-using-KPATCH_IGNORE_.patch
Patch0027:0027-create-build-diff-support-for-.cold-functions-with-n.patch
Patch0028:0028-lookup-Add-__UNIQUE_ID_-to-maybe_discarded_sym-list.patch
Patch0029:0029-create-diff-object-error-on-detect-new-changed-ALTIN.patch
BuildRequires: gcc elfutils-libelf-devel uname-build-checks kernel-devel git
Requires: bc make gcc patch bison flex openssl-devel
@ -100,7 +101,13 @@ popd
%{_mandir}/man1/*.1.gz
%changelog
* Fri Jul 23 2021 Xinpeng Liu<liuxp11@chinatelecom.cn> -1:0.9.1-15
* Sat Aug 21 2021 Zhipeng Xie<xiezhipeng1@huawei.com> -1:0.9.1-16
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:create-diff-object: error on detect new/changed ALTINSTR_ENTRY_CB
* Fri Jul 23 2021 Zhipeng Xie<xiezhipeng1@huawei.com> -1:0.9.1-15
- Type:enhancement
- ID:NA
- SUG:NA