Blame SPECS/kpatch-patch.spec

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