Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
faadcc8ccb
!140 [sync] PR-126: add gcc-c++ to BuildRequires for ppc64le
From: @openeuler-sync-bot 
Reviewed-by: @zhujianwei001 
Signed-off-by: @zhujianwei001
2024-06-14 07:55:17 +00:00
hefq343
03dbe4213d add gcc-c++ to BuildRequires for ppc64le
Signed-off-by: hefq343 <fengqing.he@shingroup.cn>
(cherry picked from commit ae8f63053459a25b96be8033b71fcb7fc1a50113)
2024-06-14 14:50:38 +08:00
openeuler-ci-bot
74c08a80fd
!112 add gcc-plugin-devel to BuildRequires for ppc64le
From: @peng_zou 
Reviewed-by: @xiezhipeng1 
Signed-off-by: @xiezhipeng1
2024-03-13 07:54:49 +00:00
邹鹏
735d67ea8f add gcc-plugin-devel to BuildRequires for ppc64le 2024-03-13 15:36:08 +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
openeuler-ci-bot
3821190e83
!79 kpatch: sync patch from master to openEuler-22.03-LTS-Next
From: @hubin95 
Reviewed-by: @xiezhipeng1 
Signed-off-by: @xiezhipeng1
2022-10-18 02:15:52 +00:00
Bin Hu
542c1441d6 kpatch: sync patch from master to openEuler-22.03-LTS-Next
Signed-off-by: Bin Hu <hubin73@huawei.com>
2022-10-17 22:11:30 +08:00
openeuler-ci-bot
fa499b9bf6
!68 sync patch from master to openEuler-22.03-LTS-Next
From: @hubin95 
Reviewed-by: @xiezhipeng1 
Signed-off-by: @xiezhipeng1
2022-07-14 02:54:50 +00:00
Bin Hu
7ed7b12d3b sync patch from master to openEuler-22.03-LTS-Next
Signed-off-by: Bin Hu <hubin73@huawei.com>
2022-07-12 17:36:09 +08:00
21 changed files with 807 additions and 8 deletions

View File

@ -0,0 +1,27 @@
From 5b34dae2eaf57c33beb5cd4e3972a4580259a5fc Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:26:25 +0800
Subject: [PATCH] livepatch-patch-hook: disable HAVE_SIMPLE_ENABLE to keep
register and unregister step of hotpatch
Signed-off-by: Bin Hu <hubin73@huawei.com>
---
kmod/patch/livepatch-patch-hook.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/kmod/patch/livepatch-patch-hook.c b/kmod/patch/livepatch-patch-hook.c
index 9e56fe3..b565a6a 100644
--- a/kmod/patch/livepatch-patch-hook.c
+++ b/kmod/patch/livepatch-patch-hook.c
@@ -70,8 +70,6 @@
RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(8, 2)
# define HAVE_SIMPLE_ENABLE
# endif
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
-# define HAVE_SIMPLE_ENABLE
#endif
#ifdef RHEL_RELEASE_CODE
--
2.31.0.windows.1

View File

