Skip to content

Commit 321eeb1

Browse files
committed
efi/preinstall: Update PCRProfileOptionsFlags
This updates PCRProfileOptionsFlags, such that: - There are now individual options to include each PCR if not already included (PCRProfileOptionLockTo*). - PCRProfileOptionsMostSecure includes all of the new PCRProfileOptionLockTo* options. - PCRProfileOptionTrustCAsForAddonDrivers and PCRProfileOptionTrustCAsForBootCode have been renamed to - PCRProfileOptionTrustSecureBootAuthoritiesForAddonDrivers and PCRProfileOptionTrustSecureBootAuthoritiesForBootCode. They can only be used if the active CAs are not recognized. They can't be used to omit PCRs 2 or 4 from the profile if the CA is recognized and explicitly distrusted, so that users can't use these options to create insecure profiles. - PCRProfileOptionDistrustVARSuppliedNonHostCode is gone because it is superceded by PCRProfileOptionLockToDriversAndApps. Fixes: FR-12150
1 parent fcc9a2a commit 321eeb1

File tree

5 files changed

+606
-539
lines changed

5 files changed

+606
-539
lines changed

cmd/test_efi_fde_compat/main.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ type options struct {
2727
} `group:"Initial check options"`
2828

2929
Profile struct {
30-
MostSecure bool `long:"most-secure" description:"Select the most secure PCR profile"`
31-
TrustCAsForBootCode bool `long:"trust-authorities-for-boot-code" description:"Trust the secure boot CAs used to authenticate code on this system to authenticate any boot code (definitely not advisable for the Microsoft UEFI CA)"`
32-
TrustCAsForAddonDrivers bool `long:"trust-authorities-for-addon-drivers" description:"Trust the secure boot CAs used to authenticate code on this system to authenticate any addon driver (most likely not advisable for the Microsoft UEFI CA)"`
33-
DistrustVARSuppliedNonHostCode bool `long:"distrust-var-supplied-nonhost-code" description:"Distrust code running in value-added-retailer supplied embedded controllers. This code doesn't run on the CPU and isn't part of the trust chain, but can potentially still affect trust"`
34-
PermitNoSecureBoot bool `long:"permit-no-secure-boot" description:"Permit profiles that don't include the secure boot policy"`
35-
NoDiscreteTPMResetMitigation bool `long:"no-discrete-tpm-reset-mitigation" description:"Disable mitigations against discrete TPM reset attacks where appropriate"`
30+
MostSecure bool `long:"most-secure" description:"Select the most secure PCR profile"`
31+
TrustCAsForBootCode bool `long:"trust-authorities-for-boot-code" description:"Trust the secure boot CAs used to authenticate code on this system to authenticate any boot code (definitely not advisable for the Microsoft UEFI CA)"`
32+
TrustCAsForAddonDrivers bool `long:"trust-authorities-for-addon-drivers" description:"Trust the secure boot CAs used to authenticate code on this system to authenticate any addon driver (most likely not advisable for the Microsoft UEFI CA)"`
33+
PermitNoSecureBoot bool `long:"permit-no-secure-boot" description:"Permit profiles that don't include the secure boot policy"`
34+
NoDiscreteTPMResetMitigation bool `long:"no-discrete-tpm-reset-mitigation" description:"Disable mitigations against discrete TPM reset attacks where appropriate"`
3635
} `group:"PCR profile options"`
3736

