Blame SPECS/kpatch-patch.spec

4017bb
# Set to 1 if building an empty subscription-only package.
cbf2d8
%define empty_package		0
4017bb
4017bb
#######################################################
4017bb
# Only need to update these variables and the changelog
4017bb
%define kernel_ver	3.10.0-1160.81.1.el7
4017bb
%define kpatch_ver	0.9.2
cbf2d8
%define rpm_ver		1
cbf2d8
%define rpm_rel		1
4017bb
4017bb
%if !%{empty_package}
4017bb
# Patch sources below. DO NOT REMOVE THIS LINE.
cbf2d8
#
cbf2d8
# https://bugzilla.redhat.com/2130096
cbf2d8
Source100: CVE-2022-2964.patch
4017bb
# End of patch sources. DO NOT REMOVE THIS LINE.
4017bb
%endif
4017bb
4017bb
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
4017bb
%define sanitized_kernel_ver	%{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), ".el7", ""), "%.", "_")))}
4017bb
%define kernel_ver_arch	%{kernel_ver}.%{_arch}
4017bb
4017bb
Name:		kpatch-patch-%{sanitized_kernel_ver}
4017bb
Version:	%{rpm_ver}
4017bb
Release:	%{rpm_rel}.el7
4017bb
4017bb
%if %{empty_package}
4017bb
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
4017bb
%else
4017bb
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
4017bb
%endif
4017bb
4017bb
Group:		System Environment/Kernel
4017bb
License:	GPLv2
4017bb
ExclusiveArch:	x86_64 ppc64le
4017bb
4017bb
Conflicts:	%{name} < %{version}-%{release}
4017bb
4017bb
Provides:	kpatch-patch = %{kernel_ver_arch}
4017bb
Provides:	kpatch-patch = %{kernel_ver}
4017bb
4017bb
%if !%{empty_package}
4017bb
Requires:	systemd
4017bb
%endif
4017bb
Requires:	kpatch >= 0.4.0-3
4017bb
Requires:	kernel-uname-r = %{kernel_ver_arch}
4017bb
4017bb
%if !%{empty_package}
4017bb
BuildRequires:	gcc elfutils-devel rpmdevtools asciidoc bc hmaccalc m4 net-tools xmlto zlib-devel binutils-devel newt-devel python-devel perl(ExtUtils::Embed) bison audit-libs-devel numactl-devel pciutils-devel openssl gettext kernel-devel ncurses-devel hostname java-devel python-docutils
4017bb
BuildRequires:	kernel-devel = %{kernel_ver}
4017bb
BuildRequires:	kernel-debuginfo = %{kernel_ver}
4017bb
4017bb
%ifarch x86_64
4017bb
BuildRequires: pesign
4017bb
%endif
4017bb
4017bb
%ifarch ppc64le
4017bb
BuildRequires: gcc-plugin-devel
4017bb
%endif
4017bb
4017bb
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
4017bb
4017bb
Source10:	kernel-%{kernel_ver}.src.rpm
4017bb
4017bb
# kpatch-build patches
4017bb
# Patch1: backport.patch
cbf2d8
Patch1: v0.9.2-backport-MR-1281-create-diff-object-add-suppo.patch
cbf2d8
Patch2: v0.9.2-backport-MR-1200-Make-sure-section-symbols-ex.patch
4017bb
4017bb
%global _dupsign_opts --keyname=rhelkpatch1
4017bb
4017bb
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
4017bb
%define kpatch		%{_sbindir}/kpatch
4017bb
%define kmoddir		%{_usr}/lib/kpatch/%{kernel_ver_arch}
4017bb
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
4017bb
%define patchmod	%{patchmodname}.ko
4017bb
4017bb
%define _missing_build_ids_terminate_build 1
4017bb
%define _find_debuginfo_opts -r
4017bb
%undefine _include_minidebuginfo
4017bb
%undefine _find_debuginfo_dwz_opts
4017bb
4017bb
%description
4017bb
This is a kernel live patch module which can be loaded by the kpatch
4017bb
command line utility to modify the code of a running kernel.  This patch
4017bb
module is targeted for kernel-%{kernel_ver}.
4017bb
4017bb
%prep
4017bb
%autosetup -n kpatch-%{kpatch_ver} -p1
4017bb
4017bb
%build
4017bb
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
4017bb
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
4017bb
4017bb
# kpatch-build
4017bb
make -C kpatch-build
4017bb
4017bb
# patch module
4017bb
for i in %{sources}; do
4017bb
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
4017bb
done
4017bb
export CACHEDIR="%{builddir}/.kpatch"
4017bb
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
4017bb
4017bb
4017bb
%install
4017bb
installdir=%{buildroot}/%{kmoddir}
4017bb
install -d $installdir
4017bb
install -m 755 %{builddir}/%{patchmod} $installdir
4017bb
4017bb
4017bb
%files
4017bb
%{_usr}/lib/kpatch
4017bb
4017bb
4017bb
%post
4017bb
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
4017bb
	cver="%{rpm_ver}_%{rpm_rel}"
4017bb
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
4017bb
4017bb
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
4017bb
4017bb
	if [ "${lver}" != "${cver}" ]; then
4017bb
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
4017bb
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
4017bb
	else
4017bb
		%{kpatch} load %{kmoddir}/%{patchmod}
4017bb
	fi
4017bb
fi
4017bb
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
4017bb
sync
4017bb
exit 0
4017bb
4017bb
4017bb
%postun
4017bb
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
4017bb
sync
4017bb
exit 0
4017bb
4017bb
%else
4017bb
%description
4017bb
This is an empty kpatch-patch package which does not contain any real patches.
4017bb
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
4017bb
4017bb
%files
4017bb
%doc
4017bb
%endif
4017bb
4017bb
%changelog
cbf2d8
* Tue Jan 10 2023 Yannick Cote <ycote@redhat.com> [1-1.el7]
cbf2d8
- kernel: memory corruption in AX88179_178A based USB ethernet device. [2130096] {CVE-2022-2964}
cbf2d8
4017bb
* Mon Nov 28 2022 Yannick Cote <ycote@redhat.com> [0-0.el7]
4017bb
- An empty patch to subscribe to kpatch stream for kernel-3.10.0-1160.81.1.el7 [2149047]