@ -0,0 +1,51 @@
From f435e99fc2652cd6263f3a2fe02b0947a5279a82 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:27:28 +0800
Subject: [PATCH 2/9] kpatch-build: add KBUILD_MODPOST_WARN=1 to avoid modpost
undefined error
Signed-off-by: hubin <hubin73@huawei.com>
---
kpatch-build/kpatch-build | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 6a9e818..ba33a3e 100644
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -1030,9 +1030,9 @@ fi
# $TARGETS used as list, no quotes.
# shellcheck disable=SC2086
if [[ -z "$USERMODBUILDDIR" ]]; then
- make "${MAKEVARS[@]}" "-j$CPUS" $TARGETS 2>&1 | logger || die
+ KBUILD_MODPOST_WARN=1 make "${MAKEVARS[@]}" "-j$CPUS" $TARGETS 2>&1 | logger || die
else
- make "${MAKEVARS[@]}" -C "$USERMODBUILDDIR" M="$USERMODBUILDDIR" $USERMODFLAGS "-j$CPUS" $TARGETS 2>&1 | logger || die
+ KBUILD_MODPOST_WARN=1 make "${MAKEVARS[@]}" -C "$USERMODBUILDDIR" M="$USERMODBUILDDIR" $USERMODFLAGS "-j$CPUS" $TARGETS 2>&1 | logger || die
fi
# Save original module symvers
@@ -1175,9 +1175,9 @@ for i in $FILES; do
remove_patches
cd "$SRCDIR" || die
if [ -z "$USERMODBUILDDIR" ];then
- make "-j$CPUS" $TARGETS 2>&1 | logger || die
+ KBUILD_MODPOST_WARN=1 make "-j$CPUS" $TARGETS 2>&1 | logger || die
else
- make -C "$USERMODBUILDDIR" M="$USERMODBUILDDIR" $USERMODFLAGS "-j$CPUS" $TARGETS 2>&1 | logger || die
+ KBUILD_MODPOST_WARN=1 make -C "$USERMODBUILDDIR" M="$USERMODBUILDDIR" $USERMODFLAGS "-j$CPUS" $TARGETS 2>&1 | logger || die
fi
cp ${KOBJFILE} ${KOBJFILE_PATH}
apply_patches
@@ -1297,7 +1297,7 @@ KBUILD_EXTRA_SYMBOLS="$KBUILD_EXTRA_SYMBOLS" \
KPATCH_LDFLAGS="$KPATCH_LDFLAGS"
save_env
-make "${MAKEVARS[@]}" 2>&1 | logger || die
+KBUILD_MODPOST_WARN=1 make "${MAKEVARS[@]}" 2>&1 | logger || die
strip -g "$TEMPDIR/patch/$MODNAME.ko"
if [[ "$USE_KLP" -eq 1 ]]; then
--
2.31.0.windows.1

View File

@ -0,0 +1,29 @@
From f1de68ea87426e7ed65dc615a46f5ce1d15df994 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:27:52 +0800
Subject: [PATCH 3/9] kpatch-build: update find_parent_obj to avoid error that
two parent match same object
Signed-off-by: hubin <hubin73@huawei.com>
---
kpatch-build/kpatch-build | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index ba33a3e..ce163e5 100644
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -527,8 +527,8 @@ find_parent_obj() {
[[ "$num" -eq 1 ]] && last_deep_find="$(dirname "$parent")"
fi
if [[ "$num" -eq 0 ]]; then
- parent="$(find $USERMODBUILDDIR -name ".*.cmd" -print0 | xargs -0 grep -l "$grepname" | grep -Fv "$pdir/.${file}.cmd" | head -n1)"
- num="$(find $USERMODBUILDDIR -name ".*.cmd" -print0 | xargs -0 grep -l "$grepname" | grep -Fvc "$pdir/.${file}.cmd")"
+ parent="$(find $USERMODBUILDDIR -name ".*.cmd" -print0 | xargs -0 grep -l "$grepname" | filter_parent_obj "$pdir" "${file}" | head -n1)"
+ num="$(find $USERMODBUILDDIR -name ".*.cmd" -print0 | xargs -0 grep -l "$grepname" | filter_parent_obj "$pdir" "${file}" | wc -l)"
[[ "$num" -eq 1 ]] && last_deep_find="$(dirname "$parent")"
fi
else
--
2.31.0.windows.1

View File

@ -0,0 +1,34 @@
From b1be16f5c42bae41f15a2579cb6ce39406648e19 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:00 +0800
Subject: [PATCH 4/9] create-diff-object: fix segment fault when using
KPATCH_FORCE_UNSAFE
Signed-off-by: hubin <hubin73@huawei.com>
---
kpatch-build/create-diff-object.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index bbb40ed..2cca6f3 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -1969,9 +1969,14 @@ static void kpatch_include_force_elements(struct kpatch_elf *kelf)
continue;
}
/* .rela.kpatch.force */
- list_for_each_entry(rela, &sec->relas, list)
+ list_for_each_entry(rela, &sec->relas, list) {
+ if (rela->sym->status != CHANGED) {
+ ERROR("function '%s' marked with KPATCH_FORCE_UNSAFE, but not changed! check your patch.\n",
+ rela->sym->name);
+ }
log_normal("function '%s' marked with KPATCH_FORCE_UNSAFE!\n",
rela->sym->name);
+ }
}
}
--
2.31.0.windows.1

