Blame SPECS/kpatch-patch.spec

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