update libcareplus to version 1.0.0-12
kpatch_process: fix possible double free. ptrace: fix NULL pointer access problem fix patched process crashing when acccess the global var fix probably restore cc symbol link fail when kill patch building uncourteous optimize: Remove unnecessary comparison code Signed-off-by: yezengruan <yezengruan@huawei.com> (cherry picked from commit f3d59711105eb667fa2f920958fcbdbb7068afd2)
This commit is contained in:
parent
3e69c6c2be
commit
eda47481b9
24
0014-kpatch_process-fix-possible-double-free.patch
Normal file
24
0014-kpatch_process-fix-possible-double-free.patch
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
From fdf172f68f2270306effda39211a4be5ca7e437e Mon Sep 17 00:00:00 2001
|
||||||
|
From: wangcichen <wangcichen_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Tue, 17 May 2022 16:40:26 +0800
|
||||||
|
Subject: [PATCH 1/5] kpatch_process: fix possible double free.
|
||||||
|
|
||||||
|
---
|
||||||
|
src/kpatch_process.c | 1 -
|
||||||
|
1 file changed, 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/kpatch_process.c b/src/kpatch_process.c
|
||||||
|
index 9d6daa4..a31f70c 100644
|
||||||
|
--- a/src/kpatch_process.c
|
||||||
|
+++ b/src/kpatch_process.c
|
||||||
|
@@ -682,7 +682,6 @@ process_list_threads(kpatch_process_t *proc,
|
||||||
|
t = realloc(pids, *alloc * sizeof(*pids));
|
||||||
|
if (t == NULL) {
|
||||||
|
kplogerror("Failed to (re)allocate memory for pids\n");
|
||||||
|
- closedir(dir);
|
||||||
|
goto dealloc;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
39
0015-ptrace-fix-NULL-pointer-access-problem.patch
Normal file
39
0015-ptrace-fix-NULL-pointer-access-problem.patch
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
From a45b9424cb7258c00211115191f74fbaf8f74285 Mon Sep 17 00:00:00 2001
|
||||||
|
From: wangcichen <wangcichen_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Mon, 23 May 2022 10:18:57 +0800
|
||||||
|
Subject: [PATCH 2/5] ptrace: fix NULL pointer access problem
|
||||||
|
|
||||||
|
---
|
||||||
|
src/arch/aarch64/arch_ptrace.c | 2 --
|
||||||
|
src/arch/x86/arch_ptrace.c | 2 --
|
||||||
|
2 files changed, 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/arch/aarch64/arch_ptrace.c b/src/arch/aarch64/arch_ptrace.c
|
||||||
|
index 774dc21..2227e95 100644
|
||||||
|
--- a/src/arch/aarch64/arch_ptrace.c
|
||||||
|
+++ b/src/arch/aarch64/arch_ptrace.c
|
||||||
|
@@ -465,8 +465,6 @@ kpatch_arch_ptrace_waitpid(kpatch_process_t *proc,
|
||||||
|
|
||||||
|
/* TODO: fix the latter by SINGLESTEPping such a thread with
|
||||||
|
* the original instruction in place */
|
||||||
|
- kperr("the thread ran out: %d, pc= %llx, expected = %lx\n", pid,
|
||||||
|
- regs.pc, pctx->execute_until);
|
||||||
|
errno = ESRCH;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
diff --git a/src/arch/x86/arch_ptrace.c b/src/arch/x86/arch_ptrace.c
|
||||||
|
index 9069484..9dede71 100644
|
||||||
|
--- a/src/arch/x86/arch_ptrace.c
|
||||||
|
+++ b/src/arch/x86/arch_ptrace.c
|
||||||
|
@@ -492,8 +492,6 @@ int kpatch_arch_ptrace_waitpid(kpatch_process_t *proc,
|
||||||
|
|
||||||
|
/* TODO: fix the latter by SINGLESTEPping such a thread with
|
||||||
|
* the original instruction in place */
|
||||||
|
- kperr("the thread ran out: %d, rip = %llx, expected = %lx\n", pid,
|
||||||
|
- regs.rip, pctx->execute_until);
|
||||||
|
errno = ESRCH;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
156
0016-fix-patched-process-crashing-when-acccess-the-global.patch
Normal file
156
0016-fix-patched-process-crashing-when-acccess-the-global.patch
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
From add4a57f47eb89acf4a471253654cc806aedaaf8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: ctyunsystem <ctyuncommiter05@chinatelecom.cn>
|
||||||
|
Date: Wed, 11 May 2022 10:20:26 +0800
|
||||||
|
Subject: [PATCH 3/5] fix patched process crashing when acccess the global var
|
||||||
|
which newly added
|
||||||
|
|
||||||
|
---
|
||||||
|
src/kpatch_gensrc.c | 20 +++++++++++++++++---
|
||||||
|
src/kpatch_patch.c | 6 +++---
|
||||||
|
tests/new_var/Makefile | 2 ++
|
||||||
|
tests/new_var/desc | 1 +
|
||||||
|
tests/new_var/new_var.c | 23 +++++++++++++++++++++++
|
||||||
|
tests/new_var/new_var.diff | 15 +++++++++++++++
|
||||||
|
6 files changed, 61 insertions(+), 6 deletions(-)
|
||||||
|
create mode 100644 tests/new_var/Makefile
|
||||||
|
create mode 100644 tests/new_var/desc
|
||||||
|
create mode 100644 tests/new_var/new_var.c
|
||||||
|
create mode 100644 tests/new_var/new_var.diff
|
||||||
|
|
||||||
|
diff --git a/src/kpatch_gensrc.c b/src/kpatch_gensrc.c
|
||||||
|
index bf1832a..67254d7 100644
|
||||||
|
--- a/src/kpatch_gensrc.c
|
||||||
|
+++ b/src/kpatch_gensrc.c
|
||||||
|
@@ -432,6 +432,20 @@ out:
|
||||||
|
|
||||||
|
/* ------------------------------------------ helpers -------------------------------------------- */
|
||||||
|
|
||||||
|
+static inline int page_shift(int n) {
|
||||||
|
+ int res = -1;
|
||||||
|
+
|
||||||
|
+ while(n) {
|
||||||
|
+ res++;
|
||||||
|
+ n >>= 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return res;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#define PAGE_SIZE getpagesize()
|
||||||
|
+#define PAGE_SHIFT page_shift(PAGE_SIZE)
|
||||||
|
+
|
||||||
|
static void change_section(struct kp_file *fout, struct section_desc *sect, int flags)
|
||||||
|
{
|
||||||
|
static int init_data_section = 0;
|
||||||
|
@@ -448,15 +462,15 @@ static void change_section(struct kp_file *fout, struct section_desc *sect, int
|
||||||
|
s = ".kpatch.text,\"ax\",@progbits";
|
||||||
|
else {
|
||||||
|
s = ".kpatch.data,\"aw\",@progbits";
|
||||||
|
- if (!init_data_section && (flags & FLAG_PUSH_SECTION)) {
|
||||||
|
+ if (!init_data_section) {
|
||||||
|
init_data_section = 1;
|
||||||
|
- align = ".p2align\t12";
|
||||||
|
+ align = ".p2align";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fout->f, "\t.%ssection %s\n", (flags & FLAG_PUSH_SECTION) ? "push" : "", s);
|
||||||
|
if (align)
|
||||||
|
- fprintf(fout->f, "\t%s\n", align);
|
||||||
|
+ fprintf(fout->f, "\t%s\t%d\n", align, PAGE_SHIFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_comm_args(struct kp_file *f, int l, kpstr_t *xname, int *sz, int *align)
|
||||||
|
diff --git a/src/kpatch_patch.c b/src/kpatch_patch.c
|
||||||
|
index d74299d..3b53a5a 100644
|
||||||
|
--- a/src/kpatch_patch.c
|
||||||
|
+++ b/src/kpatch_patch.c
|
||||||
|
@@ -372,9 +372,9 @@ object_apply_patch(struct object_file *o)
|
||||||
|
kp->jmp_offset = sz;
|
||||||
|
kpdebug("Jump table %d bytes for %d syms at offset 0x%x\n",
|
||||||
|
o->jmp_table->size, undef, kp->jmp_offset);
|
||||||
|
- sz = ROUND_UP(sz + o->jmp_table->size, 4096);
|
||||||
|
+ sz = ROUND_UP(sz + o->jmp_table->size, PAGE_SIZE);
|
||||||
|
}
|
||||||
|
- sz = ROUND_UP(sz, 4096);
|
||||||
|
+ sz = ROUND_UP(sz, PAGE_SIZE);
|
||||||
|
|
||||||
|
/* kpatch elf */
|
||||||
|
kp->elf_offset = sz;
|
||||||
|
@@ -386,7 +386,7 @@ object_apply_patch(struct object_file *o)
|
||||||
|
kp->user_undo = sz;
|
||||||
|
sz = ROUND_UP(sz + HUNK_SIZE * o->ninfo, 16);
|
||||||
|
|
||||||
|
- sz = ROUND_UP(sz, 4096);
|
||||||
|
+ sz = ROUND_UP(sz, PAGE_SIZE);
|
||||||
|
kp->kpatch_total_mem_sz = sz;
|
||||||
|
|
||||||
|
/*
|
||||||
|
diff --git a/tests/new_var/Makefile b/tests/new_var/Makefile
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..6dd4b69
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/tests/new_var/Makefile
|
||||||
|
@@ -0,0 +1,2 @@
|
||||||
|
+
|
||||||
|
+include ../makefile.inc
|
||||||
|
diff --git a/tests/new_var/desc b/tests/new_var/desc
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..4f8cd31
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/tests/new_var/desc
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+patch adds a new var
|
||||||
|
diff --git a/tests/new_var/new_var.c b/tests/new_var/new_var.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..3ed116a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/tests/new_var/new_var.c
|
||||||
|
@@ -0,0 +1,23 @@
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <unistd.h>
|
||||||
|
+
|
||||||
|
+void print_greetings_patched(int var)
|
||||||
|
+{
|
||||||
|
+ printf("Hello. This is a PATCHED version\n");
|
||||||
|
+ printf("Hello. <newly_added_var=0x%08x>\n", var);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void print_greetings(void)
|
||||||
|
+{
|
||||||
|
+ printf("Hello. This is an UNPATCHED version\n");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int main()
|
||||||
|
+{
|
||||||
|
+ while (1) {
|
||||||
|
+ print_greetings();
|
||||||
|
+ sleep(1);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
diff --git a/tests/new_var/new_var.diff b/tests/new_var/new_var.diff
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..c617535
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/tests/new_var/new_var.diff
|
||||||
|
@@ -0,0 +1,15 @@
|
||||||
|
+--- ./new_var.c 2022-02-10 19:40:17.948981115 +0800
|
||||||
|
++++ ./new_var.c 2022-02-10 20:02:38.774536002 +0800
|
||||||
|
+@@ -7,9 +7,11 @@
|
||||||
|
+ printf("Hello. <newly_added_var=0x%08x>\n", var);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
++int newly_added_var = 0x20220210;
|
||||||
|
+ void print_greetings(void)
|
||||||
|
+ {
|
||||||
|
+- printf("Hello. This is an UNPATCHED version\n");
|
||||||
|
++ newly_added_var = 0x2022 << 16 | 0x2202;
|
||||||
|
++ print_greetings_patched(newly_added_var);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int main()
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
100
0017-fix-probably-restore-cc-symbol-link-fail-when-kill-p.patch
Normal file
100
0017-fix-probably-restore-cc-symbol-link-fail-when-kill-p.patch
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
From c4f9d59c62454d255af4a5c3933eebf6942dbd99 Mon Sep 17 00:00:00 2001
|
||||||
|
From: ctyunsystem <ctyuncommiter05@chinatelecom.cn>
|
||||||
|
Date: Wed, 11 May 2022 10:32:45 +0800
|
||||||
|
Subject: [PATCH 4/5] fix probably restore cc symbol link fail when kill patch
|
||||||
|
building uncourteous
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libcare-patch-make | 45 ++++--------------------------------------
|
||||||
|
1 file changed, 4 insertions(+), 41 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libcare-patch-make b/src/libcare-patch-make
|
||||||
|
index 03aa1d6..41e5926 100755
|
||||||
|
--- a/src/libcare-patch-make
|
||||||
|
+++ b/src/libcare-patch-make
|
||||||
|
@@ -83,32 +83,6 @@ restore_origs() {
|
||||||
|
|
||||||
|
trap "restore_origs" 0
|
||||||
|
|
||||||
|
-replace_qemu_ld_flags() {
|
||||||
|
- local qemu_ld_flags_old=$1
|
||||||
|
- ret=$(echo $qemu_ld_flags_old | grep "\-Wl,-q")
|
||||||
|
- if [[ "$ret" == "" ]]; then
|
||||||
|
- local qemu_ld_flags="${qemu_ld_flags_old} -Wl,-q"
|
||||||
|
- echo "replace QEMU_LDFLAGS to '${qemu_ld_flags}'"
|
||||||
|
- sed -i "/^QEMU_LDFLAGS=/c\\${qemu_ld_flags}" config-host.mak
|
||||||
|
- fi
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-recover_qemu_ld_flags() {
|
||||||
|
- local qemu_ld_flags=$1
|
||||||
|
- echo "recover QEMU_LDFLAGS to '${qemu_ld_flags}'"
|
||||||
|
- sed -i "/^QEMU_LDFLAGS=/c\\${qemu_ld_flags}" config-host.mak
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-replace_cc_symbolink() {
|
||||||
|
- unlink $SYMBOLINK_CC
|
||||||
|
- ln -s $LIBCARE_CC $SYMBOLINK_CC
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-recover_cc_symbolink() {
|
||||||
|
- unlink $SYMBOLINK_CC
|
||||||
|
- ln -s $REAL_CC $SYMBOLINK_CC
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
build_objects() {
|
||||||
|
restore_origs
|
||||||
|
|
||||||
|
@@ -124,7 +98,8 @@ build_objects() {
|
||||||
|
export KPCC_DBGFILTER_ARGS=""
|
||||||
|
|
||||||
|
echo "${green}BUILDING ORIGINAL CODE${reset}"
|
||||||
|
- make $LPMAKEFILE $JOBS_MAKE >$MAKE_OUTPUT 2>&1
|
||||||
|
+ local lp_make_env_original="CC=${CC}"
|
||||||
|
+ make $LPMAKEFILE $JOBS_MAKE ${lp_make_env_original} >$MAKE_OUTPUT 2>&1
|
||||||
|
|
||||||
|
echo "${green}INSTALLING ORIGINAL OBJECTS INTO $LPMAKE_ORIGINAL_DIR${reset}"
|
||||||
|
make $LPMAKEFILE $JOBS_MAKE install \
|
||||||
|
@@ -149,20 +124,14 @@ build_objects() {
|
||||||
|
export KPATCH_STAGE=patched
|
||||||
|
export KPCC_APPEND_ARGS="-Wl,-q"
|
||||||
|
|
||||||
|
- qemu_ld_flags_bak=$(grep "^QEMU_LDFLAGS=" config-host.mak)
|
||||||
|
- #add '-Wl,-q' to LD_FLAGS
|
||||||
|
- replace_qemu_ld_flags "$qemu_ld_flags_bak"
|
||||||
|
-
|
||||||
|
echo "${green}BUILDING PATCHED CODE${reset}"
|
||||||
|
- make $LPMAKEFILE $JOBS_MAKE >$MAKE_OUTPUT 2>&1
|
||||||
|
+ local lp_make_env_patched="CC=${CC}"
|
||||||
|
+ make $LPMAKEFILE $JOBS_MAKE ${lp_make_env_patched} >$MAKE_OUTPUT 2>&1
|
||||||
|
|
||||||
|
echo "${green}INSTALLING PATCHED OBJECTS INTO $LPMAKE_PATCHED_DIR${reset}"
|
||||||
|
make $LPMAKEFILE $JOBS_MAKE install \
|
||||||
|
"$destdir=$LPMAKE_PATCHED_DIR" \
|
||||||
|
>$MAKE_OUTPUT 2>&1
|
||||||
|
-
|
||||||
|
- # recover LD_FLAGS
|
||||||
|
- recover_qemu_ld_flags "$qemu_ld_flags_bak"
|
||||||
|
}
|
||||||
|
|
||||||
|
build_kpatches() {
|
||||||
|
@@ -274,16 +243,10 @@ main() {
|
||||||
|
|
||||||
|
prepare_env
|
||||||
|
|
||||||
|
- # replace cc
|
||||||
|
- replace_cc_symbolink
|
||||||
|
-
|
||||||
|
if test -z "$only_update"; then
|
||||||
|
build_objects "$@"
|
||||||
|
fi
|
||||||
|
build_kpatches
|
||||||
|
-
|
||||||
|
- # recover cc
|
||||||
|
- recover_cc_symbolink
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
39
0018-optimize-Remove-unnecessary-comparison-code.patch
Normal file
39
0018-optimize-Remove-unnecessary-comparison-code.patch
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
From 5667441f87ef702ed537aba7c677eee1b36f1ead Mon Sep 17 00:00:00 2001
|
||||||
|
From: wangcichen <wangcichen_yewu@cmss.chinamobile.com>
|
||||||
|
Date: Fri, 27 May 2022 17:08:28 +0800
|
||||||
|
Subject: [PATCH 5/5] optimize: Remove unnecessary comparison code
|
||||||
|
|
||||||
|
---
|
||||||
|
src/arch/aarch64/arch_elf.c | 2 +-
|
||||||
|
src/arch/x86/arch_elf.c | 2 +-
|
||||||
|
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/arch/aarch64/arch_elf.c b/src/arch/aarch64/arch_elf.c
|
||||||
|
index 9ce586d..10399ee 100644
|
||||||
|
--- a/src/arch/aarch64/arch_elf.c
|
||||||
|
+++ b/src/arch/aarch64/arch_elf.c
|
||||||
|
@@ -202,7 +202,7 @@ int kpatch_arch_apply_relocate_add(struct object_file *o, GElf_Shdr *relsec)
|
||||||
|
unsigned long val;
|
||||||
|
void *loc, *loc2;
|
||||||
|
|
||||||
|
- if (r->r_offset < 0 || r->r_offset >= tshdr->sh_size) {
|
||||||
|
+ if (r->r_offset >= tshdr->sh_size) {
|
||||||
|
kperr("Relocation offset for section '%s'"
|
||||||
|
" is at 0x%lx beyond the section size 0x%lx\n",
|
||||||
|
scnname, r->r_offset, tshdr->sh_size);
|
||||||
|
diff --git a/src/arch/x86/arch_elf.c b/src/arch/x86/arch_elf.c
|
||||||
|
index 265fd37..f79a996 100644
|
||||||
|
--- a/src/arch/x86/arch_elf.c
|
||||||
|
+++ b/src/arch/x86/arch_elf.c
|
||||||
|
@@ -56,7 +56,7 @@ int kpatch_arch_apply_relocate_add(struct object_file *o, GElf_Shdr *relsec)
|
||||||
|
unsigned long val;
|
||||||
|
void *loc, *loc2;
|
||||||
|
|
||||||
|
- if (r->r_offset < 0 || r->r_offset >= tshdr->sh_size) {
|
||||||
|
+ if (r->r_offset >= tshdr->sh_size) {
|
||||||
|
kperr("Relocation offset for section '%s'"
|
||||||
|
" is at 0x%lx beyond the section size 0x%lx\n",
|
||||||
|
scnname, r->r_offset, tshdr->sh_size);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
101
0019-Revert-fix-probably-restore-cc-symbol-link-fail-when.patch
Normal file
101
0019-Revert-fix-probably-restore-cc-symbol-link-fail-when.patch
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
From d86044aa709617186fa4eeb2dff9540395f77c8e Mon Sep 17 00:00:00 2001
|
||||||
|
From: ctyunsystem <ctyuncommiter05@chinatelecom.cn>
|
||||||
|
Date: Tue, 5 Jul 2022 10:13:15 +0800
|
||||||
|
Subject: [PATCH 1/2] Revert "fix probably restore cc symbol link fail when
|
||||||
|
kill patch building uncourteous" ==> Revert "libcare-patch-make: fix some
|
||||||
|
bugs"
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libcare-patch-make | 45 ++++++++++++++++++++++++++++++++++++++----
|
||||||
|
1 file changed, 41 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libcare-patch-make b/src/libcare-patch-make
|
||||||
|
index 41e5926..03aa1d6 100755
|
||||||
|
--- a/src/libcare-patch-make
|
||||||
|
+++ b/src/libcare-patch-make
|
||||||
|
@@ -83,6 +83,32 @@ restore_origs() {
|
||||||
|
|
||||||
|
trap "restore_origs" 0
|
||||||
|
|
||||||
|
+replace_qemu_ld_flags() {
|
||||||
|
+ local qemu_ld_flags_old=$1
|
||||||
|
+ ret=$(echo $qemu_ld_flags_old | grep "\-Wl,-q")
|
||||||
|
+ if [[ "$ret" == "" ]]; then
|
||||||
|
+ local qemu_ld_flags="${qemu_ld_flags_old} -Wl,-q"
|
||||||
|
+ echo "replace QEMU_LDFLAGS to '${qemu_ld_flags}'"
|
||||||
|
+ sed -i "/^QEMU_LDFLAGS=/c\\${qemu_ld_flags}" config-host.mak
|
||||||
|
+ fi
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+recover_qemu_ld_flags() {
|
||||||
|
+ local qemu_ld_flags=$1
|
||||||
|
+ echo "recover QEMU_LDFLAGS to '${qemu_ld_flags}'"
|
||||||
|
+ sed -i "/^QEMU_LDFLAGS=/c\\${qemu_ld_flags}" config-host.mak
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+replace_cc_symbolink() {
|
||||||
|
+ unlink $SYMBOLINK_CC
|
||||||
|
+ ln -s $LIBCARE_CC $SYMBOLINK_CC
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+recover_cc_symbolink() {
|
||||||
|
+ unlink $SYMBOLINK_CC
|
||||||
|
+ ln -s $REAL_CC $SYMBOLINK_CC
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
build_objects() {
|
||||||
|
restore_origs
|
||||||
|
|
||||||
|
@@ -98,8 +124,7 @@ build_objects() {
|
||||||
|
export KPCC_DBGFILTER_ARGS=""
|
||||||
|
|
||||||
|
echo "${green}BUILDING ORIGINAL CODE${reset}"
|
||||||
|
- local lp_make_env_original="CC=${CC}"
|
||||||
|
- make $LPMAKEFILE $JOBS_MAKE ${lp_make_env_original} >$MAKE_OUTPUT 2>&1
|
||||||
|
+ make $LPMAKEFILE $JOBS_MAKE >$MAKE_OUTPUT 2>&1
|
||||||
|
|
||||||
|
echo "${green}INSTALLING ORIGINAL OBJECTS INTO $LPMAKE_ORIGINAL_DIR${reset}"
|
||||||
|
make $LPMAKEFILE $JOBS_MAKE install \
|
||||||
|
@@ -124,14 +149,20 @@ build_objects() {
|
||||||
|
export KPATCH_STAGE=patched
|
||||||
|
export KPCC_APPEND_ARGS="-Wl,-q"
|
||||||
|
|
||||||
|
+ qemu_ld_flags_bak=$(grep "^QEMU_LDFLAGS=" config-host.mak)
|
||||||
|
+ #add '-Wl,-q' to LD_FLAGS
|
||||||
|
+ replace_qemu_ld_flags "$qemu_ld_flags_bak"
|
||||||
|
+
|
||||||
|
echo "${green}BUILDING PATCHED CODE${reset}"
|
||||||
|
- local lp_make_env_patched="CC=${CC}"
|
||||||
|
- make $LPMAKEFILE $JOBS_MAKE ${lp_make_env_patched} >$MAKE_OUTPUT 2>&1
|
||||||
|
+ make $LPMAKEFILE $JOBS_MAKE >$MAKE_OUTPUT 2>&1
|
||||||
|
|
||||||
|
echo "${green}INSTALLING PATCHED OBJECTS INTO $LPMAKE_PATCHED_DIR${reset}"
|
||||||
|
make $LPMAKEFILE $JOBS_MAKE install \
|
||||||
|
"$destdir=$LPMAKE_PATCHED_DIR" \
|
||||||
|
>$MAKE_OUTPUT 2>&1
|
||||||
|
+
|
||||||
|
+ # recover LD_FLAGS
|
||||||
|
+ recover_qemu_ld_flags "$qemu_ld_flags_bak"
|
||||||
|
}
|
||||||
|
|
||||||
|
build_kpatches() {
|
||||||
|
@@ -243,10 +274,16 @@ main() {
|
||||||
|
|
||||||
|
prepare_env
|
||||||
|
|
||||||
|
+ # replace cc
|
||||||
|
+ replace_cc_symbolink
|
||||||
|
+
|
||||||
|
if test -z "$only_update"; then
|
||||||
|
build_objects "$@"
|
||||||
|
fi
|
||||||
|
build_kpatches
|
||||||
|
+
|
||||||
|
+ # recover cc
|
||||||
|
+ recover_cc_symbolink
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
From 96362b54e9c2162fe10fd1cfe029bcc8e203b135 Mon Sep 17 00:00:00 2001
|
||||||
|
From: ctyunsystem <ctyuncommiter05@chinatelecom.cn>
|
||||||
|
Date: Tue, 5 Jul 2022 10:13:58 +0800
|
||||||
|
Subject: [PATCH 2/2] fix probably restore cc symbol link fail when kill patch
|
||||||
|
building uncourteous
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libcare-patch-make | 2 ++
|
||||||
|
1 file changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/libcare-patch-make b/src/libcare-patch-make
|
||||||
|
index 03aa1d6..3cd2fe9 100755
|
||||||
|
--- a/src/libcare-patch-make
|
||||||
|
+++ b/src/libcare-patch-make
|
||||||
|
@@ -109,6 +109,8 @@ recover_cc_symbolink() {
|
||||||
|
ln -s $REAL_CC $SYMBOLINK_CC
|
||||||
|
}
|
||||||
|
|
||||||
|
+trap "recover_cc_symbolink" SIGINT SIGTERM SIGQUIT
|
||||||
|
+
|
||||||
|
build_objects() {
|
||||||
|
restore_origs
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -3,26 +3,33 @@
|
|||||||
Version: 1.0.0
|
Version: 1.0.0
|
||||||
Name: libcareplus
|
Name: libcareplus
|
||||||
Summary: LibcarePlus tools
|
Summary: LibcarePlus tools
|
||||||
Release: 11
|
Release: 12
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
Url: https://gitee.com/openeuler/libcareplus
|
Url: https://gitee.com/openeuler/libcareplus
|
||||||
Source0: %{name}-%{version}.tar.gz
|
Source0: %{name}-%{version}.tar.gz
|
||||||
|
|
||||||
Patch0001: fix-cblock-parse-for-LCOLD-LHOT-.cold.NUM-.init_arra.patch
|
Patch0000: 0000-gensrc-skip-vector-instruction-in-str_do_gotpcrel.patch
|
||||||
Patch0002: gensrc-we-should-add-align-while-FLAGS_PUSH_SECTION-.patch
|
Patch0001: 0001-gensrc-we-should-add-align-while-FLAGS_PUSH_SECTION-.patch
|
||||||
Patch0003: elf-add-section-adderss-for-STT_NOTYPE-type-of-symbo.patch
|
Patch0002: 0002-fix-cblock-parse-for-LCOLD-LHOT-.cold.NUM-.init_arra.patch
|
||||||
Patch0004: elf-strip-adapt-to-new-gcc-version-10.3.1.patch
|
Patch0003: 0003-elf-add-section-adderss-for-STT_NOTYPE-type-of-symbo.patch
|
||||||
Patch0005: gitignore-ignore-some-tests-and-binary.patch
|
Patch0004: 0004-elf-strip-adapt-to-new-gcc-version-10.3.1.patch
|
||||||
Patch0006: libcare-patch-make-adapt-libcare-patch-make-to-meson.patch
|
Patch0005: 0005-gitignore-ignore-some-tests-and-binary.patch
|
||||||
Patch0007: kpatch_elf-compatible-with-older-versions-of-the-so-.patch
|
Patch0006: 0006-libcare-patch-make-adapt-libcare-patch-make-to-meson.patch
|
||||||
Patch0008: kpatch_parse-fix-failed-to-recognize-.cold.patch
|
Patch0007: 0007-kpatch_elf-compatible-with-older-versions-of-the-so-.patch
|
||||||
Patch0009: help-modify-some-help-information.patch
|
Patch0008: 0008-kpatch_parse-fix-failed-to-recognize-.cold.patch
|
||||||
Patch0010: libcare-patch-make-fix-some-bugs.patch
|
Patch0009: 0009-help-modify-some-help-information.patch
|
||||||
Patch0011: selinux-enable-libcare-ctl-to-mprotect-qemu-process.patch
|
Patch0010: 0010-libcare-patch-make-fix-some-bugs.patch
|
||||||
Patch0012: libcare-dump-change-the-return-value.patch
|
Patch0011: 0011-selinux-enable-libcare-ctl-to-mprotect-qemu-process.patch
|
||||||
Patch0013: gensrc-skip-vector-instruction-in-str_do_gotpcrel.patch
|
Patch0012: 0012-libcare-dump-change-the-return-value.patch
|
||||||
Patch0014: modify-pkgbuild-to-make-kpatch-for-RPM-based-packages.patch
|
Patch0013: 0013-modify-pkgbuild-to-make-kpatch-for-RPM-based-packages.patch
|
||||||
|
Patch0014: 0014-kpatch_process-fix-possible-double-free.patch
|
||||||
|
Patch0015: 0015-ptrace-fix-NULL-pointer-access-problem.patch
|
||||||
|
Patch0016: 0016-fix-patched-process-crashing-when-acccess-the-global.patch
|
||||||
|
Patch0017: 0017-fix-probably-restore-cc-symbol-link-fail-when-kill-p.patch
|
||||||
|
Patch0018: 0018-optimize-Remove-unnecessary-comparison-code.patch
|
||||||
|
Patch0019: 0019-Revert-fix-probably-restore-cc-symbol-link-fail-when.patch
|
||||||
|
Patch0020: 0020-fix-probably-restore-cc-symbol-link-fail-when-kill-p.patch
|
||||||
|
|
||||||
BuildRequires: elfutils-libelf-devel libunwind-devel gcc systemd
|
BuildRequires: elfutils-libelf-devel libunwind-devel gcc systemd
|
||||||
|
|
||||||
@ -160,6 +167,13 @@ exit 0
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jun 15 2022 yezengruan <yezengruan@huawei.com> 1.0.0-12
|
||||||
|
- kpatch_process: fix possible double free.
|
||||||
|
- ptrace: fix NULL pointer access problem
|
||||||
|
- fix patched process crashing when acccess the global var
|
||||||
|
- fix probably restore cc symbol link fail when kill patch building uncourteous
|
||||||
|
- optimize: Remove unnecessary comparison code
|
||||||
|
|
||||||
* Wed May 11 2022 Cichen Wang <wangcichen_yewu@cmss.chinamobile.com> 1.0.0-11
|
* Wed May 11 2022 Cichen Wang <wangcichen_yewu@cmss.chinamobile.com> 1.0.0-11
|
||||||
- modify scripts/pkgbuild to make kpatch'es for the RPM-based packages
|
- modify scripts/pkgbuild to make kpatch'es for the RPM-based packages
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user