View File

@ -0,0 +1,27 @@
From 83b98afd69c8be39587bfcd2260f03b2b3082a94 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:17 +0800
Subject: [PATCH 5/9] kpatch-macros: replace __section with __kpatch_section in
kpatch macro definition
Signed-off-by: hubin <hubin73@huawei.com>
---
kmod/patch/kpatch-macros.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kmod/patch/kpatch-macros.h b/kmod/patch/kpatch-macros.h
index ee455d2..c20b061 100644
--- a/kmod/patch/kpatch-macros.h
+++ b/kmod/patch/kpatch-macros.h
@@ -13,7 +13,7 @@
#endif
#define KPATCH_IGNORE_STATIC(_static) \
- char *__UNIQUE_ID(kpatch_ignore_static_) __section(.kpatch.ignore.statics) = _static;
+ char *__UNIQUE_ID(kpatch_ignore_static_) __kpatch_section(.kpatch.ignore.statics) = _static;
/*
--
2.31.0.windows.1

View File

@ -0,0 +1,35 @@
From 41334ab046ad2c89324b61f76b262228a6bc36ad Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:26 +0800
Subject: [PATCH 6/9] create-diff-object: ignore changed of section
__patchable_function_entries
Linux 5.10 aarch64 uses -fpatchable-function-entry=N to generate N NOPs at the
beginning of each function, Section __patchable_function_entries is generated
to record the starting address of these NOPs.
Section __patchable_function_entries will change if the number of functions
changed during making hotpatch, here we just ignore the change of this section.
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 2cca6f3..8d3f377 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -3062,7 +3062,8 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf,
list_for_each_entry(sec, &kelf->sections, list) {
if (strcmp(sec->name, "__tracepoints") &&
strcmp(sec->name, "__tracepoints_ptrs") &&
- strcmp(sec->name, "__tracepoints_strings"))
+ strcmp(sec->name, "__tracepoints_strings") &&
+ strcmp(sec->name, "__patchable_function_entries"))
continue;
sec->status = SAME;
--
2.31.0.windows.1

View File

@ -0,0 +1,27 @@
From e1b12b68efc7de9e3e3db52ceda2c1b713dc7cb7 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:34 +0800
Subject: [PATCH 7/9] create-diff-object: fix null pointer dereference in
kpatch_ignore_debug_section
Signed-off-by: hubin <hubin73@huawei.com>
---
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 8d3f377..03c877e 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -2796,7 +2796,7 @@ static void kpatch_ignore_debug_sections(struct kpatch_elf *kelf)
if (is_debug_section(sec)) {
sec->include = 0;
sec->status = SAME;
- if (!is_rela_section(sec)) {
+ if (!is_rela_section(sec) && sec->secsym) {
sec->secsym->include = 0;
sec->secsym->status = SAME;
}
--
2.31.0.windows.1

View File

@ -0,0 +1,36 @@
From de34b86536bde114f481a73fdbf2f58b643c3e48 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:46 +0800
Subject: [PATCH 8/9] create-diff-object: ignore .note.gnu.property section
Linux GABI introduced new .note.gnu.property section which contains a program
property note which describes special handling requirements for linker and run-time loader.
Linux GABI specifies 2 types of entries:
GNU_PROPERTY_STACK_SIZE and GNU_PROPERTY_NO_COPY_ON_PROTECTED
These entries should not take effect when using live-patching, thus, ignore the change of
this section
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 03c877e..c2ecefa 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -3063,7 +3063,8 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf,
if (strcmp(sec->name, "__tracepoints") &&
strcmp(sec->name, "__tracepoints_ptrs") &&
strcmp(sec->name, "__tracepoints_strings") &&
- strcmp(sec->name, "__patchable_function_entries"))
+ strcmp(sec->name, "__patchable_function_entries") &&
+ strcmp(sec->name, ".note.gnu.property"))
continue;
sec->status = SAME;
--
2.31.0.windows.1

View File

@ -0,0 +1,27 @@
From 19b6926284ad2811f6de0ec29e0b45f3ae8b09dd Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 15:28:55 +0800
Subject: [PATCH 9/9] create-diff-object: skip creating .kpatch.arch section
for sections with empty secsym
Signed-off-by: hubin <hubin73@huawei.com>
---
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 c2ecefa..6b46e1f 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -2952,7 +2952,7 @@ static void kpatch_create_kpatch_arch_section(struct kpatch_elf *kelf, char *obj
continue;
sec = find_section_by_name(&kelf->sections, special->name);
- if (!sec)
+ if (!sec || !sec->secsym)
continue;
/* entries[index].sec */
--
2.31.0.windows.1

