Blame SPECS/kpatch-patch.spec

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