Blame SPECS/kpatch-patch.spec

08814c
# Set to 1 if building an empty subscription-only package.
486b82
%define empty_package		0
08814c
08814c
#######################################################
08814c
# Only need to update these variables and the changelog
08814c
%define kernel_ver	3.10.0-1160.71.1.el7
08814c
%define kpatch_ver	0.9.2
486b82
%define rpm_ver		1
b88ab5
%define rpm_rel		2
08814c
08814c
%if !%{empty_package}
08814c
# Patch sources below. DO NOT REMOVE THIS LINE.
486b82
#
486b82
# https://bugzilla.redhat.com/2122586
486b82
Source100: CVE-2022-2588.patch
b88ab5
#
b88ab5
# https://bugzilla.redhat.com/2130096
b88ab5
Source101: CVE-2022-2964.patch
08814c
# End of patch sources. DO NOT REMOVE THIS LINE.
08814c
%endif
08814c
08814c
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
08814c
%define sanitized_kernel_ver	%{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), ".el7", ""), "%.", "_")))}
08814c
%define kernel_ver_arch	%{kernel_ver}.%{_arch}
08814c
08814c
Name:		kpatch-patch-%{sanitized_kernel_ver}
08814c
Version:	%{rpm_ver}
08814c
Release:	%{rpm_rel}.el7
08814c
08814c
%if %{empty_package}
08814c
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
08814c
%else
08814c
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
08814c
%endif
08814c
08814c
Group:		System Environment/Kernel
08814c
License:	GPLv2
08814c
ExclusiveArch:	x86_64 ppc64le
08814c
08814c
Conflicts:	%{name} < %{version}-%{release}
08814c
08814c
Provides:	kpatch-patch = %{kernel_ver_arch}
08814c
Provides:	kpatch-patch = %{kernel_ver}
08814c
08814c
%if !%{empty_package}
08814c
Requires:	systemd
08814c
%endif
08814c
Requires:	kpatch >= 0.4.0-3
08814c
Requires:	kernel-uname-r = %{kernel_ver_arch}
08814c
08814c
%if !%{empty_package}
08814c
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
08814c
BuildRequires:	kernel-devel = %{kernel_ver}
08814c
BuildRequires:	kernel-debuginfo = %{kernel_ver}
08814c
08814c
%ifarch x86_64
08814c
BuildRequires: pesign
08814c
%endif
08814c
08814c
%ifarch ppc64le
08814c
BuildRequires: gcc-plugin-devel
08814c
%endif
08814c
08814c
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
08814c
08814c
Source10:	kernel-%{kernel_ver}.src.rpm
08814c
08814c
# kpatch-build patches
08814c
# Patch1: backport.patch
b88ab5
Patch1: v0.9.2-backport-MR-1281-create-diff-object-add-suppo.patch
b88ab5
Patch2: v0.9.2-backport-MR-1200-Make-sure-section-symbols-ex.patch
08814c
08814c
%global _dupsign_opts --keyname=rhelkpatch1
08814c
08814c
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
08814c
%define kpatch		%{_sbindir}/kpatch
08814c
%define kmoddir		%{_usr}/lib/kpatch/%{kernel_ver_arch}
08814c
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
08814c
%define patchmod	%{patchmodname}.ko
08814c
08814c
%define _missing_build_ids_terminate_build 1
08814c
%define _find_debuginfo_opts -r
08814c
%undefine _include_minidebuginfo
08814c
%undefine _find_debuginfo_dwz_opts
08814c
08814c
%description
08814c
This is a kernel live patch module which can be loaded by the kpatch
08814c
command line utility to modify the code of a running kernel.  This patch
08814c
module is targeted for kernel-%{kernel_ver}.
08814c
08814c
%prep
08814c
%autosetup -n kpatch-%{kpatch_ver} -p1
08814c
08814c
%build
08814c
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
08814c
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
08814c
08814c
# kpatch-build
08814c
make -C kpatch-build
08814c
08814c
# patch module
08814c
for i in %{sources}; do
08814c
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
08814c
done
08814c
export CACHEDIR="%{builddir}/.kpatch"
08814c
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
08814c
08814c
08814c
%install
08814c
installdir=%{buildroot}/%{kmoddir}
08814c
install -d $installdir
08814c
install -m 755 %{builddir}/%{patchmod} $installdir
08814c
08814c
08814c
%files
08814c
%{_usr}/lib/kpatch
08814c
08814c
08814c
%post
08814c
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
08814c
	cver="%{rpm_ver}_%{rpm_rel}"
08814c
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
08814c
08814c
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
08814c
08814c
	if [ "${lver}" != "${cver}" ]; then
08814c
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
08814c
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
08814c
	else
08814c
		%{kpatch} load %{kmoddir}/%{patchmod}
08814c
	fi
08814c
fi
08814c
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
08814c
sync
08814c
exit 0
08814c
08814c
08814c
%postun
08814c
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
08814c
sync
08814c
exit 0
08814c
08814c
%else
08814c
%description
08814c
This is an empty kpatch-patch package which does not contain any real patches.
08814c
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
08814c
08814c
%files
08814c
%doc
08814c
%endif
08814c
08814c
%changelog
b88ab5
* Tue Jan 10 2023 Yannick Cote <ycote@redhat.com> [1-2.el7]
b88ab5
- kernel: memory corruption in AX88179_178A based USB ethernet device. [2130096] {CVE-2022-2964}
b88ab5
486b82
* Thu Oct 13 2022 Yannick Cote <ycote@redhat.com> [1-1.el7]
486b82
- kernel: a use-after-free in cls_route filter implementation may lead to privilege escalation [2122586] {CVE-2022-2588}
486b82
08814c
* Wed Jun 15 2022 Yannick Cote <ycote@redhat.com> [0-0.el7]
08814c
- An empty patch to subscribe to kpatch stream for kernel-3.10.0-1160.71.1.el7 [2097442]