View File

@ -0,0 +1,27 @@
From 72d80c02e16d7558bea6512116bac2b9461bf879 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Tue, 10 May 2022 16:12:29 +0800
Subject: [PATCH] kpatch-build: do not copy linux scripts when building OOT
module hotpatch
Signed-off-by: hubin <hubin73@huawei.com>
---
kpatch-build/kpatch-build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index ce163e5..dc5f5a5 100644
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -955,7 +955,7 @@ grep -q "CONFIG_GCC_PLUGIN_RANDSTRUCT=y" "$CONFIGFILE" && die "kernel option 'CO
# support extended ELF sections. Disable the BTF typeinfo generation in
# link-vmlinux.sh and Makefile.modfinal since kpatch doesn't care about
# that anyway.
-if grep -q "CONFIG_DEBUG_INFO_BTF=y" "$CONFIGFILE" ; then
+if grep -q "CONFIG_DEBUG_INFO_BTF=y" "$CONFIGFILE" && [[ -z "$OOT_MODULE" ]] ; then
cp -f "$SRCDIR/scripts/link-vmlinux.sh" "$TEMPDIR/link-vmlinux.sh" || die
sed -i 's/CONFIG_DEBUG_INFO_BTF/DISABLED_FOR_KPATCH_BUILD/g' "$SRCDIR"/scripts/link-vmlinux.sh || die
--
2.31.0.windows.1

View File

@ -0,0 +1,37 @@
From ff93b567f3cff56e3f0c668258499acb1d511865 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Mon, 23 May 2022 17:00:37 +0800
Subject: [PATCH] create-diff-object: ignore change of certain special sections
Signed-off-by: hubin <hubin73@huawei.com>
---
kpatch-build/create-diff-object.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 6b46e1f..7fabf4d 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -3076,6 +3076,19 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf,
}
}
+ list_for_each_entry(sec, &kelf->sections, list) {
+ if (strcmp(sec->name, "__patchable_function_entries") &&
+ strcmp(sec->name, ".note.gnu.property"))
+ continue;
+
+ sec->status = SAME;
+ sec->include = 0;
+ if (sec->rela) {
+ sec->rela->status = SAME;
+ sec->rela->include = 0;
+ }
+ }
+
kpatch_regenerate_orc_sections(kelf);
}
--
2.31.0.windows.1

View File

@ -0,0 +1,27 @@
From 556db3ad9deab83942621e56accc711427224ca5 Mon Sep 17 00:00:00 2001
From: hubin <hubin73@huawei.com>
Date: Mon, 23 May 2022 17:08:50 +0800
Subject: [PATCH] create-diff-object: allow __jump_table section change for
module hotpatch
Signed-off-by: hubin <hubin73@huawei.com>
---
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 7fabf4d..d7a6789 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -3493,7 +3493,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
* special section init code (e.g., apply_paravirt)
* runs due to late module patching.
*/
- if (!KLP_ARCH && !vmlinux && special)
+ if (!KLP_ARCH && !vmlinux && special && strcmp(sec->base->name, "__jump_table"))
ERROR("unsupported dynrela reference to symbol '%s' in module-specific special section '%s'",
rela->sym->name, sec->base->name);
--
2.31.0.windows.1

View File

@ -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

View 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

View 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

View File

@ -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

View File

@ -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

View File

@ -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

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

