Skip to content

kernel: don't trust UEFI keys for modules - #635

Merged
michaelb990 merged 1 commit into
bottlerocket-os:developfrom
michaelb990:kernel-uefi-platform-keyring
Nov 25, 2026
Merged

michaelb990 merged 1 commit into
bottlerocket-os:developfrom
michaelb990:kernel-uefi-platform-keyring

Conversation

@michaelb990

Copy link
Copy Markdown
Contributor

Issue number:

N/A

Description of changes:

Amazon Linux's "KEYS: Make use of platform keyring for module signature verify" patch makes the kernel retry a
module's signature against the .platform keyring, which it fills from the UEFI db and, with Secure Boot on,
MokListRT. On the aws-mantle-* variants, modules should verify only against the kit's module-signing key.

This turns off CONFIG_INTEGRITY_PLATFORM_KEYRING for kernel-6.18 and kernel-next. The kernel then creates neither
the .platform nor the .machine keyring and reads no keys from UEFI variables, so modules verify only against the
kernel's built-in key and keys it vouches for in the secondary keyring.

The 14 changed files:

  • Two hand-edited config fragments. kernel-6.18-shared-configs/config-bottlerocket is shared by kernel-6.18 and
    kernel-6.18-microvm; kernel-next/config-bottlerocket is kernel-next's.
  • 12 regenerated config-full-bottlerocket-<target>-on-<host> files, four per kernel. Each spec diffs the resolved
    config against them (Source110-Source113) and fails the build on any difference. They're per build host
    because compiler-probed options differ: CC_HAS_MARCH_NATIVE is set only when an x86_64 host builds the x86_64
    kernel. The -on-aarch64 files were regenerated on an arm64 host.

The four Kconfig lines that change in each full config:

Symbol Before After
INTEGRITY_PLATFORM_KEYRING y not set (the fragment change)
LOAD_UEFI_KEYS y dropped, depends on INTEGRITY_PLATFORM_KEYRING
INTEGRITY_MACHINE_KEYRING y dropped, depends on LOAD_UEFI_KEYS
INTEGRITY_CA_MACHINE_KEYRING not set line dropped with its parent

Side effects:

  • kernel-6.18-microvm changes only because it shares kernel-6.18's fragment. It doesn't use the kit's
    module-signing key, and no Bottlerocket variant uses it.
  • The other variants on kernel-6.18 and kernel-next, shim variants included, change the same way: modules signed
    with a db, MOK or shim vendor certificate no longer verify. Nothing the kits ship is signed with those keys.
  • The dbx and MokListXRT hashes are no longer added to the .blacklist keyring.
  • On aarch64, kexec_file_load no longer verifies the Secure Boot-signed vmlinuz on grub images. Without
    lockdown it still loads; aws-dev, the only aarch64 variant on these kernels that reserves a crash kernel, has
    lockdown off.
  • certs/system_keyring.c is built into fips140.ko, so this changes code inside the FIPS module: 3 keyring
    functions are removed and 2 change. Every algorithm and self-test function has the same instructions.

Testing done:

Built the kit for x86_64 and aarch64 and booted images with test Secure Boot keys and UEFI data that adds a test
certificate to MokListRT, on aws-mantle-1 (x86_64, aarch64), aws-mantle-1-fips (x86_64, aarch64),
aws-mantle-1-nvidia and aws-mantle-1-nvidia-fips (x86_64, on L4 and L40S), aws-mantle-next-64k-nvidia
(aarch64) and aws-ecs-4 (x86_64, shim). kernel-6.18-microvm was built but not booted. A host container re-signed
a module with each key and loaded it. On the aws-mantle-* variants:

Key Before After
Certificate issued by the db CA, embedded in the signature loads rejected
Certificate in MokListRT loads rejected
Kit module-signing key loads loads
  • Unsigned, tampered and untrusted-key modules are still rejected, and every shipped module verified against the
    kit certificate on each image that ran that check.
  • keyctl finds neither .platform nor .machine; dmesg has no UEFI:db or UEFI:MokListRT lines.
  • The FIPS variants boot in FIPS mode (fips_enabled=1, check-fips-modules succeeds).
  • On aws-ecs-4, a module signed by the db-CA certificate is rejected.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Amazon Linux's "KEYS: Make use of platform keyring for module signature
verify" patch makes the kernel retry a module's signature against the
.platform keyring, which it fills from the UEFI db and, with Secure
Boot on, MokListRT. On the aws-mantle variants, modules should verify
only against the kit's module-signing key.

Turn off CONFIG_INTEGRITY_PLATFORM_KEYRING for kernel-6.18, in the
shared config so kernel-6.18-microvm follows, and for kernel-next. This
also turns off LOAD_UEFI_KEYS and INTEGRITY_MACHINE_KEYRING, so the
kernel creates neither .platform nor .machine and reads no keys from
UEFI variables. Modules then verify only against the kernel's built-in
key and keys it vouches for in the secondary keyring.

Regenerate the kernel-6.18, kernel-6.18-microvm and kernel-next full
configs.

Signed-off-by: Michael Brown <brownxmi@amazon.com>
@arnaldo2792
arnaldo2792 marked this pull request as draft November 24, 2026 22:22
@michaelb990
michaelb990 marked this pull request as ready for review November 25, 2026 17:01
@michaelb990
michaelb990 merged commit cf7e9bd into bottlerocket-os:develop Nov 25, 2026
5 checks passed
@michaelb990
michaelb990 deleted the kernel-uefi-platform-keyring branch November 25, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants