Blame SPECS/kpatch-patch.spec

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