Blame SPECS/kpatch-patch.spec

0bbe1d
# Set to 1 if building an empty subscription-only package.
163da7
%define empty_package		0
0bbe1d
0bbe1d
#######################################################
0bbe1d
# Only need to update these variables and the changelog
0bbe1d
%define kernel_ver	4.18.0-372.19.1.el8_6
0bbe1d
%define kpatch_ver	0.9.6
163da7
%define rpm_ver		1
163da7
%define rpm_rel		1
0bbe1d
0bbe1d
%if !%{empty_package}
0bbe1d
# Patch sources below. DO NOT REMOVE THIS LINE.
163da7
#
163da7
# https://bugzilla.redhat.com/2122584
163da7
Source100: CVE-2022-2588.patch
0bbe1d
# End of patch sources. DO NOT REMOVE THIS LINE.
0bbe1d
%endif
0bbe1d
0bbe1d
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
0bbe1d
%define sanitized_kernel_ver   %{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), '.el8_?\%d?', ""), "%.", "_")))}
0bbe1d
%define kernel_ver_arch        %{kernel_ver}.%{_arch}
0bbe1d
0bbe1d
Name:		kpatch-patch-%{sanitized_kernel_ver}
0bbe1d
Version:	%{rpm_ver}
0bbe1d
Release:	%{rpm_rel}%{?dist}
0bbe1d
0bbe1d
%if %{empty_package}
0bbe1d
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
0bbe1d
%else
0bbe1d
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
0bbe1d
%endif
0bbe1d
0bbe1d
Group:		System Environment/Kernel
0bbe1d
License:	GPLv2
0bbe1d
ExclusiveArch:	x86_64 ppc64le
0bbe1d
0bbe1d
Conflicts:	%{name} < %{version}-%{release}
0bbe1d
0bbe1d
Provides:	kpatch-patch = %{kernel_ver_arch}
0bbe1d
Provides:	kpatch-patch = %{kernel_ver}
0bbe1d
0bbe1d
%if !%{empty_package}
0bbe1d
Requires:	systemd
0bbe1d
%endif
0bbe1d
Requires:	kpatch >= 0.6.1-1
0bbe1d
Requires:	kernel-uname-r = %{kernel_ver_arch}
0bbe1d
0bbe1d
%if !%{empty_package}
0bbe1d
BuildRequires:	patchutils
0bbe1d
BuildRequires:	kernel-devel = %{kernel_ver}
0bbe1d
BuildRequires:	kernel-debuginfo = %{kernel_ver}
0bbe1d
0bbe1d
# kernel build requirements, generated from:
0bbe1d
#   % rpmspec -q --buildrequires kernel.spec | sort | awk '{print "BuildRequires:\t" $0}'
0bbe1d
# with arch-specific packages moved into conditional block
0bbe1d
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
0bbe1d
0bbe1d
%ifarch x86_64
0bbe1d
BuildRequires:	pesign >= 0.10-4
0bbe1d
%endif
0bbe1d
0bbe1d
%ifarch ppc64le
0bbe1d
BuildRequires:	gcc-plugin-devel
0bbe1d
%endif
0bbe1d
0bbe1d
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
0bbe1d
0bbe1d
Source10:	kernel-%{kernel_ver}.src.rpm
0bbe1d
0bbe1d
# kpatch-build patches
0bbe1d
0bbe1d
%global _dupsign_opts --keyname=rhelkpatch1
0bbe1d
0bbe1d
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
0bbe1d
%define kpatch		%{_sbindir}/kpatch
0bbe1d
%define kmoddir 	%{_usr}/lib/kpatch/%{kernel_ver_arch}
0bbe1d
%define kinstdir	%{_sharedstatedir}/kpatch/%{kernel_ver_arch}
0bbe1d
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
0bbe1d
%define patchmod	%{patchmodname}.ko
0bbe1d
0bbe1d
%define _missing_build_ids_terminate_build 1
0bbe1d
%define _find_debuginfo_opts -r
0bbe1d
%undefine _include_minidebuginfo
0bbe1d
%undefine _find_debuginfo_dwz_opts
0bbe1d
0bbe1d
%description
0bbe1d
This is a kernel live patch module which can be loaded by the kpatch
0bbe1d
command line utility to modify the code of a running kernel.  This patch
0bbe1d
module is targeted for kernel-%{kernel_ver}.
0bbe1d
0bbe1d
%prep
0bbe1d
%autosetup -n kpatch-%{kpatch_ver} -p1
0bbe1d
0bbe1d
%build
0bbe1d
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
0bbe1d
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
0bbe1d
0bbe1d
# kpatch-build
0bbe1d
make -C kpatch-build
0bbe1d
0bbe1d
# patch module
0bbe1d
for i in %{sources}; do
0bbe1d
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
0bbe1d
done
0bbe1d
export CACHEDIR="%{builddir}/.kpatch"
0bbe1d
kpatch-build/kpatch-build --non-replace -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
0bbe1d
0bbe1d
0bbe1d
%install
0bbe1d
installdir=%{buildroot}/%{kmoddir}
0bbe1d
install -d $installdir
0bbe1d
install -m 755 %{builddir}/%{patchmod} $installdir
0bbe1d
0bbe1d
0bbe1d
%files
0bbe1d
%{_usr}/lib/kpatch
0bbe1d
0bbe1d
0bbe1d
%post
0bbe1d
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
0bbe1d
chcon -t modules_object_t %{kinstdir}/%{patchmod}
0bbe1d
sync
0bbe1d
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
0bbe1d
	cver="%{rpm_ver}_%{rpm_rel}"
0bbe1d
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
0bbe1d
0bbe1d
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
0bbe1d
0bbe1d
	if [ "${lver}" != "${cver}" ]; then
0bbe1d
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
0bbe1d
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
0bbe1d
	else
0bbe1d
		%{kpatch} load %{patchmod}
0bbe1d
	fi
0bbe1d
fi
0bbe1d
exit 0
0bbe1d
0bbe1d
0bbe1d
%postun
0bbe1d
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
0bbe1d
sync
0bbe1d
exit 0
0bbe1d
0bbe1d
%else
0bbe1d
%description
0bbe1d
This is an empty kpatch-patch package which does not contain any real patches.
0bbe1d
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
0bbe1d
0bbe1d
%files
0bbe1d
%doc
0bbe1d
%endif
0bbe1d
0bbe1d
%changelog
163da7
* Mon Oct 10 2022 Yannick Cote <ycote@redhat.com> [1-1.el8_6]
163da7
- kernel: a use-after-free in cls_route filter implementation may lead to privilege escalation [2122584] {CVE-2022-2588}
163da7
0bbe1d
* Wed Jul 20 2022 Yannick Cote <ycote@redhat.com> [0-0.el8]
0bbe1d
- An empty patch to subscribe to kpatch stream for kernel-4.18.0-372.19.1.el8_6 [2109268]