-
Notifications
You must be signed in to change notification settings - Fork 22
efi/secureboot.go: automatically detect deployedmode variable measurement #546
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
Closed
valentindavid
wants to merge
1
commit into
canonical:master
from
valentindavid:valentindavid/automatic-user-mode
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -320,7 +320,8 @@ const ( | |
| // includeSecureBootUserModeParamKey is used to indicate that user mode related | ||
| // measurements should be included in the secure boot PCR profile if the system is | ||
| // in user mode. | ||
| includeSecureBootUserModeParamKey = "include_secure_boot_user_mode" | ||
| includeSecureBootUserModeParamKey = "include_secure_boot_user_mode" | ||
| autoIncludeSecureBootUserModeParamKey = "auto_include_secure_boot_user_mode" | ||
| ) | ||
|
|
||
| type allowSecureBootUserModeOption struct{} | ||
|
|
@@ -343,6 +344,26 @@ func (o allowSecureBootUserModeOption) ApplyOptionTo(visitor internal_efi.PCRPro | |
| return nil | ||
| } | ||
|
|
||
| type autoAllowSecureBootUserModeOption struct{} | ||
|
|
||
| func (o autoAllowSecureBootUserModeOption) ApplyOptionTo(visitor internal_efi.PCRProfileOptionVisitor) error { | ||
| visitor.AddImageLoadParams(func(params ...loadParams) []loadParams { | ||
| var out []loadParams | ||
| for _, v := range []bool{false, true} { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to set both to true and false, in case the firmware behavior changes? |
||
| var newParams []loadParams | ||
| for _, p := range params { | ||
| newParams = append(newParams, p.Clone()) | ||
| } | ||
| for _, p := range newParams { | ||
| p[autoIncludeSecureBootUserModeParamKey] = v | ||
| } | ||
| out = append(out, newParams...) | ||
| } | ||
| return out | ||
| }) | ||
| return nil | ||
| } | ||
|
|
||
| // WithAllowSecureBootUserMode can be supplied to AddPCRProfile to allow for secure boot | ||
| // PCR profiles that support user mode to be generated on systems where user mode is | ||
| // currently enabled. This is opt-in to ensure that a system that was originally in | ||
|
|
@@ -355,3 +376,15 @@ func (o allowSecureBootUserModeOption) ApplyOptionTo(visitor internal_efi.PCRPro | |
| func WithAllowSecureBootUserMode() PCRProfileOption { | ||
| return allowSecureBootUserModeOption{} | ||
| } | ||
|
|
||
| // WithAutoAllowSecureBootUserMode is like WithAllowSecureBootUserMode but will | ||
| // only expect measurements if the event log contains them. | ||
| // The variables still need to also be defined. | ||
| // For Ubuntu Core users there are hardware that define AuditMode/DeployedMode variables | ||
| // and still fail to measure that in PCR7. So we need to detect that hardware from the event | ||
| // log. | ||
| // | ||
| // This option should only be used by Ubuntu Core. | ||
| func WithAutoAllowSecureBootUserMode() PCRProfileOption { | ||
| return autoAllowSecureBootUserModeOption{} | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's enough to check one of the two vars?