Blame SPECS/kpatch-patch.spec

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