Blame SPECS/kpatch-patch.spec

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