diff --git a/0032-create-diff-object-Fix-out-of-range-relocation-error.patch b/0032-create-diff-object-Fix-out-of-range-relocation-error.patch new file mode 100644 index 0000000000000000000000000000000000000000..50308a8b607f391fdd5da7257838f632746b1dc8 --- /dev/null +++ b/0032-create-diff-object-Fix-out-of-range-relocation-error.patch @@ -0,0 +1,36 @@ +From fa5a95cafdb034b825242a93ef1b4ce57985a93d Mon Sep 17 00:00:00 2001 +From: Josh Poimboeuf +Date: Tue, 13 Apr 2021 13:58:59 -0500 +Subject: [PATCH] create-diff-object: Fix out-of-range relocation error message + +Showing sec+addend isn't valid, show sym+addend instead. + +Before: + + create-diff-object: ERROR: sys.o: kpatch_check_relocations: 2550: out-of-range relocation .rodata.__kpatch_do_sys_uname.str1.1+139 in .rela.text.__kpatch_do_sys_uname + +After: + + create-diff-object: ERROR: sys.o: kpatch_check_relocations: 2550: out-of-range relocation .LC7+139 in .rela.text.__kpatch_do_sys_uname + +Signed-off-by: Josh Poimboeuf +--- + 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 82e486f..d427beb 100644 +--- a/kpatch-build/create-diff-object.c ++++ b/kpatch-build/create-diff-object.c +@@ -2547,7 +2547,7 @@ static void kpatch_check_relocations(struct kpatch_elf *kelf) + if (rela->sym->sec) { + sdata = rela->sym->sec->data; + if (rela->addend > (long)sdata->d_size) { +- ERROR("out-of-range relocation %s+%lx in %s", rela->sym->sec->name, ++ ERROR("out-of-range relocation %s+%lx in %s", rela->sym->name, + rela->addend, sec->name); + } + } +-- +2.23.0 + diff --git a/0033-create-diff-object-Fix-out-of-range-relocation-check.patch b/0033-create-diff-object-Fix-out-of-range-relocation-check.patch new file mode 100644 index 0000000000000000000000000000000000000000..7c5e767309322c018b4421d7f3bb3983d52ef32e --- /dev/null +++ b/0033-create-diff-object-Fix-out-of-range-relocation-check.patch @@ -0,0 +1,32 @@ +From 81f9ca4833bf9c5867858d633c340cedca554ca6 Mon Sep 17 00:00:00 2001 +From: Josh Poimboeuf +Date: Tue, 13 Apr 2021 14:00:41 -0500 +Subject: [PATCH] create-diff-object: Fix out-of-range relocation check + +Improve the relocation check for the case where the referenced symbol +isn't at the beginning of the section. + +Note that the check still isn't perfect, as many relocations have a +negative addend. But it's still a lot better than nothing. + +Signed-off-by: Josh Poimboeuf +--- + 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 d427beb..14eb1f5 100644 +--- a/kpatch-build/create-diff-object.c ++++ b/kpatch-build/create-diff-object.c +@@ -2546,7 +2546,7 @@ static void kpatch_check_relocations(struct kpatch_elf *kelf) + list_for_each_entry(rela, &sec->relas, list) { + if (rela->sym->sec) { + sdata = rela->sym->sec->data; +- if (rela->addend > (long)sdata->d_size) { ++ if ((long)rela->sym->sym.st_value + rela->addend > (long)sdata->d_size) { + ERROR("out-of-range relocation %s+%lx in %s", rela->sym->name, + rela->addend, sec->name); + } +-- +2.23.0 + diff --git a/0034-add-openEuler-build-support.patch b/0034-add-openEuler-build-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..4a16cb842d307e7b000f26e52b96dfa23dad270e --- /dev/null +++ b/0034-add-openEuler-build-support.patch @@ -0,0 +1,25 @@ +From eaaced1912c43103749366927daff5794ea4f404 Mon Sep 17 00:00:00 2001 +From: gouhao +Date: Wed, 8 Sep 2021 09:37:08 +0800 +Subject: [PATCH] add openEuler build support + +--- + 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 495ca3d..49c0045 100755 +--- a/kpatch-build/kpatch-build ++++ b/kpatch-build/kpatch-build +@@ -696,7 +696,7 @@ fi + # shellcheck disable=SC1090 + [[ -f "$RELEASE_FILE" ]] && source "$RELEASE_FILE" + DISTRO="$ID" +-if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] || [[ "$DISTRO" = centos ]]; then ++if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] || [[ "$DISTRO" = centos ]] || [[ "$DISTRO" = openEuler ]]; then + [[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/lib/modules/$ARCHVERSION/vmlinux" + [[ -e "$VMLINUX" ]] || die "kernel-debuginfo-$ARCHVERSION not installed" + +-- +2.23.0 + diff --git a/README.md b/README.md index 1fd4059e2af930fbdff4cdc24e6ab09a4a4066e9..5159c801d25843ce3c04ace182cb87889407ef79 100644 --- a/README.md +++ b/README.md @@ -169,4 +169,5 @@ mkdir -p ~/rpmbuild/SOURCES/ /bin/cp kpatch/* ~/rpmbuild/SOURCES/ rpmbuild -ba kpatch/kpatch.spec rpm -Uvh ~/rpmbuild/RPMS/`arch`/kpatch*.rpm +rpm -Uvh ~/rpmbuild/RPMS/noarch/kpatch*.rpm ``` diff --git a/kpatch.spec b/kpatch.spec index 1ff3f0ce599f97d12005a730d1826be8870e8a5f..064e6df9954d1a4fd62800517b920e91d197cf27 100644 --- a/kpatch.spec +++ b/kpatch.spec @@ -1,7 +1,7 @@ Name: kpatch Epoch: 1 Version: 0.9.1 -Release: 18 +Release: 20 Summary: A Linux dynamic kernel patching infrastructure License: GPLv2 @@ -43,6 +43,9 @@ Patch0028:0028-lookup-Add-__UNIQUE_ID_-to-maybe_discarded_sym-list.patch Patch0029:0029-create-diff-object-error-on-detect-new-changed-ALTIN.patch Patch0030:0030-kpatch-update-sympos-for-duplicate-symbols-in-vmlinu.patch Patch0031:0031-create-diff-object-fix-segment-fault-when-sec2-rela-.patch +Patch0032:0032-create-diff-object-Fix-out-of-range-relocation-error.patch +Patch0033:0033-create-diff-object-Fix-out-of-range-relocation-check.patch +Patch0034:0034-add-openEuler-build-support.patch BuildRequires: gcc elfutils-libelf-devel kernel-devel git Requires: bc make gcc patch bison flex openssl-devel @@ -103,6 +106,18 @@ popd %{_mandir}/man1/*.1.gz %changelog +* Tue Oct 26 2021 Zhipeng Xie -1:0.9.1-20 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC:backport upstream patches + +* Tue Oct 26 2021 Zhipeng Xie -1:0.9.1-19 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC:support make compile environment + * Tue Sep 28 2021 Zhipeng Xie -1:0.9.1-18 - Type:bugfix - ID:NA diff --git a/make_compile_env.sh b/make_compile_env.sh new file mode 100644 index 0000000000000000000000000000000000000000..416c02f56db00e0fd8038071da5df0c42496a8fc --- /dev/null +++ b/make_compile_env.sh @@ -0,0 +1,42 @@ +#!/bin/bash +rm -rf kpatch_compile_env +yum install -y strace vim git rpm-build bc elfutils-libelf-devel gdb-headless make gcc patch bison flex openssl-devel kernel-source-`uname -r` kernel-debuginfo-`uname -r` kernel-devel-`uname -r` --installroot=`pwd`/kpatch_compile_env/ +mkdir -p kpatch_compile_env/kpatch +/bin/cp * kpatch_compile_env/kpatch/ +cat > kpatch_compile_env/installkpatch.sh < kpatch_compile_env/chroot.sh < kpatch_compile_env/unchroot.sh < kpatch_compile_env/usr/bin/openEuler_history<