3837
Action preinstall.Action `long:"action" description:"What action to run"`
@@ -101,13 +100,10 @@ func run() error {
101100
pcrFlags |= preinstall.PCRProfileOptionMostSecure
102101
}
103102
if opts.Profile.TrustCAsForBootCode {
104-
pcrFlags |= preinstall.PCRProfileOptionTrustCAsForBootCode
103+
pcrFlags |= preinstall.PCRProfileOptionTrustSecureBootAuthoritiesForBootCode
105104
}
106105
if opts.Profile.TrustCAsForAddonDrivers {
107-
pcrFlags |= preinstall.PCRProfileOptionTrustCAsForAddonDrivers
108-
}
109-
if opts.Profile.DistrustVARSuppliedNonHostCode {
110-
pcrFlags |= preinstall.PCRProfileOptionDistrustVARSuppliedNonHostCode
106+
pcrFlags |= preinstall.PCRProfileOptionTrustSecureBootAuthoritiesForAddonDrivers
111107
}
112108
if opts.Profile.PermitNoSecureBoot {
113109
pcrFlags |= preinstall.PCRProfileOptionPermitNoSecureBootPolicyProfile

efi/preinstall/checks_context_test.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,12 @@ C7E003CB
13411341
func (s *runChecksContextSuite) TestRunGoodInvalidPCR2ValueWhenOmittedFromPCRProfileOpts(c *C) {
13421342
// Test a good case on a fTPM where the value of PCR2 is inconsistent
13431343
// with the log, but PCR2 isn't required for the specified profile options.
1344+
restore := MockKnownCAs(AuthorityTrustDataSet{
1345+
{internal_efi.MSUefiCA2011, AuthorityTrustDrivers},
1346+
{internal_efi.MSUefiCA2023, 0},
1347+
})
1348+
defer restore()
1349+
13441350
meiAttrs := map[string][]byte{
13451351
"fw_ver": []byte(`0:16.1.27.2176
13461352
0:16.1.27.2176
@@ -1395,7 +1401,7 @@ C7E003CB
13951401
&mockImage{contents: []byte("mock grub executable"), digest: testutil.DecodeHexString(c, "d5a9780e9f6a43c2e53fe9fda547be77f7783f31aea8013783242b040ff21dc0")},
13961402
&mockImage{contents: []byte("mock kernel executable"), digest: testutil.DecodeHexString(c, "2ddfbd91fa1698b0d133c38ba90dbba76c9e08371ff83d03b5fb4c2e56d7e81f")},
13971403
},
1398-
profileOpts: PCRProfileOptionTrustCAsForAddonDrivers,
1404+
profileOpts: PCRProfileOptionTrustSecureBootAuthoritiesForAddonDrivers,
13991405
prepare: func(_ int) {
14001406
_, err := s.TPM.PCREvent(s.TPM.PCRHandleContext(2), []byte("foo"), nil)
14011407
c.Check(err, IsNil)
@@ -1419,6 +1425,12 @@ C7E003CB
14191425
func (s *runChecksContextSuite) TestRunGoodInvalidPCR4ValueWhenOmittedFromPCRProfileOpts(c *C) {
14201426
// Test a good case on a fTPM where the value of PCR4 is inconsistent
14211427
// with the log, but PCR4 isn't required for the specified profile options.
1428+
restore := MockKnownCAs(AuthorityTrustDataSet{
1429+
{internal_efi.MSUefiCA2011, AuthorityTrustBootCode},
1430+
{internal_efi.MSUefiCA2023, 0},
1431+
})
1432+
defer restore()
1433+
14221434
meiAttrs := map[string][]byte{
14231435
"fw_ver": []byte(`0:16.1.27.2176
14241436
0:16.1.27.2176
@@ -1473,7 +1485,7 @@ C7E003CB
14731485
&mockImage{contents: []byte("mock grub executable"), digest: testutil.DecodeHexString(c, "d5a9780e9f6a43c2e53fe9fda547be77f7783f31aea8013783242b040ff21dc0")},
14741486
&mockImage{contents: []byte("mock kernel executable"), digest: testutil.DecodeHexString(c, "2ddfbd91fa1698b0d133c38ba90dbba76c9e08371ff83d03b5fb4c2e56d7e81f")},
14751487
},
1476-
profileOpts: PCRProfileOptionTrustCAsForBootCode,
1488+
profileOpts: PCRProfileOptionTrustSecureBootAuthoritiesForBootCode,
14771489
prepare: func(_ int) {
14781490
_, err := s.TPM.PCREvent(s.TPM.PCRHandleContext(4), []byte("foo"), nil)
14791491
c.Check(err, IsNil)
@@ -2102,6 +2114,12 @@ C7E003CB
21022114
func (s *runChecksContextSuite) TestRunGoodNoBootManagerCodeProfileSupportWhenOmittedFromPCRProfileOpts(c *C) {
21032115
// Test a good case on a fTPM where the launch digests in the log for OS components
21042116
// are invalid, but the profile options permits the omission of PCR4.
2117+
restore := MockKnownCAs(AuthorityTrustDataSet{
2118+
{internal_efi.MSUefiCA2011, AuthorityTrustBootCode},
2119+
{internal_efi.MSUefiCA2023, 0},
2120+
})
2121+
defer restore()
2122+
21052123
meiAttrs := map[string][]byte{
21062124
"fw_ver": []byte(`0:16.1.27.2176
21072125
0:16.1.27.2176
@@ -2161,7 +2179,7 @@ C7E003CB
21612179
&mockImage{contents: []byte("mock grub executable"), digest: testutil.DecodeHexString(c, "80fd5a9364df79953369758a419f7cb167201cf580160b91f837aad455c55bcd")},
21622180
&mockImage{contents: []byte("mock kernel executable"), digest: testutil.DecodeHexString(c, "c49a23d0315fa446781686de3ee5c04288078911c89c39618c6a54d5fedddf44")},
21632181
},
2164-
profileOpts: PCRProfileOptionTrustCAsForBootCode,
2182+
profileOpts: PCRProfileOptionTrustSecureBootAuthoritiesForBootCode,
21652183
actions: []actionAndArgs{{action: ActionNone}},
21662184
expectedPcrAlg: tpm2.HashAlgorithmSHA256,
21672185
expectedUsedSecureBootCAs: []*X509CertificateID{NewX509CertificateID(testutil.ParseCertificate(c, msUefiCACert))},

efi/preinstall/export_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
)
3232

3333
type (
34-
AuthorityTrust = authorityTrust
34+
AuthorityTrustFlags = authorityTrustFlags
3535
AuthorityTrustData = authorityTrustData
3636
AuthorityTrustDataSet = authorityTrustDataSet
3737
BootManagerCodeResult = bootManagerCodeResult

0 commit comments

Comments
 (0)