Blame SPECS/kpatch-patch.spec

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