Skip to content

efi: implement platform-agnostic arm64 host security checks - #564

Closed
alexclewontin wants to merge 7 commits into
canonical:masterfrom
alexclewontin:check-host-security-arm64
Closed

efi: implement platform-agnostic arm64 host security checks#564
alexclewontin wants to merge 7 commits into
canonical:masterfrom
alexclewontin:check-host-security-arm64

Conversation

@alexclewontin

Copy link
Copy Markdown
Member

This PR adds a framework for host security checks on arm64 platforms. It builds on #563 (which represents most of the diff), and is part of an attempt to split up #560.

It adds a generic framework to check host security on ARM64. Very few truly cross-platform APIs were found to be applicable to that ecosystem, but we can use the backing driver for the TPM to prove that a given TPM is a fTPM: if it is using the OP-TEE fTPM driver we can be sure that it is an fTPM. This is not conclusive (absence of that driver doesn't prove that a TPM is a dTPM), but it is a common reference implementation for the ARM ecosystem, so worth including.

CheckResult.Warnings is a CompoundError interface that RunChecks leaves
nil when no warnings were detected. Unwrap on a nil interface panics, so
only unwrap when warnings are present.
github.com/canonical/cpuid does not compile on non-x86 architectures,
which forced the AMD64 host environment to be split across a filename
gated default_env_amd64.go and a default_env_amd64_null.go stub. That
made the implementation invisible to the compiler, and untestable, on
every other architecture.

Confine that dependency to a new internal/cpuid package. It is a
deliberately thin wrapper, and the only place in the tree that is gated
by architecture at build time. It exposes VendorIdentificator, Family
and HasFeature, delegating to the upstream package on amd64 and
returning zero values elsewhere.

internal/efi is now architecture neutral: it carries no build
constraints, the AMD64 implementation collapses into default_env.go, and
AMD64() selects on a mockable runtimeGOARCH rather than a build tag.
This mirrors the runtime dispatch used elsewhere for host security
checks.

The CPUIDFeature* constants stay in internal/efi, so callers are
unchanged. Their drift guards against the upstream bit positions move to
internal/cpuid, which is now the only package able to see both.

The AMD64 tests lose their build constraints and drive the CPU identity
through new mock hooks instead of mutating upstream package variables,
so they run everywhere. TestNotAMD64Host no longer depends on the host
architecture, and therefore now runs on amd64 too.
Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>
@alexclewontin
alexclewontin force-pushed the check-host-security-arm64 branch from d599a22 to 142a04a Compare September 3, 2026 17:31

@MitchellAugustin MitchellAugustin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What has been implemented here so far looks good from my perspective. Main thoughts:

  • In my comparison of this PR's diff against #560 diff, none of the new delta seems problematic to me
  • SMBIOS table 4 detection and platform-level items discussed in 560 have been cleanly included in this PR

This was only a static code review (I did not test)

// checkHostSecurityARM64Platform selects the platform-specific firmware
// integrity check. Tests replace this to supply synthetic platforms.
var checkHostSecurityARM64Platform = func(env internal_efi.HostEnvironmentARM64, cpuManufacturer string) (platformFirmwareIntegrityConfig, error) {
return platformFirmwareIntegrityNone, &UnsupportedPlatformError{fmt.Errorf("unsupported CPU manufacturer: %s", cpuManufacturer)}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess this is intentionally a stub until we have our updates from NVIDIA?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, although this could be a stub that includes a switch case statement

@alexclewontin

Copy link
Copy Markdown
Member Author

Closing in favor of #566

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.

2 participants