Make FIPS activation runtime-conditional on fips=1 kernel param#908
Make FIPS activation runtime-conditional on fips=1 kernel param#908sparrc wants to merge 1 commit into
Conversation
031257a to
7d57237
Compare
| %{_cross_datadir}/bottlerocket/fips-go.env | ||
| %{_cross_tmpfilesdir}/release-fips.conf | ||
| %{_cross_unitdir}/fipscheck.target | ||
| %{_cross_unitdir}/activate-preconfigured.service |
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>
7d57237 to
aa244aa
Compare
| # Runtime FIPS activation — conditional on fips=1 kernel command line parameter. | ||
| # These are always present but are no-ops on non-FIPS boots. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
| %{_cross_unitdir}/*-bin.mount | ||
| %{_cross_unitdir}/*-libexec.mount |
There was a problem hiding this comment.
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. | |||
There was a problem hiding this comment.
No need for the extra comment.
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:bottlerocket-core-kit/packages/release/check-kernel-integrity.service
Line 9 in 748058e
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:
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.