Blame SPECS/kpatch-patch.spec

01cd24
# Set to 1 if building an empty subscription-only package.
311138
%define empty_package		0
01cd24
01cd24
#######################################################
01cd24
# Only need to update these variables and the changelog
01cd24
%define kernel_ver	3.10.0-1160.41.1.el7
01cd24
%define kpatch_ver	0.9.2
311138
%define rpm_ver		1
a0fe1f
%define rpm_rel		2
01cd24
01cd24
%if !%{empty_package}
01cd24
# Patch sources below. DO NOT REMOVE THIS LINE.
311138
#
311138
# https://bugzilla.redhat.com/1997195
311138
Source100: CVE-2021-3715.patch
a0fe1f
#
a0fe1f
# https://bugzilla.redhat.com/1975766
a0fe1f
Source101: CVE-2021-22543.patch
a0fe1f
#
a0fe1f
# https://bugzilla.redhat.com/1988221
a0fe1f
Source102: CVE-2021-37576.patch
01cd24
# End of patch sources. DO NOT REMOVE THIS LINE.
01cd24
%endif
01cd24
01cd24
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
01cd24
%define sanitized_kernel_ver	%{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), ".el7", ""), "%.", "_")))}
01cd24
%define kernel_ver_arch	%{kernel_ver}.%{_arch}
01cd24
01cd24
Name:		kpatch-patch-%{sanitized_kernel_ver}
01cd24
Version:	%{rpm_ver}
01cd24
Release:	%{rpm_rel}.el7
01cd24
01cd24
%if %{empty_package}
01cd24
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
01cd24
%else
01cd24
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
01cd24
%endif
01cd24
01cd24
Group:		System Environment/Kernel
01cd24
License:	GPLv2
01cd24
ExclusiveArch:	x86_64 ppc64le
01cd24
01cd24
Conflicts:	%{name} < %{version}-%{release}
01cd24
01cd24
Provides:	kpatch-patch = %{kernel_ver_arch}
01cd24
Provides:	kpatch-patch = %{kernel_ver}
01cd24
01cd24
%if !%{empty_package}
01cd24
Requires:	systemd
01cd24
%endif
01cd24
Requires:	kpatch >= 0.4.0-3
01cd24
Requires:	kernel-uname-r = %{kernel_ver_arch}
01cd24
01cd24
%if !%{empty_package}
01cd24
BuildRequires:	gcc elfutils-devel rpmdevtools asciidoc bc hmaccalc m4 net-tools xmlto zlib-devel binutils-devel newt-devel python-devel perl(ExtUtils::Embed) bison audit-libs-devel numactl-devel pciutils-devel openssl gettext kernel-devel ncurses-devel hostname java-devel python-docutils
01cd24
BuildRequires:	kernel-devel = %{kernel_ver}
01cd24
BuildRequires:	kernel-debuginfo = %{kernel_ver}
01cd24
01cd24
%ifarch x86_64
01cd24
BuildRequires: pesign
01cd24
%endif
01cd24
01cd24
%ifarch ppc64le
01cd24
BuildRequires: gcc-plugin-devel
01cd24
%endif
01cd24
01cd24
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
01cd24
01cd24
Source10:	kernel-%{kernel_ver}.src.rpm
01cd24
01cd24
# kpatch-build patches
01cd24
# Patch1: backport.patch
01cd24
01cd24
%global _dupsign_opts --keyname=rhelkpatch1
01cd24
01cd24
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
01cd24
%define kpatch		%{_sbindir}/kpatch
01cd24
%define kmoddir		%{_usr}/lib/kpatch/%{kernel_ver_arch}
01cd24
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
01cd24
%define patchmod	%{patchmodname}.ko
01cd24
01cd24
%define _missing_build_ids_terminate_build 1
01cd24
%define _find_debuginfo_opts -r
01cd24
%undefine _include_minidebuginfo
01cd24
%undefine _find_debuginfo_dwz_opts
01cd24
01cd24
%description
01cd24
This is a kernel live patch module which can be loaded by the kpatch
01cd24
command line utility to modify the code of a running kernel.  This patch
01cd24
module is targeted for kernel-%{kernel_ver}.
01cd24
01cd24
%prep
01cd24
%autosetup -n kpatch-%{kpatch_ver} -p1
01cd24
01cd24
%build
01cd24
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
01cd24
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
01cd24
01cd24
# kpatch-build
01cd24
make -C kpatch-build
01cd24
01cd24
# patch module
01cd24
for i in %{sources}; do
01cd24
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
01cd24
done
01cd24
export CACHEDIR="%{builddir}/.kpatch"
01cd24
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
01cd24
01cd24
01cd24
%install
01cd24
installdir=%{buildroot}/%{kmoddir}
01cd24
install -d $installdir
01cd24
install -m 755 %{builddir}/%{patchmod} $installdir
01cd24
01cd24
01cd24
%files
01cd24
%{_usr}/lib/kpatch
01cd24
01cd24
01cd24
%post
01cd24
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
01cd24
	cver="%{rpm_ver}_%{rpm_rel}"
01cd24
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
01cd24
01cd24
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
01cd24
01cd24
	if [ "${lver}" != "${cver}" ]; then
01cd24
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
01cd24
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
01cd24
	else
01cd24
		%{kpatch} load %{kmoddir}/%{patchmod}
01cd24
	fi
01cd24
fi
01cd24
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
01cd24
sync
01cd24
exit 0
01cd24
01cd24
01cd24
%postun
01cd24
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
01cd24
sync
01cd24
exit 0
01cd24
01cd24
%else
01cd24
%description
01cd24
This is an empty kpatch-patch package which does not contain any real patches.
01cd24
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
01cd24
01cd24
%files
01cd24
%doc
01cd24
%endif
01cd24
01cd24
%changelog
a0fe1f
* Wed Sep 29 2021 Joe Lawrence <joe.lawrence@redhat.com> [1-2.el7]
a0fe1f
- kernel: powerpc: KVM guest OS users can cause host OS memory corruption [1988221] {CVE-2021-37576}
a0fe1f
- kernel: Improper handling of VM_IO|VM_PFNMAP vmas in KVM can bypass RO checks [1975766] {CVE-2021-22543}
a0fe1f
311138
* Wed Sep 01 2021 Joe Lawrence <joe.lawrence@redhat.com> [1-1.el7]
311138
- kernel: use-after-free in route4_change() in net/sched/cls_route.c [1997195] {CVE-2021-3715}
311138
01cd24
* Mon Aug 16 2021 Joel Savitz <jsavitz@redhat.com> [0-0.el7]
01cd24
- An empty patch to subscribe to kpatch stream for kernel-3.10.0-1160.41.1.el7 [1994152]