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

overlord/fdestate: keep FDE state up to date #14516

Open
wants to merge 9 commits into
base: fde-manager-features
Choose a base branch
from

Conversation

valentindavid
Copy link
Contributor

@valentindavid valentindavid commented Sep 17, 2024

Ensure() initializes the empty profiles, and reseal updates them.

This is on top of #14400

@valentindavid valentindavid added the FDE Manager Pull requests that target FDE manager branch label Sep 17, 2024
@github-actions github-actions bot added the Run Nested -auto- Label automatically added in case nested tests need to be executed label Sep 17, 2024
@valentindavid valentindavid changed the title overlord/fdestate: Keep FDE state up to date overlord/fdestate: keep FDE state up to date Sep 17, 2024
@valentindavid valentindavid force-pushed the valentindavid/sync-fde-state branch 12 times, most recently from 728ff63 to 14d22b2 Compare September 20, 2024 14:23
}
}

type KeyDigest struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might be a type that should be handled in secboot. And we just use json.RawMessage for it.

Comment on lines 61 to 70
if !locked {
m.state.Lock()
defer m.state.Unlock()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not elegant. But I am not sure how to handle it correctly. We do resealing sometimes locked, sometimes not.

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 know where is it called with the state really already unlocked?

Comment on lines 188 to 214
dataUUID, dataErr := disksDmCryptUUIDFromMountPoint(dirs.GlobalRootDir)
saveUUID, saveErr := disksDmCryptUUIDFromMountPoint(dirs.SnapSaveDir)
if errors.Is(saveErr, &disks.ErrMountPointNotFound{}) {
// TODO: do we need to care about old cases where there is no save partition?
return nil
}

if errors.Is(dataErr, disks.ErrNoDmUUID) && errors.Is(saveErr, disks.ErrNoDmUUID) {
return nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should look at the sealing method with device.SealedKeysMethod instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will make it a TODO for now.

@valentindavid valentindavid marked this pull request as ready for review September 20, 2024 14:46
Comment on lines 54 to 56
m.state.Lock()
defer m.state.Unlock()
return ensureState(m.state)
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's a bit unclear if this will really run before any reseal op? maybe it would be better to use StartUp for this?

@@ -134,7 +136,7 @@ type SealKeysWithFDESetupHookParams struct {

type ResealKeysParams struct {
// The snap model parameters
ModelParams []*SealKeyModelParams
PCRProfile json.RawMessage
Copy link
Collaborator

Choose a reason for hiding this comment

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

we probably want to use a named type for this for clarity

@valentindavid valentindavid added the Run nested The PR also runs tests inluded in nested suite label Oct 1, 2024
@valentindavid valentindavid reopened this Oct 1, 2024
Comment on lines +65 to 78
func (m *FDEManager) resealKeyForBootChains(unlocker boot.Unlocker, method device.SealingMethod, rootdir string, params *boot.ResealKeyForBootChainsParams, expectReseal bool) error {
doUpdate := func(role string, containerRole string, bootModes []string, models []secboot.ModelForSealing, tpmPCRProfile []byte) error {
if unlocker != nil {
m.state.Lock()
defer m.state.Unlock()
}
return updateParameters(m.state, role, containerRole, bootModes, models, tpmPCRProfile)
}
if unlocker != nil {
locker := unlocker()
defer locker()
}
return backend.ResealKeyForBootChains(doUpdate, method, rootdir, params, expectReseal)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is not covered by tests in this package, but still covered by tests from overlord/managers_test.go. I wonder if we should add tests in the current package. Or move them.

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.

drive-by comment

@@ -628,6 +625,14 @@ func buildPCRProtectionProfile(modelParams []*SealKeyModelParams) (*sb_tpm2.PCRP
return pcrProfile, nil
}

func BuildPCRProtectionProfile(modelParams []*SealKeyModelParams) (SerializedPCRProfile, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this needs a doc comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FDE Manager Pull requests that target FDE manager branch Run Nested -auto- Label automatically added in case nested tests need to be executed Run nested The PR also runs tests inluded in nested suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants