Blame SPECS/kpatch-patch.spec

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