@ -1,7 +1,7 @@
Name: kpatch
Epoch: 1
Version: 0.9.5
Release: 5
Release: 10
Summary: A Linux dynamic kernel patching infrastructure
License: GPLv2
@ -41,8 +41,30 @@ Patch0025:0025-create-diff-object-update-for-__already_done.patch
Patch0026:0026-kpatch-build-Add-missing-allocation-failure-checks.patch
Patch0027:0027-create-diff-object-add-support-for-.retpoline_sites-.patch
Patch0028:0028-Fix-sym-type-condition-in-locals_match.patch
Patch0029:0029-livepatch-patch-hook-disable-HAVE_SIMPLE_ENABLE-to-k.patch
Patch0030:0030-kpatch-build-add-KBUILD_MODPOST_WARN-1-to-avoid-modp.patch
Patch0031:0031-kpatch-build-update-find_parent_obj-to-avoid-error-t.patch
Patch0032:0032-create-diff-object-fix-segment-fault-when-using-KPAT.patch
Patch0033:0033-kpatch-macros-replace-__section-with-__kpatch_sectio.patch
Patch0034:0034-create-diff-object-ignore-changed-of-section-__patch.patch
Patch0035:0035-create-diff-object-fix-null-pointer-dereference-in-k.patch
Patch0036:0036-create-diff-object-ignore-.note.gnu.property-section.patch
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
Patch0047:0047-lookup-skip-duplicate-local-symbol-table-check-for-f.patch
BuildRequires: gcc elfutils-libelf-devel kernel-devel git
%ifarch ppc64le
BuildRequires: gcc-plugin-devel gcc-c++
%endif
Requires: bc make gcc patch bison flex openssl-devel
Recommends: %{name}-help = %{version}-%{release}
@ -101,6 +123,36 @@ popd
%{_mandir}/man1/*.1.gz
%changelog
* Fri May 10 2024 hefq343 <fengqing.he@shingroup.cn> - 1:0.9.5-10
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:add gcc-c++ to BuildRequires for ppc64le
* 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
- 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
- SUG:NA
- DESC:sync patch from master to openEuler-22.03-LTS-Next
* Wed Mar 30 2022 Zhipeng Xie<xiezhipeng1@huawei.com> -1:0.9.5-5
- Type:clean code
- ID:NA

View File

@ -196,8 +196,8 @@ function fn_check_jobs()
#########################################################
function fn_check_patch(){
local l_patch=$1
if [ ! -f $1 ];then
echo "error:patch file $1 not exist"
if [ ! -f "$1" ];then
echo "error:patch file $1 does not exist"
return 1
fi
G_PATCHFILE=$l_patch
@ -232,7 +232,7 @@ function fn_check_kernelsrc()
local l_kernelsrc=$1
if [ ! -d "$l_kernelsrc" ];then
echo "error: kernel src $l_kernelsrc is not exist, check kernel src failed"
echo "error: kernel src $l_kernelsrc does not exist, check kernel src failed"
return 1
fi
G_KERNEL_SRC=$l_kernelsrc
@ -250,7 +250,7 @@ function fn_check_modulesrc()
local l_modulesrc=$1
if [ ! -d "$l_modulesrc" ];then
echo "error: module src $l_modulesrc is not exist, check module src failed"
echo "error: module src $l_modulesrc does not exist, check module src failed"
return 1
fi
echo "$l_modulesrc" | grep -q ^/
@ -272,7 +272,7 @@ function fn_check_makefile()
local l_module_makefile=$1
if [ ! -f "$l_module_makefile" ] && [ "$(basename $l_module_makefile)" = "Makefile" ];then
echo "error: module makefile $l_module_makefile is not exist or makefile name is not Makefile, check module makefile failed"
echo "error: module makefile $l_module_makefile does not exist or makefile name is not Makefile, check module makefile failed"
return 1
fi
echo "$l_module_makefile" | grep -q ^/
@ -294,7 +294,7 @@ function fn_check_extra_flags()
local l_extra_flags=$1
if [ ! -f "$l_extra_flags" ];then
echo "error: extra flags file $l_extra_flags is not exist, check extra flags failed"
echo "error: extra flags file $l_extra_flags does not exist, check extra flags failed"
return 1
fi
G_EXT_FLAGS="`readlink -f ${l_extra_flags}`"
@ -508,7 +508,7 @@ function fn_makepatch()
echo "error: do not modify the header file"
return 1
fi
if [ -f $G_PATCHFILE ];then
if [ -f "$G_PATCHFILE" ];then
echo "make patch $G_PATCHFILE"
else
echo "no change detected"