Support dracut FIPS module w/UKIs

Abierto
#2,514 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
linux, rust

Línea de trabajo

Start with crates/lib/src/ukify.rs and install.rs, then inspect dracut's modules.d/11fips/fips.sh and the existing tmt coverage. Confirm the current FIPS failures for UKI and Type 1 composefs boots before choosing the HMAC flow. Done means the agreed design is implemented, HMAC files remain aligned through install, GC, and rollback, and positive and corrupted-HMAC boot tests cover the supported paths.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Basically, AFAIK this .hmac thing is somewhat of an invention in the Fedora-dervative ecosystem. And I believe Secure Boot provides much stronger integrity than having the UKI basically go and re-checksum itself.

But I guess, for non-Secure Boot scenarios, it does kind of make sense.

I think the ugly thing is whether we just default to generating .hmac files in bootc container ukify or not. Is it an opt-in feature or opt-out feature at build time for those people who don't care about the dracut FIPS check? Or we have bootc container ukify --fips-hmac?

LLM generated notes:

# FIPS on sealed UKI / composefs boots: design notes

Design for cgwalters-forge/tracker#25. Checked against CentOS Stream 10
(quay.io/centos-bootc/centos-bootc:stream10: kernel-6.12.0-271.el10,
dracut-107-11.el10, systemd-257-34.el10), dracut-ng main
(modules.d/11fips/fips.sh, the same logic as CS10's 01fips) and bootc
main at 683bb05f, which includes bootc#2499.

Summary

A composefs system booted with fips=1 fails dracut's kernel integrity
check today. With a UKI (sealed or not) it fails because dracut can't find
bootc's UKI on the ESP. With Type 1 BLS it fails because bootc installs no
HMAC next to the kernel. The fips=1 karg and the dracut module are the easy
part: kargs.d already flows into the UKI cmdline, and the CS10 base image
already puts fips in its initramfs. The work is the HMAC file: where it
comes from, what it is named, and how dracut finds it. That needs a small
dracut change plus bootc install support.

What FIPS mode checks at boot

With fips=1, dracut's fips module (always included on CS10: its check()
returns 0, and lsinitrd on the stock initramfs lists fips and
fips-crypto-policies) runs do_fips in the initramfs. Unless
rd.fips.skipkernel is set, it verifies the booted kernel against an HMAC
file with sha512hmac -c. A failed check halts the boot. There are two paths:

  • UKI (is_uki: systemd-stub's StubFeatures and
    LoaderDevicePartUUID EFI variables are both set). It mounts the ESP
    read-only at /boot by LoaderDevicePartUUID, then for each
    /boot/EFI/Linux/*-$(uname -r).efi it checks .<name>.efi.hmac in the
    same directory. If no UKI matches, the check fails.
  • Type 1: it uses the BOOT_IMAGE= karg (GRUB sets it; systemd-boot
    doesn't), finds /boot/<dir>/.<kernel-name>.hmac and checks it. /boot is
    boot= if given, otherwise a symlink to $NEWROOT/boot.

The HMAC file's format is <hex> <filename>, and the filename is resolved
relative to the HMAC file's directory. CS10's
/usr/lib/modules/<kver>/.vmlinuz.hmac reads
<hex> vmlinuz-6.12.0-271.el10.x86_64. The key is libkcapi's fixed public
key, so this is an integrity self-test (a FIPS 140 requirement), not
authentication. The hash covers only the file's bytes, so a copy of the file
under another name only needs its filename field rewritten.

Sealed UKI

  1. fips=1 in the UKI cmdline. bootc container ukify builds the
    cmdline from kargs.d (crates/lib/src/ukify.rs), so a
    /usr/lib/bootc/kargs.d/01-fips.toml with kargs = ["fips=1"] in the
    image is enough. Kargs given at install time can't reach a sealed UKI, so
    this has to be in the image, alongside update-crypto-policies --set FIPS
    for userspace. rhel-bootc-examples' sealing Containerfile should get a
    FIPS option that does both.
  2. dracut module. It is already in the base image's initramfs, which the
    UKI embeds. Nothing to do on CS10/RHEL 10. A from-scratch image that
    drops it needs add_dracutmodules+=" fips ".
  3. The HMAC must cover the signed UKI. The hash covers the whole .efi,
    so it can only be computed after signing: by the build step that signs the
    UKI, or by bootc from the bytes it installs.
  4. dracut can't find bootc's UKI. bootc installs
    ESP/EFI/Linux/bootc/bootc_composefs-<digest>.efi (plus grub user.cfg
    or BLS uki/efi entries). dracut only globs EFI/Linux/*-<kver>.efi,
    which matches neither the bootc/ subdirectory nor the name. So even a
    correct .bootc_composefs-<digest>.efi.hmac next to it is never checked,
    and the boot dies with "Failed for find UKI". The workaround is
    rd.fips.skipkernel, which must also go in the signed cmdline.
  5. What .vmlinuz.hmac and split-kernel (bootc#2499) mean here. bootc#2499
    makes split-kernel-and-rootfs move .vmlinuz.hmac along with vmlinuz,
    so it is no longer orphaned in a sealed rootfs. For a UKI that HMAC is only
    an input: it covers the bare vmlinuz, which becomes the UKI's .linux
    section and is never a file on the ESP, and dracut's UKI path never looks
    at it. The UKI build step should consume it (optionally verifying
    vmlinuz against it before wrapping, which keeps a build-time integrity
    chain) and emit a new HMAC over the signed UKI.
Proposal
  • dracut (upstream first, then RHEL 10): in do_uki_check, find the
    booted UKI from systemd-stub's StubImageIdentifier EFI variable (the
    UKI's path on the ESP; the exact systemd version that added it still needs
    checking) and check .<basename>.hmac next to it, falling back to today's
    glob. Checking exactly the booted image is also more correct than "every
    UKI matching uname -r". This works for bootc's bootc/ subdirectory and
    names, under systemd-boot and GRUB chainloading alike. A simpler dracut
    patch that also globs EFI/Linux/*/*.efi would check every bootc UKI on
    the ESP, and fail on any stale one without an HMAC.
  • bootc: carry a build-time UKI HMAC like #2499 carries .vmlinuz.hmac.
    If the image has .<uki>.efi.hmac next to its UKI, install it as
    .bootc_composefs-<digest>.efi.hmac in the same directory with the
    filename field rewritten, and verify it against the installed UKI first,
    failing the install on a mismatch. GC and rollback must delete and keep it
    together with its UKI.
  • Build (bootc container ukify / the seal flow): after signing, write
    .<uki>.efi.hmac next to the UKI in the image (sha512hmac, or the same
    HMAC-SHA512 in Rust with the fixed key).
  • Until dracut changes, document rd.fips.skipkernel in kargs.d as the only
    way to boot a sealed UKI with fips=1. Whether that is acceptable for
    certification is for the RHEL FIPS folks. Secure Boot does verify the UKI,
    but that is not the module's own integrity test.

