Blame SPECS/kpatch-patch.spec

c7b84e
# Set to 1 if building an empty subscription-only package.
74201f
%define empty_package		0
c7b84e
c7b84e
#######################################################
c7b84e
# Only need to update these variables and the changelog
c7b84e
%define kernel_ver	3.10.0-1160.59.1.el7
c7b84e
%define kpatch_ver	0.9.2
74201f
%define rpm_ver		1
20fa05
%define rpm_rel		2
c7b84e
c7b84e
%if !%{empty_package}
c7b84e
# Patch sources below. DO NOT REMOVE THIS LINE.
74201f
#
74201f
# https://bugzilla.redhat.com/2033360
74201f
Source100: CVE-2021-4028.patch
74201f
#
74201f
# https://bugzilla.redhat.com/2032491
74201f
Source101: CVE-2021-4083.patch
20fa05
#
20fa05
# https://bugzilla.redhat.com/2052183
20fa05
Source102: CVE-2022-0492.patch
c7b84e
# End of patch sources. DO NOT REMOVE THIS LINE.
c7b84e
%endif
c7b84e
c7b84e
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
c7b84e
%define sanitized_kernel_ver	%{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), ".el7", ""), "%.", "_")))}
c7b84e
%define kernel_ver_arch	%{kernel_ver}.%{_arch}
c7b84e
c7b84e
Name:		kpatch-patch-%{sanitized_kernel_ver}
c7b84e
Version:	%{rpm_ver}
c7b84e
Release:	%{rpm_rel}.el7
c7b84e
c7b84e
%if %{empty_package}
c7b84e
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
c7b84e
%else
c7b84e
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
c7b84e
%endif
c7b84e
c7b84e
Group:		System Environment/Kernel
c7b84e
License:	GPLv2
c7b84e
ExclusiveArch:	x86_64 ppc64le
c7b84e
c7b84e
Conflicts:	%{name} < %{version}-%{release}
c7b84e
c7b84e
Provides:	kpatch-patch = %{kernel_ver_arch}
c7b84e
Provides:	kpatch-patch = %{kernel_ver}
c7b84e
c7b84e
%if !%{empty_package}
c7b84e
Requires:	systemd
c7b84e
%endif
c7b84e
Requires:	kpatch >= 0.4.0-3
c7b84e
Requires:	kernel-uname-r = %{kernel_ver_arch}
c7b84e
c7b84e
%if !%{empty_package}
c7b84e
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
c7b84e
BuildRequires:	kernel-devel = %{kernel_ver}
c7b84e
BuildRequires:	kernel-debuginfo = %{kernel_ver}
c7b84e
c7b84e
%ifarch x86_64
c7b84e
BuildRequires: pesign
c7b84e
%endif
c7b84e
c7b84e
%ifarch ppc64le
c7b84e
BuildRequires: gcc-plugin-devel
c7b84e
%endif
c7b84e
c7b84e
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
c7b84e
c7b84e
Source10:	kernel-%{kernel_ver}.src.rpm
c7b84e
c7b84e
# kpatch-build patches
c7b84e
# Patch1: backport.patch
c7b84e
c7b84e
%global _dupsign_opts --keyname=rhelkpatch1
c7b84e
c7b84e
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
c7b84e
%define kpatch		%{_sbindir}/kpatch
c7b84e
%define kmoddir		%{_usr}/lib/kpatch/%{kernel_ver_arch}
c7b84e
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
c7b84e
%define patchmod	%{patchmodname}.ko
c7b84e
c7b84e
%define _missing_build_ids_terminate_build 1
c7b84e
%define _find_debuginfo_opts -r
c7b84e
%undefine _include_minidebuginfo
c7b84e
%undefine _find_debuginfo_dwz_opts
c7b84e
c7b84e
%description
c7b84e
This is a kernel live patch module which can be loaded by the kpatch
c7b84e
command line utility to modify the code of a running kernel.  This patch
c7b84e
module is targeted for kernel-%{kernel_ver}.
c7b84e
c7b84e
%prep
c7b84e
%autosetup -n kpatch-%{kpatch_ver} -p1
c7b84e
c7b84e
%build
c7b84e
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
c7b84e
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
c7b84e
c7b84e
# kpatch-build
c7b84e
make -C kpatch-build
c7b84e
c7b84e
# patch module
c7b84e
for i in %{sources}; do
c7b84e
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
c7b84e
done
c7b84e
export CACHEDIR="%{builddir}/.kpatch"
c7b84e
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
c7b84e
c7b84e
c7b84e
%install
c7b84e
installdir=%{buildroot}/%{kmoddir}
c7b84e
install -d $installdir
c7b84e
install -m 755 %{builddir}/%{patchmod} $installdir
c7b84e
c7b84e
c7b84e
%files
c7b84e
%{_usr}/lib/kpatch
c7b84e
c7b84e
c7b84e
%post
c7b84e
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
c7b84e
	cver="%{rpm_ver}_%{rpm_rel}"
c7b84e
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
c7b84e
c7b84e
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
c7b84e
c7b84e
	if [ "${lver}" != "${cver}" ]; then
c7b84e
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
c7b84e
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
c7b84e
	else
c7b84e
		%{kpatch} load %{kmoddir}/%{patchmod}
c7b84e
	fi
c7b84e
fi
c7b84e
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
c7b84e
sync
c7b84e
exit 0
c7b84e
c7b84e
c7b84e
%postun
c7b84e
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
c7b84e
sync
c7b84e
exit 0
c7b84e
c7b84e
%else
c7b84e
%description
c7b84e
This is an empty kpatch-patch package which does not contain any real patches.
c7b84e
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
c7b84e
c7b84e
%files
c7b84e
%doc
c7b84e
%endif
c7b84e
c7b84e
%changelog
20fa05
* Thu May 12 2022 Joe Lawrence <joe.lawrence@redhat.com> [1-2.el7]
20fa05
- kernel: cgroups v1 release_agent feature may allow privilege escalation [2052183] {CVE-2022-0492}
20fa05
74201f
* Thu Mar 24 2022 Joe Lawrence <joe.lawrence@redhat.com> [1-1.el7]
74201f
- kernel: fget: check that the fd still exists after getting a ref to it [2032491] {CVE-2021-4083}
74201f
- kernel: use-after-free in RDMA listen() [2033360] {CVE-2021-4028}
74201f
c7b84e
* Wed Feb 16 2022 Joe Lawrence <joe.lawrence@redhat.com> [0-0.el7]
c7b84e
- An empty patch to subscribe to kpatch stream for kernel-3.10.0-1160.59.1.el7 [2055325]