mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
3aa5c38714
Add 95ibm-sel-ebc dracut module for secure boot-time customization of SEL guests. Introduce the IBM SEL EBC dracut module (95ibm-sel-ebc) that enables Early Boot Customization for SEL guests during the initramfs phase. The module implements a critical security architecture to prevent injection attacks: all EBC resources (.asr and .pol files) are copied from /boot/sics (which resides in the qcow2 image on the host filesystem) to /run/ibm-sel-ebc (a tmpfs/RAM-backed directory). Since guest RAM is protected by the Ultravisor, this prevents malicious hosts from modifying EBC resources during boot. Systemd units and their purposes: - ibm-sel-ebc.target: Groups all EBC-related units - boot.mount: Mounts /dev/disk/by-label/boot to /boot - ibm-sel-ebc-ensure-sics.service: Fallback to create /boot/sics/ if boot partition mount fails (supports Kata VM scenarios) - ibm-sel-ebc-pvebc.service: Main unit that copies EBC resources to RAM, invokes pvebc tool to verify integrity and add ASRs to UV, retrieves LUKS passphrase from UV secret store - ibm-sel-ebc-override-crypttab.service: Replaces /etc/crypttab with prepared IBM SEL EBC crypttab, reloads systemd daemon, starts cryptsetup service - ibm-sel-ebc-paes-enforce.service: Verifies root filesystem uses PAES encryption to prevent root filesystem substitution attacks All units write logs to /boot/sics/log for debugging, accessible even if root filesystem fails to mount. Units are triggered by rd.ibm-sel-ebc kernel parameter and only execute in initramfs (ConditionPathExists=/etc/initrd-release). Assisted-by: IBM Bob:1.0.1 Reviewed-by: Holger Dengler <dengler@linux.ibm.com> Signed-off-by: Finn Callies <fcallies@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
64 lines
1.4 KiB
Bash
64 lines
1.4 KiB
Bash
#!/bin/bash
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# Copyright IBM Corp.
|
|
|
|
SYSFS=/sys/firmware/uv/prot_virt_guest
|
|
SICS=/boot/sics
|
|
EBC_TMPFS=/run/sel-ebc
|
|
TOC=toc.asr
|
|
ASR_NAME=luks-rfs-passphrase
|
|
|
|
# Early exit for non SEL guests
|
|
if [[ ! -e $SYSFS ]]; then
|
|
echo "Not running in a SEL guest."
|
|
exit 1
|
|
fi
|
|
if [[ $(cat $SYSFS) -ne 1 ]]; then
|
|
echo "Not running in a SEL guest."
|
|
exit 1
|
|
fi
|
|
echo "Running in SEL guest."
|
|
|
|
# Copy EBC resources from /boot/sics to tmpfs for security
|
|
# This protects against host injection attacks by moving resources to UV-protected RAM
|
|
echo "Copying EBC resources from $SICS to $EBC_TMPFS"
|
|
if ! mkdir -p "$EBC_TMPFS"; then
|
|
echo "Failed to create $EBC_TMPFS"
|
|
exit 1
|
|
fi
|
|
|
|
# Copy only .asr and .pol files
|
|
for file in "$SICS"/*.asr "$SICS"/*.pol; do
|
|
if [[ -f "$file" && ! -L "$file" ]]; then
|
|
cp "$file" "$EBC_TMPFS/" || {
|
|
echo "Failed to copy $file to $EBC_TMPFS"
|
|
exit 1
|
|
}
|
|
fi
|
|
done
|
|
|
|
# Verify toc.asr was copied
|
|
if [[ ! -f "$EBC_TMPFS/$TOC" ]]; then
|
|
echo "Error: $EBC_TMPFS/$TOC does not exist after copy"
|
|
exit 1
|
|
fi
|
|
|
|
# execute the actual tool with the copied toc.asr
|
|
pvebc --toc "$EBC_TMPFS/$TOC"
|
|
rc=$?
|
|
if [[ $rc -ne 0 ]]; then
|
|
exit $rc
|
|
fi
|
|
|
|
# Retrieve and check for dummy LUKS passphrase
|
|
pvsecret retrieve --inform name -o "$EBC_TMPFS/$ASR_NAME" --outform bin "$ASR_NAME"
|
|
|
|
if [[ ! -f "$EBC_TMPFS/$ASR_NAME" ]]; then
|
|
echo "$EBC_TMPFS/$ASR_NAME does not exist"
|
|
fi
|
|
|
|
chmod 400 "$EBC_TMPFS/$ASR_NAME"
|
|
|
|
exit 0
|