Skip to content

Commit 12bf7dc

Browse files
Johan-Liebert1cgwalters
authored andcommitted
composefs/tests: More flexibility for insecure UKI testing
Update the CI matrix to include `seal_state` and `boot_type`. This does not increase our matrix, but only rearranges it to be a bit more meaningful. Earlier even when testing "insecure UKI", it still showed up as "composefs-sealeduki-sdboot" which is incorrect. This also allows us flexibility to, in future, test grub + UKI which is disabled currently. Update Justfile and the Dockerfile to make use of these new arguments. Now we only sign the UKI, if `seal_state == sealed`, and in the Justfile we disallow combinations that don't make sense, like BLS boot + sealed, allowing missing verity (xfs) + sealed, etc. Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 8c4bdc8 commit 12bf7dc

4 files changed

Lines changed: 94 additions & 76 deletions

File tree

.github/workflows/ci.yml

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,36 @@ jobs:
161161
matrix:
162162
# No fedora-44 due to https://bugzilla.redhat.com/show_bug.cgi?id=2429501
163163
test_os: [fedora-43, centos-9, centos-10]
164-
variant: [ostree, composefs-sealeduki-sdboot, composefs-sdboot, composefs-grub]
164+
variant: [ostree, composefs]
165165
filesystem: ["ext4", "xfs"]
166+
bootloader: ["grub", "systemd"]
167+
boot_type: ["bls", "uki"]
168+
seal_state: ["sealed", "unsealed"]
169+
166170
exclude:
167-
# centos-9 UKI is experimental/broken (https://github.com/bootc-dev/bootc/issues/1812)
168-
- test_os: centos-9
169-
variant: composefs-sealeduki-sdboot
170171
# centos-9 fails with EUCLEAN (https://github.com/bootc-dev/bootc/issues/1812)
171172
# See: https://github.com/bootc-dev/bcvk/pull/204
172173
- test_os: centos-9
173-
variant: composefs-sdboot
174-
- test_os: centos-9
175-
variant: composefs-grub
174+
variant: composefs
175+
- seal_state: "sealed"
176+
boot_type: bls
177+
- seal_state: "sealed"
178+
bootloader: grub
179+
- seal_state: "sealed"
180+
filesystem: xfs
181+
- seal_state: "unsealed"
182+
filesystem: ext4
183+
- bootloader: grub
184+
boot_type: "uki"
185+
176186
# We only test filesystems for composefs to test if composefs backend will work on fs
177187
# without fsverity
178188
- variant: ostree
179189
filesystem: ext4
190+
- variant: ostree
191+
boot_type: uki
192+
- variant: ostree
193+
bootloader: systemd
180194

181195
runs-on: ubuntu-24.04
182196

