Blame SPECS/kpatch-patch.spec

6a1d28
# Set to 1 if building an empty subscription-only package.
d465ec
%define empty_package		0
6a1d28
6a1d28
#######################################################
6a1d28
# Only need to update these variables and the changelog
6a1d28
%define kernel_ver	5.14.0-162.22.2.el9_1
6a1d28
%define kpatch_ver	0.9.7
d465ec
%define rpm_ver		1
d465ec
%define rpm_rel		1
6a1d28
6a1d28
%if !%{empty_package}
6a1d28
# Patch sources below. DO NOT REMOVE THIS LINE.
d465ec
#
d465ec
# https://bugzilla.redhat.com/2165362
d465ec
Source100: CVE-2023-0386.patch
6a1d28
# End of patch sources. DO NOT REMOVE THIS LINE.
6a1d28
%endif
6a1d28
6a1d28
%define sanitized_rpm_rel	%{lua: print((string.gsub(rpm.expand("%rpm_rel"), "%.", "_")))}
6a1d28
%define sanitized_kernel_ver   %{lua: print((string.gsub(string.gsub(rpm.expand("%kernel_ver"), '.el9_?\%d?', ""), "%.", "_")))}
6a1d28
%define kernel_ver_arch        %{kernel_ver}.%{_arch}
6a1d28
6a1d28
Name:		kpatch-patch-%{sanitized_kernel_ver}
6a1d28
Version:	%{rpm_ver}
6a1d28
Release:	%{rpm_rel}%{?dist}
6a1d28
6a1d28
%if %{empty_package}
6a1d28
Summary:	Initial empty kpatch-patch for kernel-%{kernel_ver_arch}
6a1d28
%else
6a1d28
Summary:	Live kernel patching module for kernel-%{kernel_ver_arch}
6a1d28
%endif
6a1d28
6a1d28
Group:		System Environment/Kernel
6a1d28
License:	GPLv2
6a1d28
ExclusiveArch:	x86_64 ppc64le
6a1d28
6a1d28
Conflicts:	%{name} < %{version}-%{release}
6a1d28
6a1d28
Provides:	kpatch-patch = %{kernel_ver_arch}
6a1d28
Provides:	kpatch-patch = %{kernel_ver}
6a1d28
6a1d28
%if !%{empty_package}
6a1d28
Requires:	systemd
6a1d28
%endif
6a1d28
Requires:	kpatch >= 0.6.1-1
6a1d28
Requires:	kernel-uname-r = %{kernel_ver_arch}
6a1d28
6a1d28
%if !%{empty_package}
6a1d28
BuildRequires:	patchutils
6a1d28
BuildRequires:	kernel-devel = %{kernel_ver}
6a1d28
BuildRequires:	kernel-debuginfo = %{kernel_ver}
6a1d28
6a1d28
# kernel build requirements, generated from:
6a1d28
#   % rpmspec -q --buildrequires kernel.spec | sort | awk '{print "BuildRequires:\t" $0}'
6a1d28
# with arch-specific packages moved into conditional block
6a1d28
BuildRequires:	bash
6a1d28
BuildRequires:	bc
6a1d28
BuildRequires:	binutils
6a1d28
BuildRequires:	bison
6a1d28
BuildRequires:	bpftool
6a1d28
BuildRequires:	bzip2
6a1d28
BuildRequires:	coreutils
6a1d28
BuildRequires:	diffutils
6a1d28
BuildRequires:	dwarves
6a1d28
BuildRequires:	elfutils
6a1d28
BuildRequires:	elfutils-devel
6a1d28
BuildRequires:	findutils
6a1d28
BuildRequires:	flex
6a1d28
BuildRequires:	gawk
6a1d28
BuildRequires:	gcc
6a1d28
BuildRequires:	gcc-c++
6a1d28
BuildRequires:	gcc-plugin-devel
6a1d28
BuildRequires:	git-core
6a1d28
BuildRequires:	glibc-static
6a1d28
BuildRequires:	gzip
6a1d28
BuildRequires:	hmaccalc
6a1d28
BuildRequires:	hostname
6a1d28
BuildRequires:	kernel-rpm-macros >= 185-9
6a1d28
BuildRequires:	kmod
6a1d28
BuildRequires:	m4
6a1d28
BuildRequires:	make
6a1d28
BuildRequires:	net-tools
6a1d28
BuildRequires:	nss-tools
6a1d28
BuildRequires:	openssl
6a1d28
BuildRequires:	openssl-devel
6a1d28
BuildRequires:	patch
6a1d28
BuildRequires:	perl-Carp
6a1d28
BuildRequires:	perl-devel
6a1d28
BuildRequires:	perl-generators
6a1d28
BuildRequires:	perl-interpreter
6a1d28
BuildRequires:	python3-devel
6a1d28
BuildRequires:	redhat-rpm-config
6a1d28
BuildRequires:	rpm-build
6a1d28
BuildRequires:	system-sb-certs
6a1d28
BuildRequires:	tar
6a1d28
BuildRequires:	which
6a1d28
BuildRequires:	xz
6a1d28
6a1d28
%ifarch x86_64
6a1d28
BuildRequires:	pesign >= 0.10-4
6a1d28
%endif
6a1d28
6a1d28
Source0:	https://github.com/dynup/kpatch/archive/v%{kpatch_ver}.tar.gz
6a1d28
6a1d28
Source10:	kernel-%{kernel_ver}.src.rpm
6a1d28
6a1d28
# kpatch-build patches
6a1d28
Patch1: v0.9.7-backport-MR-1314-create-diff-object-fix-__UNI.patch
6a1d28
Patch2: v0.9.7-backport-MR-1315-Static-call-fixes.patch
6a1d28
6a1d28
%global _dupsign_opts --keyname=rhelkpatch1
6a1d28
6a1d28
%define builddir	%{_builddir}/kpatch-%{kpatch_ver}
6a1d28
%define kpatch		%{_sbindir}/kpatch
6a1d28
%define kmoddir 	%{_usr}/lib/kpatch/%{kernel_ver_arch}
6a1d28
%define kinstdir	%{_sharedstatedir}/kpatch/%{kernel_ver_arch}
6a1d28
%define patchmodname	kpatch-%{sanitized_kernel_ver}-%{version}-%{sanitized_rpm_rel}
6a1d28
%define patchmod	%{patchmodname}.ko
6a1d28
6a1d28
%define _missing_build_ids_terminate_build 1
6a1d28
%define _find_debuginfo_opts -r
6a1d28
%undefine _include_minidebuginfo
6a1d28
%undefine _find_debuginfo_dwz_opts
6a1d28
6a1d28
%description
6a1d28
This is a kernel live patch module which can be loaded by the kpatch
6a1d28
command line utility to modify the code of a running kernel.  This patch
6a1d28
module is targeted for kernel-%{kernel_ver}.
6a1d28
6a1d28
%prep
6a1d28
%autosetup -n kpatch-%{kpatch_ver} -p1
6a1d28
6a1d28
%build
6a1d28
kdevdir=/usr/src/kernels/%{kernel_ver_arch}
6a1d28
vmlinux=/usr/lib/debug/lib/modules/%{kernel_ver_arch}/vmlinux
6a1d28
6a1d28
# kpatch-build
6a1d28
make -C kpatch-build
6a1d28
6a1d28
# patch module
6a1d28
for i in %{sources}; do
6a1d28
	[[ $i == *.patch ]] && patch_sources="$patch_sources $i"
