Skip to content

Commit 6f7a2c3

Browse files
committed
efi/preinstall: moved manual preinstall check actions after automatic actions
1 parent fa3da0f commit 6f7a2c3

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

efi/preinstall/actions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ const (
6060
ActionRebootToFWSettings Action = "reboot-to-fw-settings"
6161

6262
// ActionContactOEM is a hint that the user should contact the OEM for the
63-
// device because of a bug in the platform. It is a pseudo-action and cannnot
63+
// device because of a bug in the platform. It is a pseudo-action and cannot
6464
// be performed by this package.
6565
ActionContactOEM Action = "contact-oem"
6666

6767
// ActionContactOSVendor is a hint that the user should contact the OS vendor
68-
// because of a bug in the OS. It is a pseudo-action and cannnot be performed
68+
// because of a bug in the OS. It is a pseudo-action and cannot be performed
6969
// by this package.
7070
ActionContactOSVendor Action = "contact-os-vendor"
7171

efi/preinstall/checks_context.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ import (
3535
// errorKindToActions maps an error kind to one or more possible actions. The
3636
// slice of actions is an OR in the sense that any one of these actions can
3737
// be executed to attempt to resolve the associated error kind.
38+
//
39+
// The order of actions is significant as it represents the recommended order
40+
// in which users should attempt to resolve issues. Actions are ordered by:
41+
// 1. Automatic actions before manual actions e.g. automatic PPI-based actions
42+
// are listed before manual actions that require rebooting to firmware settings.
43+
// 2. Simplest actions first e.g. ActionClearTPMViaFirmware before
44+
// ActionEnableAndClearTPMViaFirmware
3845
var errorKindToActions map[ErrorKind][]Action
3946

4047
// errorKindToProceedFlag maps an error kind to a flag that can be set
@@ -57,28 +64,28 @@ func init() {
5764
ActionContactOEM,
5865
},
5966
ErrorKindTPMDeviceDisabled: []Action{
60-
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to enable the TPM
6167
ActionEnableTPMViaFirmware, // suggest enabling the TPM via the PPI
6268
ActionEnableAndClearTPMViaFirmware, // suggest enabling and clearing the TPM via the PPI
69+
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to enable the TPM
6370
},
6471
ErrorKindTPMHierarchiesOwned: []Action{
65-
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to clear the TPM
6672
ActionClearTPMViaFirmware, // suggest clearing the TPM via the PPI
6773
ActionEnableAndClearTPMViaFirmware, // suggest enabling and clearing the TPM via the PPI
74+
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to clear the TPM
6875
ActionClearTPMSimple, // suggest clearing the TPM using TPM2_Clear
6976
ActionClearTPM, // suggest clearing the TPM using TPM2_Clear
7077
// TODO: Add action to clear the authorization values / policies
7178
},
7279
ErrorKindTPMDeviceLockoutLockedOut: []Action{
73-
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to clear the TPM
7480
ActionClearTPMViaFirmware, // suggest clearing the TPM via the PPI
7581
ActionEnableAndClearTPMViaFirmware, // suggest enabling and clearing the TPM via the PPI
82+
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to clear the TPM
7683
// There will be no option to clear the lockout as there isn't a mechanism to do this.
7784
},
7885
ErrorKindInsufficientTPMStorage: []Action{
79-
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to clear the TPM
8086
ActionClearTPMViaFirmware, // suggest clearing the TPM via the PPI
8187
ActionEnableAndClearTPMViaFirmware, // suggest enabling and clearing the TPM via the PPI
88+
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to clear the TPM
8289
ActionClearTPMSimple, // suggest clearing the TPM using TPM2_Clear
8390
ActionClearTPM, // suggest clearing the TPM using TPM2_Clear
8491
},
@@ -95,8 +102,8 @@ func init() {
95102
ActionContactOEM, // suggest contacting the OEM because of a firmware bug
96103
},
97104
ErrorKindInsufficientDMAProtection: []Action{
98-
ActionContactOEM, // suggest contacting the OEM because of a firmware bug.
99105
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to enable DMA protection.
106+
ActionContactOEM, // suggest contacting the OEM because of a firmware bug.
100107
},
101108
ErrorKindNoKernelIOMMU: []Action{
102109
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to enable DMA protection.
@@ -115,8 +122,8 @@ func init() {
115122
// TODO: Add an action to just disable these by erasing the SysPrepOrder and SysPrepXXXX variables
116123
},
117124
ErrorKindAbsolutePresent: []Action{
118-
ActionContactOEM, // suggest contacting the OEM if there's no way to disable it.
119125
ActionRebootToFWSettings, // suggest rebooting to the firmware settings UI to disable it.
126+
ActionContactOEM, // suggest contacting the OEM if there's no way to disable it.
120127
// TODO: Add an action to just disable this automatically on supported platforms (eg, Dell via the WMI interface)
121128
},
122129
ErrorKindInvalidSecureBootMode: []Action{
@@ -397,7 +404,7 @@ func (c *RunChecksContext) classifyRunChecksError(err error) (info errorInfo, ou
397404
return errorInfo{kind: ErrorKindInsufficientTPMStorage}, nil
398405
}
399406

400-
// This has to become before MeasuredBootError because that error wraps this one.
407+
// This has to come before MeasuredBootError because that error wraps this one.
401408
var pcrAlgErr *NoSuitablePCRAlgorithmError
402409
if errors.As(err, &pcrAlgErr) {
403410
// RunChecks indicates that there is no suitable PCR bank. The possibilities here:

efi/preinstall/errors.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
// to the supplied string, useful for displaying multiple errors. In a multi-line
3838
// string, subsequent lines in the supplied string will all be aligned with the start
3939
// of the first line after the marker. The indentation argument specifies the
40-
// indentation of the maker, in the number of characters.
40+
// indentation of the marker, in the number of characters.
4141
func makeIndentedListItem(indentation int, marker, str string) string {
4242
scanner := bufio.NewScanner(bytes.NewReader([]byte(str)))
4343

@@ -94,7 +94,7 @@ func makeIndentedListItem(indentation int, marker, str string) string {
9494
// CompoundError is an interface for accessing wrapped errors from an error type that
9595
// wraps more than one error. The [RunChecks] and [RunChecksContext.Run] APIs may return
9696
// multiple errors that are wrapped by a type implementing this interface, as an
97-
// alternative to aborting early and returning individual errors as the occur. This is
97+
// alternative to aborting early and returning individual errors as they occur. This is
9898
// to ensure as much information is gathered as possible.
9999
type CompoundError interface {
100100
Unwrap() []error
@@ -185,7 +185,7 @@ func (e *EFIVariableAccessError) Unwrap() error {
185185
var (
186186
// ErrSystemNotEFI is returned unwrapped from RunChecks if the current host
187187
// system does not appear to be an EFI system.
188-
ErrSystemNotEFI = errors.New("host system is not a EFI system")
188+
ErrSystemNotEFI = errors.New("host system is not an EFI system")
189189
)
190190

191191
// Errors related to checking platform firmware protections.
@@ -263,7 +263,7 @@ var (
263263

264264
// ErrTPMStartupLocalityNotProtected is returned wrapped in HostSecurityError if access to
265265
// the TPM's startup locality is available to platform firmware or privileged code. This
266-
// means that it's not possible to provide a mitigation against reseet attacks (see the
266+
// means that it's not possible to provide a mitigation against reset attacks (see the
267267
// description of DiscreteTPMDetected). This error is only relevant for discrete TPMs.
268268
// It can be permitted by passing the PermitNoDiscreteTPMResetMitigation flag to RunChecks.
269269
ErrTPMStartupLocalityNotProtected = errors.New("access to the discrete TPM's startup locality is available to platform firmware and privileged OS code, preventing any mitigation against reset attacks")
@@ -331,7 +331,7 @@ var (
331331

332332
// ErrNoPCClientTPM is returned wrapped in TPM2DeviceError if a TPM2 device exists but
333333
// it doesn't claim to be meet the requirements for PC-Client. Note that swtpm used
334-
// by VM's don't behave correctly here, so we account for that instead of returning
334+
// by VMs don't behave correctly here, so we account for that instead of returning
335335
// an error.
336336
ErrNoPCClientTPM = errors.New("TPM2 device is present but it is not a PC-Client TPM")
337337

@@ -344,7 +344,7 @@ var (
344344
// ErrTPMFailure is returned wrapped in TPM2DeviceError is the TPM device is in
345345
// failure mode. A TPM device in failure mode can only execute commands to obtain
346346
// test results, or fetch a limited set of permanent properties to determine the
347-
// manufactuer, vendor name or firmware version. Resetting a device in failure mode
347+
// manufacturer, vendor name or firmware version. Resetting a device in failure mode
348348
// may clear it but it's possible that the failure may occur again during the next
349349
// boot cycle, in which case, it's likely that there is a fault somewhere with the
350350
// TPM's hardware (in the case of dTPMs) or the TPM's firmware.
@@ -507,7 +507,7 @@ func (e *MeasuredBootError) Unwrap() error {
507507
// cannot be used to generate profiles for PCR 0.
508508
//
509509
// If an error occurs, this error will be returned wrapped in
510-
// [NoSuitablePCRAlgorithmError] if the PermitNolatformFirmwareProfileSupport flag
510+
// [NoSuitablePCRAlgorithmError] if the PermitNoPlatformFirmwareProfileSupport flag
511511
// is not supplied to [RunChecks].
512512
type PlatformFirmwarePCRError struct {
513513
err error
@@ -523,7 +523,7 @@ func (e *PlatformFirmwarePCRError) Unwrap() error {
523523

524524
// Errors related to platform config PCR checks
525525

526-
// PlatformConfigPCR may be returned if the PCR 1 value is inconsistent with the
526+
// PlatformConfigPCRError may be returned if the PCR 1 value is inconsistent with the
527527
// value reconstructed from the TCG log.
528528
//
529529
// This error will currently always be returned as a warning in [CheckResult] if
@@ -553,7 +553,7 @@ func (e *PlatformConfigPCRError) Unwrap() error {
553553

554554
// Errors related to drivers and apps PCR checks.
555555

556-
// DriversAndAppsError may be returned if the PCR 2 value is inconsistent with the
556+
// DriversAndAppsPCRError may be returned if the PCR 2 value is inconsistent with the
557557
// value reconstructed from the TCG log.
558558
//
559559
// If an error occurs, this error will be returned as a warning in [CheckResult] if
@@ -631,7 +631,7 @@ func (e *DriversAndAppsConfigPCRError) Unwrap() error {
631631
// - EV_EFI_BOOT_SERVICES_APPLICATION events that occur before secure boot policy
632632
// is measured.
633633
// - Unexpected event types before the OS-present phase.
634-
// - The presence of system prepartion apps when the firmware indicates they are
634+
// - The presence of system preparation apps when the firmware indicates they are
635635
// not supported.
636636
// - EV_EFI_BOOT_SERVICES_APPLICATION events that occur in the OS-present phase
637637
// but aren't associated with the OS launch or Absolute.
@@ -823,7 +823,7 @@ var (
823823
// indicates that pre-OS components were authenticated using Authenticode digests rather than a
824824
// X.509 certificate. This makes PCR7 inherently fragile with regards to firmware updates because db
825825
// has to be changed accordingly each time.
826-
// This can be bypassed by supplying the PermitPreOSVeriricationUsingDigests flag to RunChecks, in
826+
// This can be bypassed by supplying the PermitPreOSVerificationUsingDigests flag to RunChecks, in
827827
// which case, the error is returned as a warning via CheckResult.
828828
//
829829
// The check for pre-OS components authenticated using a digest may not execute if a

0 commit comments

Comments
 (0)