From 190f5a586122f7ca02fb4b80dee4ac5757031680 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 29 2019 11:40:34 +0000 Subject: import kpatch-0.6.1-6.el7 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a98fe6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/v0.6.1.tar.gz diff --git a/.kpatch.metadata b/.kpatch.metadata new file mode 100644 index 0000000..654277d --- /dev/null +++ b/.kpatch.metadata @@ -0,0 +1 @@ +7a0395e649f58026a3dd66dd13e3bcecdb9e97a4 SOURCES/v0.6.1.tar.gz diff --git a/SOURCES/0001-contrib-disable-upstart-kpatch.conf-install.patch b/SOURCES/0001-contrib-disable-upstart-kpatch.conf-install.patch new file mode 100644 index 0000000..44eb5b4 --- /dev/null +++ b/SOURCES/0001-contrib-disable-upstart-kpatch.conf-install.patch @@ -0,0 +1,46 @@ +From f056d60fb309896a52882fd3fc10fb5305f5a47e Mon Sep 17 00:00:00 2001 +From: Joe Lawrence +Date: Thu, 21 Jun 2018 15:40:20 -0400 +Subject: [PATCH] contrib: disable upstart kpatch.conf install + +Do not install the upstart configuration file to avoid this rhpkg +build complaint: + + Checking for unpackaged file(s): /usr/lib/rpm/check-files /builddir/build/BUILDROOT/kpatch-0.6.1-1.el7.noarch + error: Installed (but unpackaged) file(s) found: + /etc/init/kpatch.conf + Installed (but unpackaged) file(s) found: + /etc/init/kpatch.conf + +We'll need to think of a better way to do this upstream, but for now, +just skip the unneeded file on RHEL. + +Signed-off-by: Joe Lawrence +--- + contrib/Makefile | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/contrib/Makefile b/contrib/Makefile +index 0b0eeeb23a56..e873f27d6eae 100644 +--- a/contrib/Makefile ++++ b/contrib/Makefile +@@ -6,12 +6,12 @@ install: all + $(INSTALL) -d $(SYSTEMDDIR) + $(INSTALL) -m 0644 kpatch.service $(SYSTEMDDIR) + sed -i 's~PREFIX~$(PREFIX)~' $(SYSTEMDDIR)/kpatch.service +- $(INSTALL) -d $(UPSTARTDIR) +- $(INSTALL) -m 0644 kpatch.conf $(UPSTARTDIR) +- sed -i 's~PREFIX~$(PREFIX)~' $(UPSTARTDIR)/kpatch.conf ++# $(INSTALL) -d $(UPSTARTDIR) ++# $(INSTALL) -m 0644 kpatch.conf $(UPSTARTDIR) ++# sed -i 's~PREFIX~$(PREFIX)~' $(UPSTARTDIR)/kpatch.conf + + uninstall: + $(RM) $(SYSTEMDDIR)/kpatch.service +- $(RM) $(UPSTARTDIR)/kpatch.conf ++# $(RM) $(UPSTARTDIR)/kpatch.conf + + clean: +-- +1.8.3.1 + diff --git a/SOURCES/0002-contrib-service-don-t-unload-modules-on-stop.patch b/SOURCES/0002-contrib-service-don-t-unload-modules-on-stop.patch new file mode 100644 index 0000000..559b00f --- /dev/null +++ b/SOURCES/0002-contrib-service-don-t-unload-modules-on-stop.patch @@ -0,0 +1,31 @@ +From 8909e63c54adb34a0324200f99c63fcd7db5cbc5 Mon Sep 17 00:00:00 2001 +From: Joe Lawrence +Date: Mon, 10 Jun 2019 16:55:54 -0400 +Subject: [PATCH] contrib/service: don't unload modules on stop + +The kpatch.service file shouldn't unload patch modules on service stop +(this is also executed by systemd on reboot). Patch modules may not be +designed to be safely unloaded and/or may patch kernel routines that +need to continue to run throughout system bring down. + +Suggested-by: disaster123 +Signed-off-by: Joe Lawrence +--- + contrib/kpatch.service | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/contrib/kpatch.service b/contrib/kpatch.service +index 5286f6c929e0..cf13f40105d9 100644 +--- a/contrib/kpatch.service ++++ b/contrib/kpatch.service +@@ -6,7 +6,6 @@ ConditionKernelCommandLine=!kpatch.enable=0 + Type=oneshot + RemainAfterExit=yes + ExecStart=PREFIX/sbin/kpatch load --all +-ExecStop=PREFIX/sbin/kpatch unload --all + + [Install] + WantedBy=multi-user.target +-- +2.21.0 + diff --git a/SOURCES/0003-kpatch-script-don-t-fail-if-module-already-loaded-en.patch b/SOURCES/0003-kpatch-script-don-t-fail-if-module-already-loaded-en.patch new file mode 100644 index 0000000..0b0ae31 --- /dev/null +++ b/SOURCES/0003-kpatch-script-don-t-fail-if-module-already-loaded-en.patch @@ -0,0 +1,77 @@ +From 1d2dffec7a6fad4a8daed9340cd42aada856d03f Mon Sep 17 00:00:00 2001 +From: Joe Lawrence +Date: Wed, 19 Jun 2019 15:29:43 -0400 +Subject: [PATCH] kpatch script: don't fail if module already loaded+enabled + +For "kpatch load" invocations, don't set failing return status if the +kpatch module is already loaded and enabled. Make note of the existing +livepatch module and then verify that is has completed its transition +before continuing. This allows the user to more gracefully re-run +"kpatch load" commands to pick up new kpatch modules. + +Fixes: #979 +Signed-off-by: Joe Lawrence +--- + kpatch/kpatch | 44 ++++++++++++++++++++++---------------------- + 1 file changed, 22 insertions(+), 22 deletions(-) + +diff --git a/kpatch/kpatch b/kpatch/kpatch +index 328f1197259d..8ea6c80ca2d3 100755 +--- a/kpatch/kpatch ++++ b/kpatch/kpatch +@@ -314,30 +314,30 @@ load_module () { + die "error: cannot re-enable patch module $modname, cannot verify checksum match" + fi + else +- die "error: module named $modname already loaded and enabled" ++ echo "module named $modname already loaded and enabled" + fi +- fi ++ else ++ echo "loading patch module: $module" ++ local i=0 ++ while true; do ++ out="$(LC_ALL=C insmod "$module" 2>&1)" ++ [[ -z "$out" ]] && break ++ echo "$out" 1>&2 ++ [[ ! "$out" =~ "Device or resource busy" ]] && ++ die "failed to load module $module" + +- echo "loading patch module: $module" +- local i=0 +- while true; do +- out="$(LC_ALL=C insmod "$module" 2>&1)" +- [[ -z "$out" ]] && break +- echo "$out" 1>&2 +- [[ ! "$out" =~ "Device or resource busy" ]] && +- die "failed to load module $module" +- +- # "Device or resource busy" means the activeness safety check +- # failed. Retry in a few seconds. +- i=$((i+1)) +- if [[ $i -eq $MAX_LOAD_ATTEMPTS ]]; then +- die "failed to load module $module" +- break +- else +- warn "retrying..." +- sleep $RETRY_INTERVAL +- fi +- done ++ # "Device or resource busy" means the activeness safety check ++ # failed. Retry in a few seconds. ++ i=$((i+1)) ++ if [[ $i -eq $MAX_LOAD_ATTEMPTS ]]; then ++ die "failed to load module $module" ++ break ++ else ++ warn "retrying..." ++ sleep $RETRY_INTERVAL ++ fi ++ done ++ fi + + if ! wait_for_patch_transition "$modname" ; then + echo "module $modname did not complete its transition, unloading..." +-- +2.21.0 + diff --git a/SOURCES/0004-kpatch-clarify-unload-unsupport.patch b/SOURCES/0004-kpatch-clarify-unload-unsupport.patch new file mode 100644 index 0000000..0d95f93 --- /dev/null +++ b/SOURCES/0004-kpatch-clarify-unload-unsupport.patch @@ -0,0 +1,78 @@ +kpatch: clarify that "kpatch unload" isn't supported + +Add a user-prompt to the kpatch unload subcommand and make a similiar +mention in the manual page. + +Provide an undocumented force option so that QE and dev scripts can +still run unload kpatch modules from scripts. + +RHEL-only. + +Signed-off-by: Joe Lawrence +diff -Nupr kpatch-0.6.1.old/kpatch/kpatch kpatch-0.6.1/kpatch/kpatch +--- kpatch-0.6.1.old/kpatch/kpatch 2019-08-28 10:35:01.191259434 -0400 ++++ kpatch-0.6.1/kpatch/kpatch 2019-08-28 16:11:13.067926576 -0400 +@@ -49,8 +49,8 @@ usage () { + echo >&2 + usage_cmd "load --all" "load all installed patch modules into the running kernel" + usage_cmd "load " "load patch module into the running kernel" +- usage_cmd "unload --all" "unload all patch modules from the running kernel" +- usage_cmd "unload " "unload patch module from the running kernel" ++ usage_cmd "unload --all (UNSUPPORTED)" "unload all patch modules from the running kernel" ++ usage_cmd "unload (UNSUPPORTED)" "unload patch module from the running kernel" + echo >&2 + usage_cmd "info " "show information about a patch module" + echo >&2 +@@ -71,6 +71,16 @@ die() { + exit 1 + } + ++confirm_prompt() { ++ local prompt="$1" ++ local answer ++ while true; do ++ read -rp "$prompt [Y/N] " answer ++ [[ $answer == 'Y' || $answer == 'y' ]] && return 0 ++ [[ $answer == 'N' || $answer == 'n' ]] && return 1 ++ done ++} ++ + __find_module () { + MODULE="$1" + [[ -f "$MODULE" ]] && return +@@ -406,6 +416,19 @@ unset MODULE + init_sysfs_var + + [[ "$#" -lt 1 ]] && usage ++ ++# RHEL-specific support options ++case "$1" in ++"force") ++ # For scripting purposes, support "kpatch force unload". ++ # Shift out the "force" to avoid the user-prompt check below. ++ shift ++ ;; ++"unload") ++ confirm_prompt "WARNING: Red Hat doesn't support unloading of kpatches, continue anyway?" || exit 1 ++ ;; ++esac ++ + case "$1" in + "load") + [[ "$#" -ne 2 ]] && usage +diff -Nupr kpatch-0.6.1.old/man/kpatch.1 kpatch-0.6.1/man/kpatch.1 +--- kpatch-0.6.1.old/man/kpatch.1 2019-08-28 10:35:01.191259434 -0400 ++++ kpatch-0.6.1/man/kpatch.1 2019-08-28 14:51:23.268198897 -0400 +@@ -23,10 +23,10 @@ load --all + load + load patch module into the running kernel + +-unload --all ++unload --all (UNSUPPORTED) + unload all patch modules from the running kernel + +-unload ++unload (UNSUPPORTED) + unload patch module from the running kernel + + info diff --git a/SOURCES/0005-Fix-livepatch-enabled-kernel-detection-in-kpatch-scr.patch b/SOURCES/0005-Fix-livepatch-enabled-kernel-detection-in-kpatch-scr.patch new file mode 100644 index 0000000..1ec00a4 --- /dev/null +++ b/SOURCES/0005-Fix-livepatch-enabled-kernel-detection-in-kpatch-scr.patch @@ -0,0 +1,29 @@ +From 54c3d6d8fef188da10a5040c9cc841f35e01bfbf Mon Sep 17 00:00:00 2001 +From: Artem Savkov +Date: Tue, 7 May 2019 14:12:38 +0200 +Subject: [PATCH] Fix livepatch-enabled kernel detection in kpatch script + +We can no longer use klp_register_patch symbol to determine if the +kernel is livepatch-enabled. Use klp_enable_patch instead. + +Signed-off-by: Artem Savkov +--- + kpatch/kpatch | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kpatch/kpatch b/kpatch/kpatch +index 1d9f90c..bdceff1 100755 +--- a/kpatch/kpatch ++++ b/kpatch/kpatch +@@ -126,7 +126,7 @@ find_core_module() { + } + + core_loaded () { +- grep -q -e "T klp_register_patch" -e "T kpatch_register" /proc/kallsyms ++ grep -q -e "T klp_enable_patch" -e "T kpatch_register" /proc/kallsyms + } + + get_module_name () { +-- +2.21.0 + diff --git a/SPECS/kpatch.spec b/SPECS/kpatch.spec new file mode 100644 index 0000000..e8a000c --- /dev/null +++ b/SPECS/kpatch.spec @@ -0,0 +1,121 @@ +Name: kpatch +Version: 0.6.1 +Release: 6%{?dist} +Summary: Dynamic kernel patch manager + +Group: System Environment/Kernel +License: GPLv2 +URL: https://github.com/dynup/kpatch +Source0: https://github.com/dynup/kpatch/archive/v%{version}.tar.gz +Patch0: 0001-contrib-disable-upstart-kpatch.conf-install.patch +Patch1: 0002-contrib-service-don-t-unload-modules-on-stop.patch +Patch2: 0003-kpatch-script-don-t-fail-if-module-already-loaded-en.patch +Patch3: 0004-kpatch-clarify-unload-unsupport.patch +Patch4: 0005-Fix-livepatch-enabled-kernel-detection-in-kpatch-scr.patch + +Requires: bash kmod binutils + +BuildArch: noarch + + +%description +kpatch is a live kernel patch module manager. It allows the user to manage +a collection of binary kernel patch modules which can be used to dynamically +patch the kernel without rebooting. + + +%prep +%setup -q +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 + + +%build +make -C man + + +%install +make install PREFIX=/usr DESTDIR=%{buildroot} -C kpatch +make install PREFIX=/usr DESTDIR=%{buildroot} -C man +make install PREFIX=/usr DESTDIR=%{buildroot} -C contrib +rm -f %{buildroot}/usr/share/man/man1/kpatch-build.1.gz + + +%files +%{_sbindir}/kpatch +%{_usr}/lib/systemd/system/kpatch.service +%doc %{_mandir}/man1/kpatch.1.gz + + +%changelog +* Tue Sep 17 2019 Artem Savkov 0.6.1-6 +- fix patch loading issue caused by recent kernel rebase (rhbz#1752698) + +* Wed Aug 28 2019 Joe Lawrence 0.6.1-5 +- kpatch: clarify that "kpatch unload" isn't supported (rhbz#1746461) + +* Sun Jun 23 2019 Joe Lawrence 0.6.1-3 +- Rebuild with correct RHEL-7.7 bugzilla number (rhbz#1719309) + +* Sun Jun 23 2019 Joe Lawrence 0.6.1-3 +- kpatch script: don't fail if module already loaded+enabled (rhbz#1719309) + +* Wed Jun 12 2019 Joe Lawrence 0.6.1-2 +- kpatch: patches shouldn't be unloaded on system shutdown (rhbz#1719309) + +* Thu Jun 21 2018 Joe Lawrence 0.6.1-1 +- update to 0.6.1 (rhbz#1562976) + +* Thu Nov 16 2017 Joe Lawrence 0.4.0-3 +- kpatch: better livepatch module support (rhbz#1504066) + +* Wed Oct 18 2017 Josh Poimboeuf 0.4.0-2 +- fix backwards compatibility with RHEL 7.3 patches (rhbz#1497735) + +* Mon Mar 13 2017 Josh Poimboeuf 0.4.0-1 +- update to 0.4.0 (rhbz#1427642) + +* Wed Jun 15 2016 Josh Poimboeuf 0.3.2-1 +- update to 0.3.2 (rhbz#1282508) + +* Wed Nov 18 2015 Josh Poimboeuf 0.3.1-1 +- update to 0.3.1 (rhbz#1282508) + +* Tue Sep 16 2014 Seth Jennings 0.1.10-4 +- fix dracut dependencies (rhbz#1170369) + +* Tue Sep 16 2014 Seth Jennings 0.1.10-3 +- support re-enabling forced modules (rhbz#1140268) + +* Thu Sep 11 2014 Seth Jennings 0.1.10-2 +- support modprobe format names (rhbz#1133045) + +* Thu Jul 31 2014 Josh Poimboeuf 0.1.10-1 +- update to kpatch 0.1.10 + +* Wed Jul 23 2014 Josh Poimboeuf 0.1.9-1 +- update to kpatch 0.1.9 + +* Tue Jul 15 2014 Josh Poimboeuf 0.1.8-1 +- update to kpatch 0.1.8 + +* Wed May 21 2014 Josh Poimboeuf 0.1.2-1 +- update to kpatch 0.1.2 + +* Mon May 19 2014 Josh Poimboeuf 0.1.1-2 +- fix initramfs core module path + +* Mon May 19 2014 Josh Poimboeuf 0.1.1-1 +- rebase to kpatch 0.1.1 + +* Fri May 9 2014 Josh Poimboeuf 0.1.0-2 +- modprobe core module + +* Tue May 6 2014 Josh Poimboeuf 0.1.0-1 +- Initial kpatch release 0.1.0 + +* Thu Jan 30 2014 Josh Poimboeuf 0.0-1 +- Initial build