Blame SPECS/kpatch-patch.spec

2096e6
# Set to 1 if building an empty subscription-only package.
a417e5
%define empty_package		0
2096e6
2096e6
#######################################################
2096e6
# Only need to update these variables and the changelog
2096e6
%define kernel_ver	5.14.0-70.26.1.el9_0
2096e6
%define kpatch_ver	0.9.6
a417e5
%define rpm_ver		1
a417e5
%define rpm_rel		2
2096e6
2096e6
%if !%{empty_package}
2096e6
# Patch sources below. DO NOT REMOVE THIS LINE.
a417e5
#
a417e5
# https://bugzilla.redhat.com/2118959
a417e5
Source100: CVE-2022-2585.patch
2096e6
# End of patch sources. DO NOT REMOVE THIS LINE.
2096e6
%endif
2096e6
2096e6
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
2096e6
%define sanitized_kernel_ver   %{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), '.el9_?\%d?', ""), "%.", "_")))}
2096e6
%define kernel_ver_arch        %{kernel_ver}.%{_arch}
2096e6
2096e6
Name:		kpatch-patch-%{sanitized_kernel_ver}
2096e6
Version:	%{rpm_ver}
2096e6
Release:	%{rpm_rel}%{?dist}
2096e6
2096e6
%if %{empty_package}
2096e6
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
2096e6
%else
2096e6
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
2096e6
%endif
2096e6
2096e6
Group:		System Environment/Kernel
2096e6
License:	GPLv2
2096e6
ExclusiveArch:	x86_64 ppc64le
2096e6
2096e6
Conflicts:	%{name} < %{version}-%{release}
2096e6
2096e6
Provides:	kpatch-patch = %{kernel_ver_arch}
2096e6
Provides:	kpatch-patch = %{kernel_ver}
2096e6
2096e6
%if !%{empty_package}
2096e6
Requires:	systemd
2096e6
%endif
2096e6
Requires:	kpatch >= 0.6.1-1
2096e6
Requires:	kernel-uname-r = %{kernel_ver_arch}
2096e6
2096e6
%if !%{empty_package}
2096e6
BuildRequires:	patchutils
2096e6
BuildRequires:	kernel-devel = %{kernel_ver}
2096e6
BuildRequires:	kernel-debuginfo = %{kernel_ver}
2096e6
2096e6
# kernel build requirements, generated from:
2096e6
#   % rpmspec -q --buildrequires kernel.spec | sort | awk '{print "BuildRequires:\t" $0}'
2096e6
# with arch-specific packages moved into conditional block
2096e6
BuildRequires:	bash
2096e6
BuildRequires:	bc
2096e6
BuildRequires:	binutils
2096e6
BuildRequires:	bison
2096e6
BuildRequires:	bpftool
2096e6
BuildRequires:	bzip2
2096e6
BuildRequires:	coreutils
2096e6
BuildRequires:	diffutils
2096e6
BuildRequires:	dwarves
2096e6
BuildRequires:	elfutils
2096e6
BuildRequires:	elfutils-devel
2096e6
BuildRequires:	findutils
2096e6
BuildRequires:	flex
2096e6
BuildRequires:	gawk
2096e6
BuildRequires:	gcc
2096e6
BuildRequires:	gcc-c++
2096e6
BuildRequires:	gcc-plugin-devel
2096e6
BuildRequires:	git-core
2096e6
BuildRequires:	glibc-static
2096e6
BuildRequires:	gzip
2096e6
BuildRequires:	hmaccalc
2096e6
BuildRequires:	hostname
2096e6
BuildRequires:	kernel-rpm-macros >= 185-9
2096e6
BuildRequires:	kmod
2096e6
BuildRequires:	m4
2096e6
BuildRequires:	make
2096e6
BuildRequires:	net-tools
2096e6
BuildRequires:	nss-tools
2096e6
BuildRequires:	openssl
2096e6
BuildRequires:	openssl-devel
2096e6
BuildRequires:	patch
2096e6
BuildRequires:	perl-Carp
2096e6
BuildRequires:	perl-devel
2096e6
BuildRequires:	perl-generators
2096e6
BuildRequires:	perl-interpreter
2096e6
BuildRequires:	python3-devel
2096e6
BuildRequires:	redhat-rpm-config
2096e6
BuildRequires:	rpm-build
2096e6
BuildRequires:	system-sb-certs
2096e6
BuildRequires:	tar
2096e6
BuildRequires:	which
2096e6
BuildRequires:	xz
2096e6
2096e6
%ifarch x86_64
2096e6
BuildRequires:	pesign >= 0.10-4
2096e6
%endif
2096e6
2096e6
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
2096e6
2096e6
Source10:	kernel-%{kernel_ver}.src.rpm
2096e6
2096e6
# kpatch-build patches
2096e6
2096e6
%global _dupsign_opts --keyname=rhelkpatch1
2096e6
2096e6
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
2096e6
%define kpatch		%{_sbindir}/kpatch
2096e6
%define kmoddir 	%{_usr}/lib/kpatch/%{kernel_ver_arch}
2096e6
%define kinstdir	%{_sharedstatedir}/kpatch/%{kernel_ver_arch}
2096e6
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
2096e6
%define patchmod	%{patchmodname}.ko
2096e6
2096e6
%define _missing_build_ids_terminate_build 1
2096e6
%define _find_debuginfo_opts -r
2096e6
%undefine _include_minidebuginfo
2096e6
%undefine _find_debuginfo_dwz_opts
2096e6
2096e6
%description
2096e6
This is a kernel live patch module which can be loaded by the kpatch
2096e6
command line utility to modify the code of a running kernel.  This patch
2096e6
module is targeted for kernel-%{kernel_ver}.
2096e6
2096e6
%prep
2096e6
%autosetup -n kpatch-%{kpatch_ver} -p1
2096e6
2096e6
%build
2096e6
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
2096e6
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
2096e6
2096e6
# kpatch-build
2096e6
make -C kpatch-build
2096e6
2096e6
# patch module
2096e6
for i in %{sources}; do
2096e6
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
2096e6
done
2096e6
export CACHEDIR="%{builddir}/.kpatch"
2096e6
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
2096e6
2096e6
2096e6
%install
2096e6
installdir=%{buildroot}/%{kmoddir}
2096e6
install -d $installdir
2096e6
install -m 755 %{builddir}/%{patchmod} $installdir
2096e6
2096e6
2096e6
%files
2096e6
%{_usr}/lib/kpatch
2096e6
2096e6
2096e6
%post
2096e6
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
2096e6
chcon -t modules_object_t %{kinstdir}/%{patchmod}
2096e6
sync
2096e6
if [[ %{kernel_ver_arch} = $(uname -r) && "${LEAPP_IPU_IN_PROGRESS}" != "8to9" ]]; then
2096e6
	cver="%{rpm_ver}_%{rpm_rel}"
2096e6
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
2096e6
2096e6
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
2096e6
2096e6
	if [ "${lver}" != "${cver}" ]; then
2096e6
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
2096e6
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
2096e6
	else
2096e6
		%{kpatch} load %{patchmod}
2096e6
	fi
2096e6
fi
2096e6
exit 0
2096e6
2096e6
2096e6
%postun
2096e6
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
2096e6
sync
2096e6
exit 0
2096e6
2096e6
%else
2096e6
%description
2096e6
This is an empty kpatch-patch package which does not contain any real patches.
2096e6
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
2096e6
2096e6
%files
2096e6
%doc
2096e6
%endif
2096e6
2096e6
%changelog
a417e5
* Mon Oct 17 2022 Yannick Cote <ycote@redhat.com> [1-2.el9_0]
a417e5
- kernel: posix cpu timer use-after-free may lead to local privilege escalation [2118959] {CVE-2022-2585}
a417e5
2096e6
* Tue Sep 06 2022 Yannick Cote <ycote@redhat.com> [0-0.el9]
2096e6
- An empty patch to subscribe to kpatch stream for kernel-5.14.0-70.26.1.el9_0 [2124577]