Blame SPECS/kpatch-patch.spec

7cb336
# Set to 1 if building an empty subscription-only package.
51c253
%define empty_package		0
7cb336
7cb336
#######################################################
7cb336
# Only need to update these variables and the changelog
7cb336
%define kernel_ver	3.10.0-1160.24.1.el7
7cb336
%define kpatch_ver	0.9.2
51c253
%define rpm_ver		1
51c253
%define rpm_rel		1
7cb336
7cb336
%if !%{empty_package}
7cb336
# Patch sources below. DO NOT REMOVE THIS LINE.
51c253
#
51c253
# https://bugzilla.redhat.com/1935112
51c253
Source100: CVE-2021-3347.patch
7cb336
# End of patch sources. DO NOT REMOVE THIS LINE.
7cb336
%endif
7cb336
7cb336
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
7cb336
%define sanitized_kernel_ver	%{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), ".el7", ""), "%.", "_")))}
7cb336
%define kernel_ver_arch	%{kernel_ver}.%{_arch}
7cb336
7cb336
Name:		kpatch-patch-%{sanitized_kernel_ver}
7cb336
Version:	%{rpm_ver}
7cb336
Release:	%{rpm_rel}.el7
7cb336
7cb336
%if %{empty_package}
7cb336
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
7cb336
%else
7cb336
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
7cb336
%endif
7cb336
7cb336
Group:		System Environment/Kernel
7cb336
License:	GPLv2
7cb336
ExclusiveArch:	x86_64 ppc64le
7cb336
7cb336
Conflicts:	%{name} < %{version}-%{release}
7cb336
7cb336
Provides:	kpatch-patch = %{kernel_ver_arch}
7cb336
Provides:	kpatch-patch = %{kernel_ver}
7cb336
7cb336
%if !%{empty_package}
7cb336
Requires:	systemd
7cb336
%endif
7cb336
Requires:	kpatch >= 0.4.0-3
7cb336
Requires:	kernel-uname-r = %{kernel_ver_arch}
7cb336
7cb336
%if !%{empty_package}
7cb336
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
7cb336
BuildRequires:	kernel-devel = %{kernel_ver}
7cb336
BuildRequires:	kernel-debuginfo = %{kernel_ver}
7cb336
7cb336
%ifarch x86_64
7cb336
BuildRequires: pesign
7cb336
%endif
7cb336
7cb336
%ifarch ppc64le
7cb336
BuildRequires: gcc-plugin-devel
7cb336
%endif
7cb336
7cb336
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
7cb336
7cb336
Source10:	kernel-%{kernel_ver}.src.rpm
7cb336
7cb336
# kpatch-build patches
7cb336
# Patch1: backport.patch
7cb336
7cb336
%global _dupsign_opts --keyname=rhelkpatch1
7cb336
7cb336
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
7cb336
%define kpatch		%{_sbindir}/kpatch
7cb336
%define kmoddir		%{_usr}/lib/kpatch/%{kernel_ver_arch}
7cb336
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
7cb336
%define patchmod	%{patchmodname}.ko
7cb336
7cb336
%define _missing_build_ids_terminate_build 1
7cb336
%define _find_debuginfo_opts -r
7cb336
%undefine _include_minidebuginfo
7cb336
%undefine _find_debuginfo_dwz_opts
7cb336
7cb336
%description
7cb336
This is a kernel live patch module which can be loaded by the kpatch
7cb336
command line utility to modify the code of a running kernel.  This patch
7cb336
module is targeted for kernel-%{kernel_ver}.
7cb336
7cb336
%prep
7cb336
%autosetup -n kpatch-%{kpatch_ver} -p1
7cb336
7cb336
%build
7cb336
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
7cb336
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
7cb336
7cb336
# kpatch-build
7cb336
make -C kpatch-build
7cb336
7cb336
# patch module
7cb336
for i in %{sources}; do
7cb336
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
7cb336
done
7cb336
export CACHEDIR="%{builddir}/.kpatch"
7cb336
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
7cb336
7cb336
7cb336
%install
7cb336
installdir=%{buildroot}/%{kmoddir}
7cb336
install -d $installdir
7cb336
install -m 755 %{builddir}/%{patchmod} $installdir
7cb336
7cb336
7cb336
%files
7cb336
%{_usr}/lib/kpatch
7cb336
7cb336
7cb336
%post
7cb336
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
7cb336
	cver="%{rpm_ver}_%{rpm_rel}"
7cb336
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
7cb336
7cb336
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
7cb336
7cb336
	if [ "${lver}" != "${cver}" ]; then
7cb336
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
7cb336
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
7cb336
	else
7cb336
		%{kpatch} load %{kmoddir}/%{patchmod}
7cb336
	fi
7cb336
fi
7cb336
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
7cb336
sync
7cb336
exit 0
7cb336
7cb336
7cb336
%postun
7cb336
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
7cb336
sync
7cb336
exit 0
7cb336
7cb336
%else
7cb336
%description
7cb336
This is an empty kpatch-patch package which does not contain any real patches.
7cb336
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
7cb336
7cb336
%files
7cb336
%doc
7cb336
%endif
7cb336
7cb336
%changelog
51c253
* Fri May 21 2021 Artem Savkov <asavkov@redhat.com> [1-1.el7]
51c253
- Use after free via PI futex state [1935112] {CVE-2021-3347}
51c253
7cb336
* Wed Mar 31 2021 Yannick Cote <ycote@redhat.com> [0-0.el7]
7cb336
- An empty patch to subscribe to kpatch stream for kernel-3.10.0-1160.24.1.el7 [1944814]