Skip to content

Commit f67b66c

Browse files
committed
Merge: redhat: Fix SBAT data in kernel-uki-virt
MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-10/-/merge_requests/279 JIRA: https://issues.redhat.com/browse/RHEL-109610 dracut v107 switched to using 'ukify' for building UKIs. The impementation is, unfortunately, buggy and not 100% backwards compatible, the result is that kernel-uki-virt does not contain the correct SBAT. Fix things by switching to calling ukify explicitly. While on it, add explicit '--no-hostonly' to the dracut command line as hostonly="no" in the config file is not always enough. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Approved-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Approved-by: Jan Stancek <jstancek@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Julio Faracco <jfaracco@redhat.com>
2 parents 50199cf + fb08452 commit f67b66c

File tree

4 files changed

+34
-21
lines changed

4 files changed

+34
-21
lines changed

redhat/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ sources-rh: $(TARBALL) $(KABI_TARBALL) $(KABIDW_TARBALL) generate-testpatch-tmp
761761
README.rst \
762762
kernel-local \
763763
dracut-virt.conf \
764+
uki.sbat.template \
765+
uki-addons.sbat.template \
764766
$(SOURCES)/
765767
@changelog_glob="$(SPECPACKAGE_NAME).changelog-*"; \
766768
[[ -n "$(AUTOMOTIVE_BUILD)" ]] && changelog_glob="kernel.changelog-*"; \

redhat/kernel.spec.template

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ Summary: The Linux kernel
108108
%global signkernel 0
109109
%endif
110110

111+
# RHEL/CentOS/Fedora specific .SBAT entries
112+
%if 0%{?centos}
113+
%global sbat_suffix centos
114+
%else
115+
%if 0%{?fedora}
116+
%global sbat_suffix fedora
117+
%else
118+
%global sbat_suffix rhel
119+
%endif
120+
%endif
121+
111122
# Sign modules on all arches
112123
%global signmodules 1
113124

@@ -989,6 +1000,9 @@ Source77: partial-clang_lto-aarch64-debug-snip.config
9891000
Source80: generate_all_configs.sh
9901001
Source81: process_configs.sh
9911002

1003+
Source83: uki.sbat.template
1004+
Source84: uki-addons.sbat.template
1005+
9921006
Source86: dracut-virt.conf
9931007

9941008
Source87: flavors
@@ -1977,6 +1991,10 @@ rm -f localversion-next localversion-rt
19771991
Documentation \
19781992
scripts/clang-tools 2> /dev/null
19791993

1994+
# SBAT data
1995+
sed -e s,@KVER,%{KVERREL}, -e s,@SBAT_SUFFIX,%{sbat_suffix}, %{SOURCE83} > uki.sbat
1996+
sed -e s,@KVER,%{KVERREL}, -e s,@SBAT_SUFFIX,%{sbat_suffix}, %{SOURCE84} > uki-addons.sbat
1997+
19801998
# only deal with configs if we are going to build for the arch
19811999
%ifnarch %nobuildarches
19822000

@@ -2736,41 +2754,30 @@ BuildKernel() {
27362754
SBATsuffix="rhel"
27372755
%endif
27382756
%endif
2739-
SBAT=$(cat <<- EOF
2740-
linux,1,Red Hat,linux,$KernelVer,mailto:secalert@redhat.com
2741-
linux.$SBATsuffix,1,Red Hat,linux,$KernelVer,mailto:secalert@redhat.com
2742-
kernel-uki-virt.$SBATsuffix,1,Red Hat,kernel-uki-virt,$KernelVer,mailto:secalert@redhat.com
2743-
EOF
2744-
)
2745-
2746-
ADDONS_SBAT=$(cat <<- EOF
2747-
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
2748-
kernel-uki-virt-addons.$SBATsuffix,1,Red Hat,kernel-uki-virt-addons,$KernelVer,mailto:secalert@redhat.com
2749-
EOF
2750-
)
2751-
27522757
KernelUnifiedImageDir="$RPM_BUILD_ROOT/lib/modules/$KernelVer"
27532758
KernelUnifiedImage="$KernelUnifiedImageDir/$InstallName-virt.efi"
2759+
KernelUnifiedInitrd="$KernelUnifiedImageDir/$InstallName-virt.img"
27542760

27552761
mkdir -p $KernelUnifiedImageDir
27562762

27572763
dracut --conf=%{SOURCE86} \
27582764
--confdir=$(mktemp -d) \
2765+
--no-hostonly \
27592766
--verbose \
27602767
--kver "$KernelVer" \
27612768
--kmoddir "$RPM_BUILD_ROOT/lib/modules/$KernelVer/" \
27622769
--logfile=$(mktemp) \
2763-
--uefi \
2764-
%if 0%{?rhel} && !0%{?eln}
2765-
--sbat "$SBAT" \
2766-
%endif
2767-
--kernel-image $(realpath $KernelImage) \
2768-
--kernel-cmdline 'console=tty0 console=ttyS0' \
2769-
$KernelUnifiedImage
2770+
$KernelUnifiedInitrd
2771+
2772+
ukify build --linux $(realpath $KernelImage) --initrd $KernelUnifiedInitrd \
2773+
--sbat @uki.sbat --os-release @/etc/os-release --uname $KernelVer \
2774+
--cmdline 'console=tty0 console=ttyS0' --output $KernelUnifiedImage
2775+
2776+
rm -f $KernelUnifiedInitrd
27702777

27712778
KernelAddonsDirOut="$KernelUnifiedImage.extra.d"
27722779
mkdir -p $KernelAddonsDirOut
2773-
python3 %{SOURCE151} %{SOURCE152} $KernelAddonsDirOut virt %{primary_target} %{_target_cpu} "$ADDONS_SBAT"
2780+
python3 %{SOURCE151} %{SOURCE152} $KernelAddonsDirOut virt %{primary_target} %{_target_cpu} @uki-addons.sbat
27742781

27752782
%if %{signkernel}
27762783
%{log_msg "Sign the EFI UKI kernel"}

redhat/uki-addons.sbat.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
2+
kernel-uki-virt-addons.@SBAT_SUFFIX,1,Red Hat,kernel-uki-virt-addons,@KVER,mailto:secalert@redhat.com

redhat/uki.sbat.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
2+
kernel-uki-virt.@SBAT_SUFFIX,1,Red Hat,kernel-uki-virt,@KVER,mailto:secalert@redhat.com

0 commit comments

Comments
 (0)