@@ -194,35 +208,13 @@ jobs:
194208
BASE=$(just pullspec-for-os base ${{ matrix.test_os }})
195209
echo "BOOTC_base=${BASE}" >> $GITHUB_ENV
196210
echo "RUST_BACKTRACE=full" >> $GITHUB_ENV
197-
echo "RUST_LOG=trace" >> $GITHUB_ENV
198-
echo "BOOTC_filesystem=${{ matrix.filesystem }}" >> $GITHUB_ENV
211+
echo "RUST_LOG=debug" >> $GITHUB_ENV
199212
200-
case "${{ matrix.variant }}" in
201-
composefs-grub)
202-
echo "BOOTC_variant=composefs" >> $GITHUB_ENV
203-
echo "BOOTC_bootloader=grub" >> $GITHUB_ENV
204-
;;
205-
206-
composefs-sdboot)
207-
echo "BOOTC_variant=composefs" >> $GITHUB_ENV
208-
echo "BOOTC_bootloader=systemd" >> $GITHUB_ENV
209-
;;
210-
211-
composefs-sealeduki-sdboot)
212-
echo "BOOTC_variant=${{ matrix.variant }}" >> $GITHUB_ENV
213-
echo "BOOTC_bootloader=systemd" >> $GITHUB_ENV
214-
;;
215-
216-
ostree)
217-
echo "BOOTC_variant=${{ matrix.variant }}" >> $GITHUB_ENV
218-
echo "BOOTC_bootloader=grub" >> $GITHUB_ENV
219-
;;
220-
esac
221-
222-
if [ "${{ matrix.variant }}" = "composefs-sealeduki-sdboot" ]; then
223-
BUILDROOTBASE=$(just pullspec-for-os buildroot-base ${{ matrix.test_os }})
224-
echo "BOOTC_buildroot_base=${BUILDROOTBASE}" >> $GITHUB_ENV
225-
fi
213+
echo "BOOTC_variant=${{ matrix.variant }}" >> $GITHUB_ENV
214+
echo "BOOTC_filesystem=${{ matrix.filesystem }}" >> $GITHUB_ENV
215+
echo "BOOTC_bootloader=${{ matrix.bootloader }}" >> $GITHUB_ENV
216+
echo "BOOTC_boot_type=${{ matrix.boot_type }}" >> $GITHUB_ENV
217+
echo "BOOTC_seal_state=${{ matrix.seal_state }}" >> $GITHUB_ENV
226218
227219
- name: Download package artifacts
228220
uses: actions/download-artifact@v8
@@ -241,14 +233,14 @@ jobs:
241233
- name: Unit and container integration tests
242234
run: just test-container
243235

244-
- name: Validate composefs digest (sealed UKI only)
245-
if: matrix.variant == 'composefs-sealeduki-sdboot'
236+
- name: Validate composefs digest (UKI only)
237+
if: matrix.boot_type == 'uki'
246238
run: just validate-composefs-digest
247239

248240
- name: Run TMT integration tests
249241
run: |
250-
if [[ "${{ matrix.variant }}" = composefs* ]]; then
251-
just "test-${{ matrix.variant }}" "${{ matrix.filesystem }}"
242+
if [[ "${{ matrix.variant }}" = composefs ]]; then
243+
just test-composefs "${{ matrix.bootloader }}" "${{ matrix.filesystem }}" "${{ matrix.boot_type }}" "${{ matrix.seal_state }}"
252244
else
253245
just test-tmt integration
254246
fi
@@ -259,7 +251,14 @@ jobs:
259251
if: always()
260252
uses: actions/upload-artifact@v7
261253
with:
262-
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ matrix.variant }}-${{ matrix.filesystem }}-${{ env.ARCH }}
254+
name: "tmt-log-PR-${{ github.event.number }}-\
255+
${{ matrix.test_os }}-\
256+
${{ matrix.variant }}-\
257+
${{ matrix.bootloader }}-\
258+
${{ matrix.boot_type }}-\
259+
${{ matrix.filesystem }}-\
260+
${{ matrix.seal_state }}-\
261+
${{ env.ARCH }}"
263262
path: /var/tmp/tmt
264263

265264
# Test bootc install on Fedora CoreOS (separate job to avoid disk space issues

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp
177177
FROM tools as sealed-uki
178178
ARG variant
179179
ARG filesystem
180+
ARG seal_state
181+
ARG boot_type
180182
# Install our bootc package (only needed for the compute-composefs-digest command)
181183
RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
182184
--mount=type=bind,from=packages,src=/,target=/run/packages \
@@ -194,20 +196,21 @@ if [[ $filesystem == "xfs" ]]; then
194196
allow_missing_verity=true
195197
fi
196198

197-
if test "${variant}" = "composefs-sealeduki-sdboot"; then
198-
/run/packaging/seal-uki /run/target /out /run/secrets $allow_missing_verity
199+
if test "${boot_type}" = "uki"; then
200+
/run/packaging/seal-uki /run/target /out /run/secrets $allow_missing_verity $seal_state
199201
fi
200202
EORUN
201203

