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

go.mod: update secboot to 42c7ea9715b3 #14253

Conversation

valentindavid
Copy link
Contributor

@valentindavid valentindavid commented Jul 25, 2024

Also update github.com/mvo5/goconfigparser to latest.

This commit of secboot is right before the introduction of new key data format.

@valentindavid valentindavid force-pushed the valentindavid/secboot-update-part-1 branch 3 times, most recently from 416ca44 to 742eb61 Compare July 25, 2024 12:47
@valentindavid
Copy link
Contributor Author

This is taken from #13278 (which is from #13210)

@valentindavid valentindavid force-pushed the valentindavid/secboot-update-part-1 branch 2 times, most recently from 6179daa to ff9418e Compare July 25, 2024 15:00
@valentindavid valentindavid added the Run nested The PR also runs tests inluded in nested suite label Jul 25, 2024
@valentindavid valentindavid reopened this Jul 25, 2024
@valentindavid valentindavid added the FDE Manager Pull requests that target FDE manager branch label Jul 26, 2024
@valentindavid
Copy link
Contributor Author

This depends on #14252

@valentindavid valentindavid marked this pull request as ready for review July 26, 2024 11:02
@valentindavid valentindavid force-pushed the valentindavid/secboot-update-part-1 branch from ff9418e to 445c1d8 Compare July 26, 2024 12:31
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 pass, some questions and comments, maybe Chris should also take a look at this?

if err := sbActivateVolumeWithRecoveryKey(name, device, nil, &options); err != nil {
authRequestor, err := newAuthRequestor()
if err != nil {
return fmt.Errorf("cannot build an auth requestor: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

sounds like this should be an i"nternal error:" ?

@@ -280,8 +286,14 @@ func unlockEncryptedPartitionWithSealedKey(mapperName, sourceDevice, keyfile str
return NotUnlocked, fmt.Errorf("cannot read key data: %v", err)
}
options := activateVolOpts(allowRecovery)
options.Model = sb.SkipSnapModelCheck
// ignoring model checker as it doesn't work with tpm "legacy" platform key data
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this comment go before the previous line? or should this comment be changed instead?

var handle []byte
if keySetup.Handle == nil {
// this will reach fde-reveal-key as null but should be ok
handle = []byte("null")
Copy link
Collaborator

Choose a reason for hiding this comment

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

have we tested if this work or is not needed anymore? I suppose this is about trying things with the OptEE hooks we have

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original commit: 9807656

secboot: secboot.sb.NewKeyData() now marhals the handle internally

The old version of secboot.sb.NewKeyData() was expecting a handle
in json encoded form. However the new code is now doing the
marshalling itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the future PRs, the code will be different. We will return the handle from a method implementing KeyProtector.ProtectKey.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the spike branch, something similar is also done there. It has to do with dereference. So for sure the code is tested with nil, since I had to deal with it.

secboot/secboot_hooks.go Show resolved Hide resolved
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, couple of comments

}
if !ok {
return res, fmt.Errorf("cannot unlock volume: model %s/%s not authorized", model.BrandID(), model.Model())
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

there'a defer here that can also go away now as there's no code that can set error in the rest of the function anymore?

secboot/secboot_sb_test.go Outdated Show resolved Hide resolved
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


return kd, nil
})
defer restore()

restore = secboot.MockSbActivateVolumeWithKeyData(func(volumeName, sourceDevicePath string, authRequestor sb.AuthRequestor, kdf sb.KDF, options *sb.ActivateVolumeOptions, keys ...*sb.KeyData) error {

c.Assert(volumeName, Equals, "name-"+randomUUID)
c.Assert(sourceDevicePath, Equals, devicePath)
c.Assert(keys, HasLen, 1)
c.Assert(keys[0], NotNil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we might leave this one out now?

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 can remove it.

Copy link
Member

@alfonsosanchezbeato alfonsosanchezbeato left a comment

Choose a reason for hiding this comment

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

LGTM, small nitpick below

Comment on lines 175 to 180
options := activateVolOpts(opts.AllowRecoveryKey)
modChecker, err := sbActivateVolumeWithKeyData(mapperName, sourceDevice, keyData, options)
options.Model = model

Choose a reason for hiding this comment

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

nitpick: maybe it would make sense if activateVolOpts() accepts the model as input so it creates ActivateVolumeOptions with it already instead of assigning a line later. As this is done in the 2 cases where this function is called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, since we will remove this one and call SetModel instead, I prefer not to change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe this is not completely true. For the old keys will still need this to be set. But we will possibly we will only add it when we have old key files and not when we have key slot token data. Then we can set it to nil to make it force to fail if it finds old data. I will add a FIXME here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also both unlock for FDE hook and tpm will be joined in the same function at some point.

Copy link
Contributor

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@chrisccoulson chrisccoulson left a comment

Choose a reason for hiding this comment

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

This looks ok to me - I've left a few minor comments

return res, fmt.Errorf("internal error: cannot build an auth requestor: %v", err)
}

err = sbActivateVolumeWithKeyData(mapperName, sourceDevice, authRequestor, sb.Argon2iKDF(), options, keyData)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work if you pass nil instead of sb.Argon2iKDF? The intention here is that this API would always be executed remotely in a short-lived helper process because otherwise there's a need to force a GC between invocations. As there's technically no passphrase support right now, nothing should call this anyway.

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 parameter is removed in the next queued up PR. But I can change that and see if the tests are still working

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unlocking failed with:

[    4.522158] snap-bootstrap[195]: 2024/08/22 12:44:12.816188 main.go:63: execution error: cannot unlock encrypted partition: nil kdf

@@ -38,8 +38,7 @@ import (
)

var (
sbInitializeLUKS2Container = sb.InitializeLUKS2Container
sbAddRecoveryKeyToLUKS2Container = sb.AddRecoveryKeyToLUKS2Container
Copy link
Contributor

Choose a reason for hiding this comment

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

Did nothing call this before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was removed in 3988a93 which was in PR #11715

This mini key manager has a copy of the internal code of secboot.

I could make a separate commit of removing this and the mock.

// FIXME: consider setting it in activateVolOpts if we keep
// this function separate from the tpm one for key data in
// files. Otherwise we should only set it if we provide key
// data generation 1.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to actually remove the Model field in secboot given that future versions of snap-bootstrap are going to call bootscope.SetModel. We should probably obtain the model from there for existing keys rather than have a separate option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be great.

@valentindavid valentindavid force-pushed the valentindavid/secboot-update-part-1 branch from 6cc667c to 1b78a4a Compare August 22, 2024 09:10
@valentindavid valentindavid force-pushed the valentindavid/secboot-update-part-1 branch 3 times, most recently from 3f7f246 to d20a337 Compare August 23, 2024 09:49
@github-actions github-actions bot added the Run Nested -auto- Label automatically added in case nested tests need to be executed label Aug 23, 2024
@valentindavid valentindavid force-pushed the valentindavid/secboot-update-part-1 branch from d20a337 to bd90f5b Compare August 23, 2024 11:09
Also update github.com/mvo5/goconfigparser to latest.
@valentindavid valentindavid force-pushed the valentindavid/secboot-update-part-1 branch from bd90f5b to 89a01e9 Compare August 23, 2024 13:12
@pedronis pedronis merged commit 1e0707b into canonical:fde-manager-features Aug 26, 2024
46 of 51 checks passed
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.

5 participants