Skip to content

Make FIPS activation runtime-conditional on fips=1 kernel param#908

Open
sparrc wants to merge 1 commit into
bottlerocket-os:developfrom
sparrc:sparrc-runtime-fips-v2
Open

Make FIPS activation runtime-conditional on fips=1 kernel param#908
sparrc wants to merge 1 commit into
bottlerocket-os:developfrom
sparrc:sparrc-runtime-fips-v2

Conversation

@sparrc

@sparrc sparrc commented Apr 14, 2026

Copy link
Copy Markdown

The overall purpose of this change is to include most FIPS logic in all BR variants, and to standardize on all of the systemd services only being activated with ConditionKernelCommandLine=fips=1, as some already are:

This gets closer to the "standard" BR AMI being able to be used in FIPS environments, only needing a runtime switch to activate FIPS mode like the following userdata:

[settings.boot] 
reboot-to-reconcile = true 
[settings.boot.kernel-parameters] 
fips = ["1"]

Description of changes:

Move FIPS-related systemd units and drop-ins from the release-fips subpackage into the base release package so they ship in all variants. These units already use ConditionKernelCommandLine=fips=1 or depend on fipscheck.target, so they are no-ops on non-FIPS boots.

Replace the unconditional Environment=GODEBUG=fips140=on drop-in with an EnvironmentFile=-/run/fips-go.env approach: a new service copies the env file into /run only when fips=1 is set. Similarly, replace the tmpfiles-based /etc/system-fips creation with a conditional service.

The bootconfig snippet and FIPS binary overlay mounts remain in the fips subpackage since they require build-time binary selection.

Assisted-by: Cline:anthropic.claude-opus-4-6-v1

Testing done:

WIP

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.

Comment thread packages/release/create-fips-marker.service
@sparrc sparrc force-pushed the sparrc-runtime-fips-v2 branch from 031257a to 7d57237 Compare May 27, 2026 17:05
@sparrc sparrc changed the title [WIP] Make FIPS activation runtime-conditional on fips=1 kernel param Make FIPS activation runtime-conditional on fips=1 kernel param May 27, 2026
%{_cross_datadir}/bottlerocket/fips-go.env
%{_cross_tmpfilesdir}/release-fips.conf
%{_cross_unitdir}/fipscheck.target
%{_cross_unitdir}/activate-preconfigured.service

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These also need

ConditionKernelCommandLine=fips=1

which @sky1122 has in #918

We should merge #918 first and rebase this PR

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack 👍

Move FIPS-related systemd units and drop-ins from the release-fips
subpackage into the base release package so they ship in all variants.
These units already use ConditionKernelCommandLine=fips=1 or depend on
fipscheck.target, so they are no-ops on non-FIPS boots.

Replace the unconditional Environment=GODEBUG=fips140=on drop-in with
an EnvironmentFile=-/run/fips-go.env approach: a new service copies the
env file into /run only when fips=1 is set. Similarly, replace the
tmpfiles-based /etc/system-fips creation with a conditional service.

The bootconfig snippet and FIPS binary overlay mounts remain in the fips
subpackage since they require build-time binary selection.

Assisted-by: Cline:anthropic.claude-opus-4-6-v1
Signed-off-by: Cameron Sparr <sparrc@users.noreply.github.com>
@sparrc sparrc force-pushed the sparrc-runtime-fips-v2 branch from 7d57237 to aa244aa Compare June 3, 2026 21:58
Comment on lines +488 to +489
# Runtime FIPS activation — conditional on fips=1 kernel command line parameter.
# These are always present but are no-ops on non-FIPS boots.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra comment here not really needed, we have the context from the previous comments

# the generate-fips-env.service creates /run/fips-go.env with
# GODEBUG=fips140=on. The "-" prefix means this is optional and
# will not cause failures if the file does not exist (non-FIPS boot).
EnvironmentFile=-/run/fips-go.env

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for posterity:

I thought that it will be simpler to keep the original file and copy it with a systemd service to /etc/systemd/system/service.d. But, it doesn't feel right that a systemd service copies a drop-in for other systemd services (and I don't want to establish the precedent that we should do that).

That said, I like your approach in the PR better because it copies an env file for all systemd services instead of a drop-in for all services.

Comment on lines +504 to +505
%{_cross_unitdir}/*-bin.mount
%{_cross_unitdir}/*-libexec.mount

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep these in the main package as now they are conditional on the kernel parameter.

@@ -1,2 +1,2 @@
f+ /etc/system-fips 0644 root root -
# Clean up FIPS module check state files from fips-modprobe@.service.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the extra comment.

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