202204
# And now the final image
203205
FROM base-penultimate
204206
ARG variant
207+
ARG boot_type
205208
# Copy the sealed UKI and finalize the image (remove raw kernel, create symlinks)
206209
RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
207210
--mount=type=bind,from=packaging,src=/,target=/run/packaging \
208211
--mount=type=bind,from=sealed-uki,src=/,target=/run/sealed-uki <<EORUN
209212
set -xeuo pipefail
210-
if test "${variant}" = "composefs-sealeduki-sdboot"; then
213+
if test "${boot_type}" = "uki"; then
211214
/run/packaging/finalize-uki /run/sealed-uki/out
212215
fi
213216
EORUN

Justfile

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ base_img := "localhost/bootc"
1818
# Synthetic upgrade image for testing
1919
upgrade_img := base_img + "-upgrade"
2020

21-
# Build variant: ostree (default) or composefs-sealeduki-sdboot (sealed UKI)
21+
# Build variant: ostree (default) or composefs
2222
variant := env("BOOTC_variant", "ostree")
2323
bootloader := env("BOOTC_bootloader", "grub")
2424
# Only used for composefs tests
2525
filesystem := env("BOOTC_filesystem", "ext4")
26+
# Only used for composefs tests
27+
boot_type := env("BOOTC_boot_type", "bls")
28+
# Only used for composefs tests
29+
seal_state := env("BOOTC_seal_state", "unsealed")
2630
# Base container image to build from
2731
base := env("BOOTC_base", "quay.io/centos-bootc/centos-bootc:stream10")
2832
# Buildroot base image
@@ -45,6 +49,8 @@ base_buildargs := generic_buildargs + " " + _extra_src_args \
4549
+ " --build-arg=base=" + base \
4650
+ " --build-arg=variant=" + variant \
4751
+ " --build-arg=bootloader=" + bootloader \
52+
+ " --build-arg=boot_type=" + boot_type \
53+
+ " --build-arg=seal_state=" + seal_state \
4854
+ " --build-arg=filesystem=" + filesystem # required for bootc container ukify to allow missing fsverity
4955
buildargs := base_buildargs \
5056
+ " --cap-add=all --security-opt=label=type:container_runtime_t --device /dev/fuse" \
@@ -75,15 +81,15 @@ list-variants:
7581
Standard bootc image using ostree backend.
7682
This is the traditional, production-ready configuration.
7783

78-
composefs-sealeduki-sdboot
79-
Sealed composefs image with:
80-
- Unified Kernel Image (UKI) containing kernel + initramfs + cmdline
81-
- Secure Boot signing (using keys in target/test-secureboot/)
82-
- systemd-boot bootloader
83-
- composefs digest embedded in kernel cmdline for verified boot
84+
composefs (bootloader, filesystem, boot_type, seal_state)
85+
Build Composefs image with:
86+
- The specified bootloader (grub/systemd)
87+
- The specified filesystem (ext4,btrfs,xfs)
88+
- The specified boot type (BLS/UKI)
89+
- The specified seal state (sealed/unsealed) determining whether we sign the UKI and
90+
use secure boot or not
8491

85-
Use `just build-sealed` as a shortcut, or:
86-
just variant=composefs-sealeduki-sdboot build
92+
Use `just build-sealed` as shortcut to build a sealed composefs image with systemd-boot as the bootloader
8793

8894
Current Configuration
8995
=====================
@@ -96,7 +102,7 @@ list-variants:
96102
# Build a sealed composefs image (alias for variant=composefs-sealeduki-sdboot)
97103
[group('core')]
98104
build-sealed:
99-
@just --justfile {{justfile()}} variant=composefs-sealeduki-sdboot build
105+
@just --justfile {{justfile()}} variant=composefs bootloader=systemd boot_type=uki seal_state=sealed build
100106