6a1d28
done
6a1d28
export CACHEDIR="%{builddir}/.kpatch"
6a1d28
kpatch-build/kpatch-build -n %{patchmodname} -r %{SOURCE10} -v $vmlinux --skip-cleanup $patch_sources || { cat "${CACHEDIR}/build.log"; exit 1; }
6a1d28
6a1d28
6a1d28
%install
6a1d28
installdir=%{buildroot}/%{kmoddir}
6a1d28
install -d $installdir
6a1d28
install -m 755 %{builddir}/%{patchmod} $installdir
6a1d28
6a1d28
6a1d28
%files
6a1d28
%{_usr}/lib/kpatch
6a1d28
6a1d28
6a1d28
%post
6a1d28
%{kpatch} install -k %{kernel_ver_arch} %{kmoddir}/%{patchmod}
6a1d28
chcon -t modules_object_t %{kinstdir}/%{patchmod}
6a1d28
sync
6a1d28
if [[ %{kernel_ver_arch} = $(uname -r) && "${LEAPP_IPU_IN_PROGRESS}" != "8to9" ]]; then
6a1d28
	cver="%{rpm_ver}_%{rpm_rel}"
6a1d28
	pname=$(echo "kpatch_%{sanitized_kernel_ver}" | sed 's/-/_/')
6a1d28
6a1d28
	lver=$({ %{kpatch} list | sed -nr "s/^${pname}_([0-9_]+)\ \[enabled\]$/\1/p"; echo "${cver}"; } | sort -V | tail -1)
6a1d28
6a1d28
	if [ "${lver}" != "${cver}" ]; then
6a1d28
		echo "WARNING: at least one loaded kpatch-patch (${pname}_${lver}) has a newer version than the one being installed."
6a1d28
		echo "WARNING: You will have to reboot to load a downgraded kpatch-patch"
6a1d28
	else
6a1d28
		%{kpatch} load %{patchmod}
6a1d28
	fi
6a1d28
fi
6a1d28
exit 0
6a1d28
6a1d28
6a1d28
%postun
6a1d28
%{kpatch} uninstall -k %{kernel_ver_arch} %{patchmod}
6a1d28
sync
6a1d28
exit 0
6a1d28
6a1d28
%else
6a1d28
%description
6a1d28
This is an empty kpatch-patch package which does not contain any real patches.
6a1d28
It is only a method to subscribe to the kpatch stream for kernel-%{kernel_ver}.
6a1d28
6a1d28
%files
6a1d28
%doc
6a1d28
%endif
6a1d28
6a1d28
%changelog
d465ec
* Mon Mar 27 2023 Yannick Cote <ycote@redhat.com> [1-1.el9_1]
d465ec
- kernel: FUSE filesystem low-privileged user privileges escalation [2165362] {CVE-2023-0386}
d465ec
6a1d28
* Thu Mar 16 2023 Linqing Lu <lilu@redhat.com> [0-0.el9]
6a1d28
- An empty patch to subscribe to kpatch stream for kernel-5.14.0-162.22.2.el9_1 [2179189]