kpatch: sync patch from master to openEuler-22.03-LTS-Next
Signed-off-by: Bin Hu <hubin73@huawei.com>
This commit is contained in:
parent
7ed7b12d3b
commit
542c1441d6
@ -0,0 +1,43 @@
|
||||
From ec538d436364293b15e41f3c2c2a8ab389c7b043 Mon Sep 17 00:00:00 2001
|
||||
From: tangbin <tangbin@cmss.chinamobile.com>
|
||||
Date: Mon, 5 Sep 2022 12:09:06 -0400
|
||||
Subject: [PATCH] livepatch-patch-hook: fix kpatch-build error which do not
|
||||
support ftrace
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
When using the kernel 5.10.0-60.18.0.50.oe2203 in x86_64, and chose the
|
||||
livepatch with ftrace, it will show not support for this feature, which
|
||||
is not allowed, the error displays as follows:
|
||||
|
||||
In file included from /root/.kpatch/tmp/patch/patch-hook.c:21:
|
||||
/root/.kpatch/tmp/patch/livepatch-patch-hook.c: In function ‘patch_init’:
|
||||
/root/.kpatch/tmp/patch/livepatch-patch-hook.c:606:8: error: implicit declaration of function ‘klp_register_patch’; did you mean ‘klp_enable_patch’? [-Werror=implicit-function-declaration]
|
||||
606 | ret = klp_register_patch(lpatch);
|
||||
| ^~~~~~~~~~~~~~~~~~
|
||||
| klp_enable_patch
|
||||
|
||||
So fix this problem.
|
||||
|
||||
Signed-off-by: tangbin <tangbin@cmss.chinamobile.com>
|
||||
---
|
||||
kmod/patch/livepatch-patch-hook.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/kmod/patch/livepatch-patch-hook.c b/kmod/patch/livepatch-patch-hook.c
|
||||
index b565a6a..5d8780c 100644
|
||||
--- a/kmod/patch/livepatch-patch-hook.c
|
||||
+++ b/kmod/patch/livepatch-patch-hook.c
|
||||
@@ -70,6 +70,8 @@
|
||||
RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(8, 2)
|
||||
# define HAVE_SIMPLE_ENABLE
|
||||
# endif
|
||||
+# elif (defined(CONFIG_LIVEPATCH_FTRACE))
|
||||
+# define HAVE_SIMPLE_ENABLE
|
||||
#endif
|
||||
|
||||
#ifdef RHEL_RELEASE_CODE
|
||||
--
|
||||
2.18.4
|
||||
|
||||
79
0042-kpatch-build-fix-loading-error-in-aarch64.patch
Normal file
79
0042-kpatch-build-fix-loading-error-in-aarch64.patch
Normal file
@ -0,0 +1,79 @@
|
||||
From fd5e883eae4d2187e1c2cd6d66b2cf6376183d0e Mon Sep 17 00:00:00 2001
|
||||
From: tangbin <tangbin_yewu@cmss.chinamobile.com>
|
||||
Date: Tue, 6 Sep 2022 11:03:02 -0400
|
||||
Subject: [PATCH] kpatch-build: fix loading error in aarch64
|
||||
|
||||
When using the kernel version 4.19.90-2112.8.0.0131.oe1 in
|
||||
openEuler-22.03-LTS-aarch64, there are some errors in dmesg
|
||||
as follows:
|
||||
|
||||
[ 44.843180 < 38.388618>] klp_30: loading out-of-tree module taints kernel.
|
||||
[ 44.843183 < 0.000003>] klp_30: tainting kernel with TAINT_LIVEPATCH
|
||||
[ 44.843325 < 0.000142>] klp_30: module verification failed: signature and/or required key missing - t ainting kernel
|
||||
[ 44.844007 < 0.000682>] WARNING: CPU: 20 PID: 7708 at kernel/trace/ftrace.c:2040 ftrace_bug+0x74/0x25 8
|
||||
[ 44.844009 < 0.000002>] Modules linked in: nft_objref nf_conntrack_tftp tun nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nf_tables_set nf_tabl es ebtable_nat ebtable_broute bridge stp llc ip6table_nat nf_nat_ipv6 ip6table_mangle ip6table_raw ip6table _security iptable_nat nf_nat_ipv4 nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c iptable_mangl e iptable_raw iptable_security rfkill ip_set nfnetlink ebtable_filter ebtables ip6table_filter ip6_tables i ptable_filter ip_tables sunrpc sg vfat fat sch_fq_codel fuse ext4 mbcache jbd2 sr_mod sd_mod cdrom virtio_n et virtio_gpu net_failover virtio_scsi failover aes_ce_blk crypto_simd cryptd aes_ce_cipher ghash_ce sha2_c e sha256_arm64 sha1_ce virtio_pci virtio_mmio virtio_ring virtio dm_mirror dm_region_hash
|
||||
[ 44.844035 < 0.000026>] dm_log dm_mod
|
||||
[ 44.844040 < 0.000005>] CPU: 20 PID: 7708 Comm: insmod Kdump: loaded Tainted: G OE K 4.19 .90+ #1
|
||||
[ 44.844041 < 0.000001>] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
|
||||
[ 44.844043 < 0.000002>] pstate: 60400005 (nZCv daif +PAN -UAO)
|
||||
[ 44.844045 < 0.000002>] pc : ftrace_bug+0x74/0x258
|
||||
[ 44.844048 < 0.000003>] lr : ftrace_update_code.isra.0+0xe0/0x114
|
||||
[ 44.844048 < 0.000000>] sp : ffff00002366fc20
|
||||
[ 44.844049 < 0.000001>] x29: ffff00002366fc20 x28: ffff0000093b5d40
|
||||
[ 44.844050 < 0.000001>] x27: ffff0000080a2e38 x26: ffff0000093b5000
|
||||
[ 44.844051 < 0.000001>] x25: ffff000009070028 x24: 0000000002000000
|
||||
[ 44.844053 < 0.000002>] x23: ffff000002270080 x22: ffff000009725000
|
||||
[ 44.844054 < 0.000001>] x21: ffff000008df6650 x20: ffff000002250514
|
||||
[ 44.844055 < 0.000001>] x19: ffff8000c9990050 x18: 0000000000000000
|
||||
[ 44.844056 < 0.000001>] x17: 0000000000000000 x16: 0000000000000000
|
||||
[ 44.844057 < 0.000001>] x15: ffff000002250514 x14: ff00000000000000
|
||||
[ 44.844058 < 0.000001>] x13: 0000000000000000 x12: 0000000000000000
|
||||
[ 44.844059 < 0.000001>] x11: fefefefefefefeff x10: 0000000000000000
|
||||
[ 44.844060 < 0.000001>] x9 : 0000000000000000 x8 : ffff8000c9212000
|
||||
[ 44.844061 < 0.000001>] x7 : ffff00002366f7f0 x6 : ffff00002366fc08
|
||||
[ 44.844062 < 0.000001>] x5 : ffff00002366fc08 x4 : 000000000fffffff
|
||||
[ 44.844063 < 0.000001>] x3 : ffff0000093b5d40 x2 : ffff0000093b5000
|
||||
[ 44.844064 < 0.000001>] x1 : ffff0000080a2e60 x0 : 00000000ffffffea
|
||||
[ 44.844066 < 0.000002>] Call trace:
|
||||
[ 44.844068 < 0.000002>] ftrace_bug+0x74/0x258
|
||||
[ 44.844069 < 0.000001>] ftrace_update_code.isra.0+0xe0/0x114
|
||||
[ 44.844071 < 0.000002>] ftrace_process_locs.isra.0+0x118/0x1f0
|
||||
[ 44.844072 < 0.000001>] ftrace_module_init+0x2c/0x34
|
||||
[ 44.844078 < 0.000006>] load_module+0x3f4/0x820
|
||||
[ 44.844080 < 0.000002>] __se_sys_finit_module+0xb8/0x120
|
||||
[ 44.844081 < 0.000001>] __arm64_sys_finit_module+0x28/0x34
|
||||
[ 44.844084 < 0.000003>] el0_svc_common+0x118/0x170
|
||||
[ 44.844085 < 0.000001>] el0_svc_handler+0x3c/0x80
|
||||
[ 44.844088 < 0.000003>] el0_svc+0x8/0x640
|
||||
[ 44.844090 < 0.000002>] ---[ end trace dab33fa797cbe7ee ]---
|
||||
[ 44.844090 < 0.000000>] ftrace failed to modify
|
||||
[ 44.844093 < 0.000003>] [] 0xffff000002250514
|
||||
[ 44.844093 < 0.000000>] actual: 1f:20:03:d5
|
||||
[ 44.844096 < 0.000003>] Initializing ftrace call sites
|
||||
[ 44.844097 < 0.000001>] ftrace record flags: 2000000
|
||||
[ 44.844098 < 0.000001>] (0)
|
||||
expected tramp: ffff0000080a2e3c
|
||||
|
||||
Thus, fix this problem.
|
||||
|
||||
Signed-off-by: tangbin <tangbin_yewu@cmss.chinamobile.com>
|
||||
---
|
||||
kpatch-build/kpatch-elf.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c
|
||||
index 2df9105..c84d865 100644
|
||||
--- a/kpatch-build/kpatch-elf.c
|
||||
+++ b/kpatch-build/kpatch-elf.c
|
||||
@@ -325,7 +325,7 @@ static void kpatch_find_func_profiling_calls(struct kpatch_elf *kelf)
|
||||
list_for_each_entry(sym, &kelf->symbols, list) {
|
||||
if (sym->type != STT_FUNC || !sym->sec || !sym->sec->rela)
|
||||
continue;
|
||||
-#if defined(__powerpc64__) || defined(__aarch64__)
|
||||
+#if defined(__powerpc64__)
|
||||
list_for_each_entry(rela, &sym->sec->rela->relas, list) {
|
||||
if (!strcmp(rela->sym->name, "_mcount")) {
|
||||
sym->has_func_profiling = 1;
|
||||
--
|
||||
2.18.4
|
||||
|
||||
43
0043-kpatch-build-Remove-duplicate-functions.patch
Normal file
43
0043-kpatch-build-Remove-duplicate-functions.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From 81a48ca6a060cf006cf9eec309e726c4333a9d46 Mon Sep 17 00:00:00 2001
|
||||
From: tangbin <tangbin_yewu@cmss.chinamobile.com>
|
||||
Date: Tue, 6 Sep 2022 11:46:41 -0400
|
||||
Subject: [PATCH] kpatch-build: Remove duplicate functions
|
||||
|
||||
We find that there are duplicate functions of "use_klp_arch()" &
|
||||
"rhel_kernel_version_gte", and one of them are useless, so remove
|
||||
them.
|
||||
|
||||
Signed-off-by: tangbin <tangbin_yewu@cmss.chinamobile.com>
|
||||
---
|
||||
kpatch-build/kpatch-build | 15 ---------------
|
||||
1 file changed, 15 deletions(-)
|
||||
|
||||
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
|
||||
index dc5f5a5..6a0645a 100755
|
||||
--- a/kpatch-build/kpatch-build
|
||||
+++ b/kpatch-build/kpatch-build
|
||||
@@ -198,21 +198,6 @@ rhel_kernel_version_gte() {
|
||||
[ "${ARCHVERSION}" = "$(echo -e "${ARCHVERSION}\\n$1" | sort -rV | head -n1)" ]
|
||||
}
|
||||
|
||||
-# klp.arch relocations were supported prior to v5.8
|
||||
-# and prior to 4.18.0-240.el8
|
||||
-use_klp_arch()
|
||||
-{
|
||||
- if kernel_is_rhel; then
|
||||
- ! rhel_kernel_version_gte 4.18.0-240.el8
|
||||
- else
|
||||
- ! kernel_version_gte 5.8.0
|
||||
- fi
|
||||
-}
|
||||
-
|
||||
-rhel_kernel_version_gte() {
|
||||
- [ "${ARCHVERSION}" = "$(echo -e "${ARCHVERSION}\\n$1" | sort -rV | head -n1)" ]
|
||||
-}
|
||||
-
|
||||
# klp.arch relocations were supported prior to v5.8
|
||||
# and prior to 4.18.0-284.el8
|
||||
use_klp_arch()
|
||||
--
|
||||
2.18.4
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
From 6b79df49055abbccd3033fbec52085b8a9d7b250 Mon Sep 17 00:00:00 2001
|
||||
From: hubin <hubin73@huawei.com>
|
||||
Date: Sun, 9 Oct 2022 10:34:52 +0800
|
||||
Subject: [PATCH] lookup: skip finding local symbols for object with no local
|
||||
symbols
|
||||
|
||||
Signed-off-by: hubin <hubin73@huawei.com>
|
||||
---
|
||||
kpatch-build/lookup.c | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c
|
||||
index b77d7a8..875605d 100644
|
||||
--- a/kpatch-build/lookup.c
|
||||
+++ b/kpatch-build/lookup.c
|
||||
@@ -166,6 +166,22 @@ static bool locals_match(struct lookup_table *table, int idx,
|
||||
return true;
|
||||
}
|
||||
|
||||
+static int count_local_symbol(struct list_head *sym_list)
|
||||
+{
|
||||
+ struct symbol *sym;
|
||||
+ int sym_num = 0;
|
||||
+
|
||||
+ list_for_each_entry(sym, sym_list, list) {
|
||||
+ if (sym->bind != STB_LOCAL)
|
||||
+ continue;
|
||||
+ if (sym->type != STT_FUNC && sym->type != STT_OBJECT)
|
||||
+ continue;
|
||||
+ sym_num++;
|
||||
+ }
|
||||
+
|
||||
+ return sym_num;
|
||||
+}
|
||||
+
|
||||
static void find_local_syms(struct lookup_table *table, struct symbol *file_sym,
|
||||
struct list_head *sym_list)
|
||||
{
|
||||
@@ -173,6 +189,9 @@ static void find_local_syms(struct lookup_table *table, struct symbol *file_sym,
|
||||
struct object_symbol *lookup_table_file_sym = NULL;
|
||||
int i;
|
||||
|
||||
+ if (count_local_symbol(sym_list) == 0)
|
||||
+ return;
|
||||
+
|
||||
for_each_obj_symbol(i, sym, table) {
|
||||
if (sym->type != STT_FILE)
|
||||
continue;
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
From 764baf9f38c15d48a7cacbafcad9b83b7a23d842 Mon Sep 17 00:00:00 2001
|
||||
From: hubin <hubin73@huawei.com>
|
||||
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 <jdobson@redhat.com>
|
||||
|
||||
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
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
From 594f0810329ca074d53399f6d1927aa87607c34a Mon Sep 17 00:00:00 2001
|
||||
From: hubin <hubin73@huawei.com>
|
||||
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 <hubin73@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
14
kpatch.spec
14
kpatch.spec
@ -1,7 +1,7 @@
|
||||
Name: kpatch
|
||||
Epoch: 1
|
||||
Version: 0.9.5
|
||||
Release: 6
|
||||
Release: 7
|
||||
Summary: A Linux dynamic kernel patching infrastructure
|
||||
|
||||
License: GPLv2
|
||||
@ -53,6 +53,12 @@ Patch0037:0037-create-diff-object-skip-creating-.kpatch.arch-sectio.patch
|
||||
Patch0038:0038-kpatch-build-do-not-copy-linux-scripts-when.patch
|
||||
Patch0039:0039-create-diff-object-ignore-change-of-certain.patch
|
||||
Patch0040:0040-create-diff-object-allow-__jump_table-section.patch
|
||||
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
|
||||
@ -113,6 +119,12 @@ popd
|
||||
%{_mandir}/man1/*.1.gz
|
||||
|
||||
%changelog
|
||||
* Mon Oct 17 2022 Bin Hu<hubin73@huawei.com> -1:0.9.5-7
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:sync patch from master to openEuler-22.03-LTS-Next
|
||||
|
||||
* Mon Jul 11 2022 Bin Hu<hubin73@huawei.com> -1:0.9.5-6
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user