101107
# Run tmt integration tests in VMs (e.g. `just test-tmt readonly`)
102108
[group('core')]
@@ -110,28 +116,29 @@ test-container: build build-units
110116
podman run --rm --read-only localhost/bootc-units /usr/bin/bootc-units
111117
podman run --rm --env=BOOTC_variant={{variant}} --env=BOOTC_base={{base}} {{base_img}} bootc-integration-tests container
112118

113-
# Build and test sealed composefs images
114119
[group('core')]
115-
test-composefs-sealeduki-sdboot filesystem:
116-
just variant=composefs-sealeduki-sdboot filesystem={{filesystem}} test-tmt readonly local-upgrade-reboot
120+
test-composefs bootloader filesystem boot_type seal_state:
121+
@if [ "{{seal_state}}" = "sealed" ] && [ "{{filesystem}}" = "xfs" ]; then \
122+
echo "Invalid combination: sealed requires filesystem that supports fs-verity (ext4, btrfs)"; \
123+
exit 1; \
124+
fi
117125

118-
[group('core')]
119-
test-composefs bootloader filesystem:
120-
just variant=composefs bootloader={{bootloader}} filesystem={{filesystem}} \
121-
test-tmt --composefs-backend \
122-
--bootloader {{bootloader}} \
123-
--filesystem {{filesystem}} \
124-
integration
125-
126-
# Build and test composefs images booted using Type1 boot entries and systemd-boot as the bootloader
127-
[group('core')]
128-
test-composefs-sdboot filesystem:
129-
just test-composefs systemd {{filesystem}}
126+
@if [ "{{seal_state}}" = "sealed" ] && [ "{{boot_type}}" != "uki" ]; then \
127+
echo "Invalid combination: sealed requires boot_type=uki"; \
128+
exit 1; \
129+
fi
130130

131-
# Build and test composefs images booted using Type1 boot entries and grub as the bootloader
132-
[group('core')]
133-
test-composefs-grub filesystem:
134-
just test-composefs grub {{filesystem}}
131+
just variant=composefs \
132+
bootloader={{bootloader}} \
133+
filesystem={{filesystem}} \
134+
boot_type={{boot_type}} \
135+
seal_state={{seal_state}} \
136+
test-tmt-nobuild --composefs-backend \
137+
--bootloader={{bootloader}} \
138+
--filesystem={{filesystem}} \
139+
--seal-state={{seal_state}} \
140+
--boot-type={{boot_type}} \
141+
$(if [ "{{boot_type}}" = "uki" ]; then echo "readonly"; else echo "integration"; fi)
135142

136143
# Run cargo fmt and clippy checks in container
137144
[group('core')]

contrib/packaging/seal-uki

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ secrets=$1
1313
shift
1414
allow_missing_verity=$1
1515
shift
16+
seal_state=$1
17+
shift
18+
19+
if [[ $seal_state == "sealed" && $allow_missing_verity == "true" ]]; then
20+
echo "Cannot have missing verity with sealed UKI" >&2
21+
exit 1
22+
fi
1623

1724
# Find the kernel version (needed for output filename)
1825
kver=$(bootc container inspect --rootfs "${target}" --json | jq -r '.kernel.version')
@@ -28,10 +35,12 @@ ukifyargs=(--measure
2835
--json pretty
2936
--output "${output}/${kver}.efi")
3037

31-
# Signing options, we use sbsign by default
32-
ukifyargs+=(--signtool sbsign
33-
--secureboot-private-key "${secrets}/secureboot_key"
34-
--secureboot-certificate "${secrets}/secureboot_cert")
38+
if [[ $seal_state == "sealed" ]]; then
39+
# Signing options, we use sbsign by default
40+
ukifyargs+=(--signtool sbsign
41+
--secureboot-private-key "${secrets}/secureboot_key"
42+
--secureboot-certificate "${secrets}/secureboot_cert")
43+
fi
3544

3645
# Baseline container ukify options
3746
containerukifyargs=(--rootfs "${target}")

0 commit comments

Comments
 (0)