Composefs Type 1 (BLS, not UKI)

bootc copies vmlinuz and the initramfs to
/boot/bootc_composefs-<digest>/ (GRUB) or ESP/EFI/Linux/bootc_composefs-<digest>/
(systemd-boot), and neither bootc nor composefs-rs copies an HMAC. So:

  • Install /usr/lib/modules/<kver>/.vmlinuz.hmac as .vmlinuz.hmac next to
    the installed vmlinuz, with its filename field rewritten from
    vmlinuz-<kver> to vmlinuz. It must also count in the shared-entry
    dedup that compute_boot_digest/find_vmlinuz_initrd_duplicate does.
  • /boot in the initramfs: without boot=, dracut falls back to
    $NEWROOT/boot, which on composefs is the image's empty /boot, not the
    physical one. bootc already adds boot=UUID=... when there is a separate
    /boot partition (install.rs, "things like FIPS"). Without one, it would
    need boot= naming the root filesystem, and dracut's BOOT_IMAGE handling
    then finds /boot/boot/bootc_composefs-.../vmlinuz. That needs testing.
  • systemd-boot sets no BOOT_IMAGE, so dracut looks for
    /boot/vmlinuz-<kver> and fails. Either bootc adds BOOT_IMAGE= to the
    entry's options, or composefs systemd-boot with FIPS is UKI-only.

Test plan

A tmt test with fips=1 in kargs.d, for composefs grub/BLS and systemd-boot
UKI (sealed on CI's sealed leg), that asserts
cat /proc/sys/crypto/fips_enabled is 1 and that the journal shows
dracut's checking .<uki>.hmac or the kernel HMAC line. A negative case
corrupts the HMAC and expects the boot to fail. From reading fips.sh, every
composefs leg should fail the positive case today, which makes it the
reproducer. I haven't booted one with fips=1 yet; that is the next step
once the approach is agreed.

Lenguaje dominante
Rust
Estrellas
2.3k
Forks
230
Merge medio
2 d 11 h
PR fusionados (30 d)
42

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bootc-dev/bootc

Todos los issues de bootc-dev/bootc

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.