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

efi: AddPCRProfile support for PCRs 4 and 7 profiles #249

Conversation

chrisccoulson
Copy link
Collaborator

@chrisccoulson chrisccoulson commented Jun 5, 2023

This adds the remaining missing pieces so that AddPCRProfile can
generate boot manager code and secure boot policy profiles. This will
replace the existing AddBootManagerProfile and AddSecureBootPolicyProfile
APIs.

@chrisccoulson chrisccoulson force-pushed the efi-add-pcr-4-and-7-profile-generation branch 5 times, most recently from d0335f8 to fdb5796 Compare June 9, 2023 11:53
@chrisccoulson chrisccoulson force-pushed the efi-add-pcr-4-and-7-profile-generation branch from fdb5796 to 1ba7336 Compare August 1, 2023 17:14
@chrisccoulson chrisccoulson force-pushed the efi-add-pcr-4-and-7-profile-generation branch from 1ba7336 to e4c2c15 Compare August 15, 2023 14:43
This adds the remaining missing pieces so that AddPCRProfile can
generate boot manager code and secure boot policy profiles. This will
replace the existing AddBootManagerProfile and AddSecureBootPolicyProfile
APIs.
@chrisccoulson chrisccoulson force-pushed the efi-add-pcr-4-and-7-profile-generation branch from e4c2c15 to 94bdca6 Compare September 4, 2023 22:22
@chrisccoulson chrisccoulson marked this pull request as ready for review September 5, 2023 09:32
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

did a first pass, some questions

efi/image_rules_defs.go Show resolved Hide resolved
signatureDBUpdateNoFirmwareQuirk,
signatureDBUpdateFirmwareDedupIgnoresOwner} {
// create branch by copying the root varBranch
branch := *root
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm probably missing something, how does the change propagate out of this function if below we operate on a copy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The copy maintains a copy of updates, and then each call to WriteVar propagates those updates to rootVarsCollector via its registerUpdates callback.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see maybe the comment should be:

// create a branch per quirk by copying the root varBranch

Copy link
Collaborator

Choose a reason for hiding this comment

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

for a moment I was confused and thought that root.updates was a slice, that is not case, otherwise the shallow copy would not be safe, as append to the same slice again can produce confusing results depending on the allocation history of the slice. I don't think we have code here that shallow copy structs with slices in them?

}

func (h *ubuntuCoreUKILoadHandler) MeasureImageStart(_ pcrBranchContext) error {
// TODO: Add stuff that the kernel measures here
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need to fix this before things can be used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It doesn't - snapd can continue to use the AddSystemdStubProfile API in addition to this one, although that will be moved here in a follow up. That will be a fairly minor change though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe it's a good idea to leave a comment also about that:

// for now clients can continue using AddSystemdStubProfile

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

thanks, some small final comments

signatureDBUpdateNoFirmwareQuirk,
signatureDBUpdateFirmwareDedupIgnoresOwner} {
// create branch by copying the root varBranch
branch := *root
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see maybe the comment should be:

// create a branch per quirk by copying the root varBranch

}

func (h *ubuntuCoreUKILoadHandler) MeasureImageStart(_ pcrBranchContext) error {
// TODO: Add stuff that the kernel measures here
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe it's a good idea to leave a comment also about that:

// for now clients can continue using AddSystemdStubProfile

signatureDBUpdateNoFirmwareQuirk,
signatureDBUpdateFirmwareDedupIgnoresOwner} {
// create branch by copying the root varBranch
branch := *root
Copy link
Collaborator

Choose a reason for hiding this comment

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

for a moment I was confused and thought that root.updates was a slice, that is not case, otherwise the shallow copy would not be safe, as append to the same slice again can produce confusing results depending on the allocation history of the slice. I don't think we have code here that shallow copy structs with slices in them?

@chrisccoulson chrisccoulson merged commit 5e0b0cb into snapcore:master Sep 13, 2023
1 check passed
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.

None yet

2 participants