Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHEL 10 FIPS adjustments #21264

Merged
merged 4 commits into from
Nov 15, 2024
Merged

RHEL 10 FIPS adjustments #21264

merged 4 commits into from
Nov 15, 2024

Conversation

martinpitt
Copy link
Member

@martinpitt martinpitt commented Nov 14, 2024

See commit logs for details.

https://issues.redhat.com/browse/COCKPIT-1185

Testing:

  • All our current "main" bots images still have fips-mode-setup, so this PR shouldn't cause any regressions.
  • The rhel-10-0 refresh brings the announced FIPS mode setup changes (which fail the tests) and doesn't regress anything else. test against that image succeeded here
  • The centos-10 refresh also brings the FIPS changes, and its kernel doesn't oops with FIPS -- but it regresses PCP, so tests will still not go green. However, TestSystemInfo.testCryptoPolicies and TestSystemInfo.testInconsistentCryptoPolicy should go green. see the test output, this is exactly as expected.

pkg/systemd/overview-cards/cryptoPolicies.jsx Outdated Show resolved Hide resolved

try {
if (policy === "FIPS") {
await setup_fips("--enable", ["set", "fips=1"]);

Choose a reason for hiding this comment

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

There's a bit of a catch here. Switching to FIPS by adding fips=1 to the kernel command line is only sufficient if /boot is not on a separate partition. If it is, adding fips=1 without adding boot=UUID=$boot_uuid flag will cause the boot to fail because the initramfs can no longer figure out where to find the HMAC and kernel image to do the required integrity check.

So if you're implementing functionality to enable FIPS mode, I'd recommend you also add boot=UUID=$(blkid --output value --match-tag UUID $(findmnt --first --noheadings -o SOURCE /boot)).

Copy link
Member Author

Choose a reason for hiding this comment

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

Meh -- that's exactly the kind of quirk that makes it hard to do and to document, i.e. what the fips-mode-setup helper was good at. By asking users to do that (manually, in Ansible deployments, bootc container builds, and what not), that'd reintroduce brittleness. If there is no choice here, why can't the dracut magic do that by itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

@neverpanic Maybe a better alternative would be to drop the FIPS mode enabling if fips-mode-setup isn't available -- as far as I understood your mail, you don't support enabling FIPS mode after installation any more?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, it never offers enabling/disabling FIPS without fips-mode-setup now.

@martinpitt
Copy link
Member Author

For future records, the "support fips=1 enablement" approach was commit 1a8c831. But as the announcement email said quite explicitly

Users can still switch to FIPS mode after installation by adding fips=1 to their kernel command line using grubby, but this is not supported outside of testing.

and @neverpanic mentioned the potential breakage with the boot= argument (which we can't test, as cloud images don't have a boot partition), let's rather not offer unsupported things.

I'll rework this to disable the FIPS switching if fips-mode-setup does not exist (aka. RHEL/CentOS 10)

@martinpitt martinpitt marked this pull request as draft November 15, 2024 08:31
If FIPS is enabled, /etc/crypto-policies/state/current will still show
the previous non-FIPS policy. Ask `update-crypto-policies --show` for
the real policy instead, to avoid second-guessing all of this. Keep the
watch, as that's useful to detect dynamic changes, but watch the actual
config file instead, as recommended by FIPS maintainer @neverpanic.

This was spotted in TestSystemInfo.testCryptoPolicies, which first
enabled FIPS and then tried to test the "EMPTY" profile. This doesn't
really work, as the end result is still "FIPS". So swap the order.
This will make further conditionals easier, and is generally easier to
read.
useEffect() is not necessary here. This allows us to drop a condition.
RHEL 10 drops the `fips-mode-setup` and only supports enabling FIPS on
installation or bootc images [1]. For testing one can also add `fips=1`
to the kernel command line, but that (1) causes trouble with separate
/boot partition, and (2) is not supported.

So only offering switching to and away from FIPS if `fips-mode-setup` is
present. Otherwise, if FIPS is already enabled, make the crypto policy
indicator readonly; if f-m-s is not available, filter out FIPS from
available policies.

https://issues.redhat.com/browse/COCKPIT-1185
Copy link
Member

@jelly jelly left a comment

Choose a reason for hiding this comment

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

Thanks!

promise.then(() => cockpit.spawn(["shutdown", "--reboot", "now"], { superuser: "require", err: "message" }))
.catch(error => setError(error))
.finally(() => setInProgress(false));
await cockpit.spawn(["shutdown", "--reboot", "now"], { superuser: "require", err: "message" });
Copy link
Member

Choose a reason for hiding this comment

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

Technically should use cockpit.hint('restart'); but that is another issue.

// Ask crypto-policies to get correct FIPS state, as that dominates the configured policy
try {
setCurrentCryptoPolicy((await cockpit.spawn(["update-crypto-policies", "--show"])).trim());
} catch (error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test.


const policyRender = (currentCryptoPolicy.startsWith("FIPS") && !fipsConfigurable)
/* read-only mode; can't switch away from FIPS without fips-mode-setup */
? <span id="crypto-policy-current">{displayProfileText(currentCryptoPolicy)}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test.

Comment on lines +111 to +113
} catch (error) {
setError(error);
} finally {
Copy link
Contributor

Choose a reason for hiding this comment

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

These 3 added lines are not executed by any test.


useInit(() => {
cockpit.file("/etc/crypto-policies/state/current")
.watch(content => setCurrentCryptoPolicy(content ? content.trim().split(':', 1)[0] : undefined));
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test.

@martinpitt martinpitt merged commit 9cc4197 into cockpit-project:main Nov 15, 2024
81 of 87 checks passed
@martinpitt martinpitt deleted the fips branch November 15, 2024 11:08
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