summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorMatthew Kobayashi <matthew@kobayashi.au>2026-10-22 10:16:46 +1000
committerMatthew Kobayashi <matthew@kobayashi.au>2026-10-26 10:36:35 +1000
commitdb65cb49b2163874314e49fc9bf4d1d19faccd70 (patch)
tree4e5389b4b46e44f24f801b917ac529dde5e4bb25 /data
parent4d866b0ac68c73f89a2cf495f05a053b1b53517d (diff)
downloadvyos-build-db65cb49b2163874314e49fc9bf4d1d19faccd70.tar.gz
vyos-build-db65cb49b2163874314e49fc9bf4d1d19faccd70.zip
secure-boot: T861: decompress kernel for ARM64 signing
Detect gzip-wrapped kernels and stage decompressed input for both development-key and HSM signing. Install the signed, uncompressed image only after sbverify succeeds. Keep decompression, signing, and verification failures fatal, preserve the original kernel and clean temporary input. Leave already-uncompressed kernels on the existing signing path.
Diffstat (limited to 'data')
-rwxr-xr-xdata/live-build-config/hooks/live/93-sb-sign-kernel.chroot30
1 files changed, 28 insertions, 2 deletions
diff --git a/data/live-build-config/hooks/live/93-sb-sign-kernel.chroot b/data/live-build-config/hooks/live/93-sb-sign-kernel.chroot
index 794bf2e7..deb4bfe8 100755
--- a/data/live-build-config/hooks/live/93-sb-sign-kernel.chroot
+++ b/data/live-build-config/hooks/live/93-sb-sign-kernel.chroot
@@ -9,6 +9,22 @@ SB_OPENSSL_CONF="/etc/ssl/yubihsm-openssl.cnf"
SB_PKCS11_CONF="/etc/yubihsm_pkcs11.conf"
PKCS11_KEY_OBJECT="vyos-sb-signer-2025"
VMLINUZ=$(readlink /boot/vmlinuz)
+KERNEL_INPUT="/boot/${VMLINUZ}"
+KERNEL_UNCOMPRESSED=""
+
+trap '[ -z "${KERNEL_UNCOMPRESSED}" ] || rm -f "${KERNEL_UNCOMPRESSED}"' EXIT
+
+# sbsign needs the EFI executable, not the gzip wrapper used on ARM64.
+prepare_kernel() {
+ if [ "$(od -An -tx1 -N2 "${KERNEL_INPUT}" | tr -d ' \n')" = "1f8b" ]; then
+ echo "I: Decompressing Linux Kernel for Secure Boot"
+ KERNEL_UNCOMPRESSED=$(mktemp "/boot/${VMLINUZ}.uncompressed.XXXXXX") || return 1
+ if ! gzip -dc "${KERNEL_INPUT}" > "${KERNEL_UNCOMPRESSED}"; then
+ return 1
+ fi
+ KERNEL_INPUT="${KERNEL_UNCOMPRESSED}"
+ fi
+}
# Abort HSM signing: drop the partially signed Kernel and the HSM configuration
hsm_sign_failed() {
@@ -30,13 +46,17 @@ done
if [ -f ${SB_KERNEL_CERT} ] && [ -f ${SB_OPENSSL_CONF} ]; then
echo "I: Signing Linux Kernel for Secure Boot using the HSM"
+ if ! prepare_kernel; then
+ hsm_sign_failed "Decompression of Linux Kernel failed"
+ fi
+
export OPENSSL_CONF="${SB_OPENSSL_CONF}"
export YUBIHSM_PKCS11_CONF="${SB_PKCS11_CONF}"
sbsign --engine pkcs11 \
--key "pkcs11:object=${PKCS11_KEY_OBJECT};type=private" \
--cert ${SB_KERNEL_CERT} \
- /boot/${VMLINUZ} --output /boot/${VMLINUZ}.tmp
+ "${KERNEL_INPUT}" --output /boot/${VMLINUZ}.tmp
if [ $? -ne 0 ]; then
hsm_sign_failed "Signing of Linux Kernel failed"
fi
@@ -50,8 +70,14 @@ if [ -f ${SB_KERNEL_CERT} ] && [ -f ${SB_OPENSSL_CONF} ]; then
echo "I: Linux Kernel signed and signature verified"
elif [ -f ${KERNEL_KEY} ] && [ -f ${KERNEL_CERT} ]; then
echo "I: Signing Linux Kernel for Secure Boot"
+ if ! prepare_kernel; then
+ rm -f "/boot/${VMLINUZ}.tmp" "${KERNEL_KEY}"
+ echo "E: Decompression of Linux Kernel failed"
+ exit 1
+ fi
+
sbsign --key ${KERNEL_KEY} --cert ${KERNEL_CERT} \
- /boot/${VMLINUZ} --output /boot/${VMLINUZ}.tmp
+ "${KERNEL_INPUT}" --output /boot/${VMLINUZ}.tmp
if [ $? -ne 0 ]; then
rm -f /boot/${VMLINUZ}.tmp ${KERNEL_KEY}
echo "E: Signing of Linux Kernel failed"