Blame SPECS/kpatch-patch.spec

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