Blame SPECS/kpatch-patch.spec

2bf68e
# Set to 1 if building an empty subscription-only package.
98e09b
%define empty_package		0
2bf68e
2bf68e
#######################################################
2bf68e
# Only need to update these variables and the changelog
2bf68e
%define kernel_ver	4.18.0-305.19.1.el8_4
2bf68e
%define kpatch_ver	0.9.3
98e09b
%define rpm_ver		1
98e09b
%define rpm_rel		1
2bf68e
2bf68e
%if !%{empty_package}
2bf68e
# Patch sources below. DO NOT REMOVE THIS LINE.
98e09b
#
98e09b
# https://bugzilla.redhat.com/1981706
98e09b
Source100: CVE-2020-36385.patch
98e09b
#
98e09b
# https://bugzilla.redhat.com/1979028
98e09b
Source101: CVE-2021-0512.patch
2bf68e
# End of patch sources. DO NOT REMOVE THIS LINE.
2bf68e
%endif
2bf68e
2bf68e
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
2bf68e
%define sanitized_kernel_ver   %{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), '.el8_?\%d?', ""), "%.", "_")))}
2bf68e
%define kernel_ver_arch        %{kernel_ver}.%{_arch}
2bf68e
2bf68e
Name:		kpatch-patch-%{sanitized_kernel_ver}
2bf68e
Version:	%{rpm_ver}
2bf68e
Release:	%{rpm_rel}%{?dist}
2bf68e
2bf68e
%if %{empty_package}
2bf68e
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
2bf68e
%else
2bf68e
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
2bf68e
%endif
2bf68e
2bf68e
Group:		System Environment/Kernel
2bf68e
License:	GPLv2
2bf68e
ExclusiveArch:	x86_64 ppc64le
2bf68e
2bf68e
Conflicts:	%{name} < %{version}-%{release}
2bf68e
2bf68e
Provides:	kpatch-patch = %{kernel_ver_arch}
2bf68e
Provides:	kpatch-patch = %{kernel_ver}
2bf68e
2bf68e
%if !%{empty_package}
2bf68e
Requires:	systemd
2bf68e
%endif
2bf68e
Requires:	kpatch >= 0.6.1-1
2bf68e
Requires:	kernel-uname-r = %{kernel_ver_arch}
2bf68e
2bf68e
%if !%{empty_package}
2bf68e
BuildRequires:	patchutils
2bf68e
BuildRequires:	kernel-devel = %{kernel_ver}
2bf68e
BuildRequires:	kernel-debuginfo = %{kernel_ver}
2bf68e
2bf68e
# kernel build requirements, generated from:
2bf68e
#   % rpmspec -q --buildrequires kernel.spec | sort | awk '{print "BuildRequires:\t" $0}'
2bf68e
# with arch-specific packages moved into conditional block
2bf68e
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
2bf68e
2bf68e
%ifarch x86_64
2bf68e
BuildRequires:	pesign >= 0.10-4
2bf68e
%endif
2bf68e
2bf68e
%ifarch ppc64le
2bf68e
BuildRequires:	gcc-plugin-devel
2bf68e
%endif
2bf68e
2bf68e
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
2bf68e
2bf68e
Source10:	kernel-%{kernel_ver}.src.rpm
2bf68e
2bf68e
# kpatch-build patches
2bf68e
2bf68e
%global _dupsign_opts --keyname=rhelkpatch1
2bf68e
2bf68e
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
2bf68e
%define kpatch		%{_sbindir}/kpatch
2bf68e
%define kmoddir 	%{_usr}/lib/kpatch/%{kernel_ver_arch}
2bf68e
%define kinstdir	%{_sharedstatedir}/kpatch/%{kernel_ver_arch}
2bf68e
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
2bf68e
%define patchmod	%{patchmodname}.ko
2bf68e
2bf68e
%define _missing_build_ids_terminate_build 1
2bf68e
%define _find_debuginfo_opts -r
2bf68e
%undefine _include_minidebuginfo
2bf68e
%undefine _find_debuginfo_dwz_opts
2bf68e
2bf68e
%description
2bf68e
This is a kernel live patch module which can be loaded by the kpatch
2bf68e
command line utility to modify the code of a running kernel.  This patch
2bf68e
module is targeted for kernel-%{kernel_ver}.
2bf68e
2bf68e
%prep
2bf68e
%autosetup -n kpatch-%{kpatch_ver} -p1
2bf68e
2bf68e
%build
2bf68e
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
2bf68e
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
2bf68e
2bf68e
# kpatch-build
2bf68e
make -C kpatch-build
2bf68e
2bf68e
# patch module
2bf68e
for i in %{sources}; do
2bf68e
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
2bf68e
done
2bf68e
export CACHEDIR="%{builddir}/.kpatch"
2bf68e
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
2bf68e
2bf68e
2bf68e
%install
2bf68e
installdir=%{buildroot}/%{kmoddir}
2bf68e
install -d $installdir
2bf68e
install -m 755 %{builddir}/%{patchmod} $installdir
2bf68e
2bf68e
2bf68e
%files
2bf68e
%{_usr}/lib/kpatch
2bf68e
2bf68e
2bf68e
%post
2bf68e
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
2bf68e
chcon -t modules_object_t %{kinstdir}/%{patchmod}
2bf68e
sync
2bf68e
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
2bf68e
	cver="%{rpm_ver}_%{rpm_rel}"
2bf68e
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
2bf68e
2bf68e
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
2bf68e
2bf68e
	if [ "${lver}" != "${cver}" ]; then
2bf68e
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
2bf68e
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
2bf68e
	else
2bf68e
		%{kpatch} load %{patchmod}
2bf68e
	fi
2bf68e
fi
2bf68e
exit 0
2bf68e
2bf68e
2bf68e
%postun
2bf68e
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
2bf68e
sync
2bf68e
exit 0
2bf68e
2bf68e
%else
2bf68e
%description
2bf68e
This is an empty kpatch-patch package which does not contain any real patches.
2bf68e
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
2bf68e
2bf68e
%files
2bf68e
%doc
2bf68e
%endif
2bf68e
2bf68e
%changelog
98e09b
* Wed Oct 27 2021 Artem Savkov <asavkov@redhat.com> [1-1.el8_4]
98e09b
- out-of-bounds write due to a heap buffer overflow in __hidinput_change_resolution_multipliers() [1979028] {CVE-2021-0512}
98e09b
- use-after-free in drivers/infiniband/core/ucma.c ctx use-after-free [1981706] {CVE-2020-36385}
98e09b
2bf68e
* Wed Sep 08 2021 Artem Savkov <asavkov@redhat.com> [0-0.el8_4]
2bf68e
- An empty patch to subscribe to kpatch stream for kernel-4.18.0-305.19.1.el8_4 [2002294]