Blame SPECS/kpatch-patch.spec

7f7cfe
# Set to 1 if building an empty subscription-only package.
65e7f7
%define empty_package		0
7f7cfe
7f7cfe
#######################################################
7f7cfe
# Only need to update these variables and the changelog
7f7cfe
%define kernel_ver	3.10.0-1160.108.1.el7
7f7cfe
%define kpatch_ver	0.9.2
65e7f7
%define rpm_ver		1
65e7f7
%define rpm_rel		1
7f7cfe
7f7cfe
%if !%{empty_package}
7f7cfe
# Patch sources below. DO NOT REMOVE THIS LINE.
65e7f7
#
65e7f7
# https://issues.redhat.com/browse/RHEL-8831
65e7f7
Source100: CVE-2022-42896.patch
65e7f7
#
65e7f7
# https://issues.redhat.com/browse/RHEL-15213
65e7f7
Source101: CVE-2023-45871.patch
65e7f7
#
65e7f7
# https://issues.redhat.com/browse/RHEL-14416
65e7f7
Source102: CVE-2023-4921.patch
7f7cfe
# End of patch sources. DO NOT REMOVE THIS LINE.
7f7cfe
%endif
7f7cfe
7f7cfe
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
7f7cfe
%define sanitized_kernel_ver	%{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), ".el7", ""), "%.", "_")))}
7f7cfe
%define kernel_ver_arch	%{kernel_ver}.%{_arch}
7f7cfe
7f7cfe
Name:		kpatch-patch-%{sanitized_kernel_ver}
7f7cfe
Version:	%{rpm_ver}
7f7cfe
Release:	%{rpm_rel}.el7
7f7cfe
7f7cfe
%if %{empty_package}
7f7cfe
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
7f7cfe
%else
7f7cfe
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
7f7cfe
%endif
7f7cfe
7f7cfe
Group:		System Environment/Kernel
7f7cfe
License:	GPLv2
7f7cfe
ExclusiveArch:	x86_64 ppc64le
7f7cfe
7f7cfe
Conflicts:	%{name} < %{version}-%{release}
7f7cfe
7f7cfe
Provides:	kpatch-patch = %{kernel_ver_arch}
7f7cfe
Provides:	kpatch-patch = %{kernel_ver}
7f7cfe
7f7cfe
%if !%{empty_package}
7f7cfe
Requires:	systemd
7f7cfe
%endif
7f7cfe
Requires:	kpatch >= 0.4.0-3
7f7cfe
Requires:	kernel-uname-r = %{kernel_ver_arch}
7f7cfe
7f7cfe
%if !%{empty_package}
7f7cfe
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
7f7cfe
BuildRequires:	kernel-devel = %{kernel_ver}
7f7cfe
BuildRequires:	kernel-debuginfo = %{kernel_ver}
7f7cfe
7f7cfe
%ifarch x86_64
7f7cfe
BuildRequires: pesign
7f7cfe
%endif
7f7cfe
7f7cfe
%ifarch ppc64le
7f7cfe
BuildRequires: gcc-plugin-devel
7f7cfe
%endif
7f7cfe
7f7cfe
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
7f7cfe
7f7cfe
Source10:	kernel-%{kernel_ver}.src.rpm
7f7cfe
7f7cfe
# kpatch-build patches
7f7cfe
# Patch1: backport.patch
7f7cfe
Patch1: v0.9.2-backport-MR-1281-create-diff-object-add-suppo.patch
7f7cfe
Patch2: v0.9.2-backport-MR-1200-Make-sure-section-symbols-ex.patch
7f7cfe
7f7cfe
%global _dupsign_opts --keyname=rhelkpatch1
7f7cfe
7f7cfe
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
7f7cfe
%define kpatch		%{_sbindir}/kpatch
7f7cfe
%define kmoddir		%{_usr}/lib/kpatch/%{kernel_ver_arch}
7f7cfe
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
7f7cfe
%define patchmod	%{patchmodname}.ko
7f7cfe
7f7cfe
%define _missing_build_ids_terminate_build 1
7f7cfe
%define _find_debuginfo_opts -r
7f7cfe
%undefine _include_minidebuginfo
7f7cfe
%undefine _find_debuginfo_dwz_opts
7f7cfe
7f7cfe
%description
7f7cfe
This is a kernel live patch module which can be loaded by the kpatch
7f7cfe
command line utility to modify the code of a running kernel.  This patch
7f7cfe
module is targeted for kernel-%{kernel_ver}.
7f7cfe
7f7cfe
%prep
7f7cfe
%autosetup -n kpatch-%{kpatch_ver} -p1
7f7cfe
7f7cfe
%build
7f7cfe
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
7f7cfe
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
7f7cfe
7f7cfe
# kpatch-build
7f7cfe
make -C kpatch-build
7f7cfe
7f7cfe
# patch module
7f7cfe
for i in %{sources}; do
7f7cfe
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
7f7cfe
done
7f7cfe
export CACHEDIR="%{builddir}/.kpatch"
7f7cfe
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
7f7cfe
7f7cfe
7f7cfe
%install
7f7cfe
installdir=%{buildroot}/%{kmoddir}
7f7cfe
install -d $installdir
7f7cfe
install -m 755 %{builddir}/%{patchmod} $installdir
7f7cfe
7f7cfe
7f7cfe
%files
7f7cfe
%{_usr}/lib/kpatch
7f7cfe
7f7cfe
7f7cfe
%post
7f7cfe
if [[ %{kernel_ver_arch} = $(uname -r) ]]; then
7f7cfe
	cver="%{rpm_ver}_%{rpm_rel}"
7f7cfe
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
7f7cfe
7f7cfe
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
7f7cfe
7f7cfe
	if [ "${lver}" != "${cver}" ]; then
7f7cfe
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
7f7cfe
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
7f7cfe
	else
7f7cfe
		%{kpatch} load %{kmoddir}/%{patchmod}
7f7cfe
	fi
7f7cfe
fi
7f7cfe
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
7f7cfe
sync
7f7cfe
exit 0
7f7cfe
7f7cfe
7f7cfe
%postun
7f7cfe
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
7f7cfe
sync
7f7cfe
exit 0
7f7cfe
7f7cfe
%else
7f7cfe
%description
7f7cfe
This is an empty kpatch-patch package which does not contain any real patches.
7f7cfe
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
7f7cfe
7f7cfe
%files
7f7cfe
%doc
7f7cfe
%endif
7f7cfe
7f7cfe
%changelog
65e7f7
* Wed Mar 06 2024 Yannick Cote <ycote@redhat.com> [1-1.el7]
65e7f7
- kernel: use-after-free in sch_qfq network scheduler [RHEL-14416] {CVE-2023-4921}
65e7f7
- kernel: IGB driver inadequate buffer size for frames larger than MTU [RHEL-15213] {CVE-2023-45871}
65e7f7
- kernel: use-after-free in l2cap_connect and l2cap_le_connect_req in net/bluetooth/l2cap_core.c [RHEL-8831] {CVE-2022-42896}
65e7f7
7f7cfe
* Fri Jan 05 2024 Yannick Cote <ycote@redhat.com> [0-0.el7]
7f7cfe
- An empty patch to subscribe to kpatch stream for kernel-3.10.0-1160.108.1.el7 [RHEL-20898]