Blame SPECS/kpatch-patch.spec

a71f97
# Set to 1 if building an empty subscription-only package.
8215de
%define empty_package		0
a71f97
a71f97
#######################################################
a71f97
# Only need to update these variables and the changelog
a71f97
%define kernel_ver	4.18.0-305.12.1.el8_4
a71f97
%define kpatch_ver	0.9.3
8215de
%define rpm_ver		1
e535d4
%define rpm_rel		2
a71f97
a71f97
%if !%{empty_package}
a71f97
# Patch sources below. DO NOT REMOVE THIS LINE.
8215de
#
8215de
# https://bugzilla.redhat.com/1988230
8215de
Source100: CVE-2021-37576.patch
e535d4
#
e535d4
# https://bugzilla.redhat.com/1981706
e535d4
Source101: CVE-2020-36385.patch
e535d4
#
e535d4
# https://bugzilla.redhat.com/1979028
e535d4
Source102: CVE-2021-0512.patch
a71f97
# End of patch sources. DO NOT REMOVE THIS LINE.
a71f97
%endif
a71f97
a71f97
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
a71f97
%define sanitized_kernel_ver   %{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), '.el8_?\%d?', ""), "%.", "_")))}
a71f97
%define kernel_ver_arch        %{kernel_ver}.%{_arch}
a71f97
a71f97
Name:		kpatch-patch-%{sanitized_kernel_ver}
a71f97
Version:	%{rpm_ver}
a71f97
Release:	%{rpm_rel}%{?dist}
a71f97
a71f97
%if %{empty_package}
a71f97
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
a71f97
%else
a71f97
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
a71f97
%endif
a71f97
a71f97
Group:		System Environment/Kernel
a71f97
License:	GPLv2
e535d4
ExclusiveArch:	x86_64 ppc64le
a71f97
a71f97
Conflicts:	%{name} < %{version}-%{release}
a71f97
a71f97
Provides:	kpatch-patch = %{kernel_ver_arch}
a71f97
Provides:	kpatch-patch = %{kernel_ver}
a71f97
a71f97
%if !%{empty_package}
a71f97
Requires:	systemd
a71f97
%endif
a71f97
Requires:	kpatch >= 0.6.1-1
a71f97
Requires:	kernel-uname-r = %{kernel_ver_arch}
a71f97
a71f97
%if !%{empty_package}
a71f97
BuildRequires:	patchutils
a71f97
BuildRequires:	kernel-devel = %{kernel_ver}
a71f97
BuildRequires:	kernel-debuginfo = %{kernel_ver}
a71f97
a71f97
# kernel build requirements, generated from:
a71f97
#   % rpmspec -q --buildrequires kernel.spec | sort | awk '{print "BuildRequires:\t" $0}'
a71f97
# with arch-specific packages moved into conditional block
a71f97
BuildRequires:	asciidoc audit-libs-devel bash bc binutils binutils-devel bison bzip2 diffutils elfutils elfutils-devel findutils flex gawk gcc gettext git gzip hmaccalc hostname kmod m4 make ncurses-devel net-tools newt-devel numactl-devel openssl openssl-devel patch pciutils-devel perl-Carp perl-devel perl(ExtUtils::Embed) perl-generators perl-interpreter python3-devel python3-docutils redhat-rpm-config rpm-build sh-utils tar xmlto xz xz-devel zlib-devel java-devel kabi-dw
a71f97
a71f97
%ifarch x86_64
a71f97
BuildRequires:	pesign >= 0.10-4
a71f97
%endif
a71f97
a71f97
%ifarch ppc64le
a71f97
BuildRequires:	gcc-plugin-devel
a71f97
%endif
a71f97
a71f97
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
a71f97
a71f97
Source10:	kernel-%{kernel_ver}.src.rpm
a71f97
a71f97
# kpatch-build patches
a71f97
a71f97
%global _dupsign_opts --keyname=rhelkpatch1
a71f97
a71f97
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
a71f97
%define kpatch		%{_sbindir}/kpatch
a71f97
%define kmoddir 	%{_usr}/lib/kpatch/%{kernel_ver_arch}
a71f97
%define kinstdir	%{_sharedstatedir}/kpatch/%{kernel_ver_arch}
a71f97
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
a71f97
%define patchmod	%{patchmodname}.ko
a71f97
a71f97
%define _missing_build_ids_terminate_build 1
a71f97
%define _find_debuginfo_opts -r
a71f97
%undefine _include_minidebuginfo
a71f97
%undefine _find_debuginfo_dwz_opts
a71f97
a71f97
%description
a71f97
This is a kernel live patch module which can be loaded by the kpatch
a71f97
command line utility to modify the code of a running kernel.  This patch
a71f97
module is targeted for kernel-%{kernel_ver}.
a71f97
a71f97
%prep
a71f97
%autosetup -n kpatch-%{kpatch_ver} -p1
a71f97
a71f97
%build
a71f97
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
a71f97
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
a71f97
a71f97
# kpatch-build
a71f97
make -C kpatch-build
a71f97
a71f97
# patch module
a71f97
for i in %{sources}; do
a71f97
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
a71f97
done
a71f97
export CACHEDIR="%{builddir}/.kpatch"
a71f97
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
a71f97
a71f97
a71f97
%install
a71f97
installdir=%{buildroot}/%{kmoddir}
a71f97
install -d $installdir
a71f97
install -m 755 %{builddir}/%{patchmod} $installdir
a71f97
a71f97
a71f97
%files
a71f97
%{_usr}/lib/kpatch
a71f97
a71f97
a71f97
%post
a71f97
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
a71f97
chcon -t modules_object_t %{kinstdir}/%{patchmod}
a71f97
sync
a71f97
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
a71f97
	cver="%{rpm_ver}_%{rpm_rel}"
a71f97
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
a71f97
a71f97
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
a71f97
a71f97
	if [ "${lver}" != "${cver}" ]; then
a71f97
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
a71f97
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
a71f97
	else
a71f97
		%{kpatch} load %{patchmod}
a71f97
	fi
a71f97
fi
a71f97
exit 0
a71f97
a71f97
a71f97
%postun
a71f97
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
a71f97
sync
a71f97
exit 0
a71f97
a71f97
%else
a71f97
%description
a71f97
This is an empty kpatch-patch package which does not contain any real patches.
a71f97
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
a71f97
a71f97
%files
a71f97
%doc
a71f97
%endif
a71f97
a71f97
%changelog
e535d4
* Wed Oct 27 2021 Artem Savkov <asavkov@redhat.com> [1-2.el8_4]
e535d4
- out-of-bounds write due to a heap buffer overflow in __hidinput_change_resolution_multipliers() [1979028] {CVE-2021-0512}
e535d4
- use-after-free in drivers/infiniband/core/ucma.c ctx use-after-free [1981706] {CVE-2020-36385}
e535d4
8215de
* Wed Sep 01 2021 Artem Savkov <asavkov@redhat.com> [1-1.el8_4]
8215de
- powerpc: KVM guest OS users can cause host OS memory corruption [1988230] {CVE-2021-37576}
8215de
a71f97
* Thu Jul 29 2021 Artem Savkov <asavkov@redhat.com> [0-0.el8_4]
a71f97
- An empty patch to subscribe to kpatch stream for kernel-4.18.0-305.12.1.el8_4 [1987277]