Skip to content
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.

VerifiedBooter - NOT FOR MERGE #28

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

VerifiedBooter - NOT FOR MERGE #28

wants to merge 18 commits into from

Conversation

zaolin
Copy link
Collaborator

@zaolin zaolin commented Jun 11, 2018

  • Adds verifiedbooter
  • Allows booting in secure, measured or both modes.
  • Makes use of boot config image format.
  • Kexec support
  • Seeds /dev/random for more boot entropy.

@zaolin zaolin requested a review from insomniacslk June 11, 2018 18:22
@zaolin zaolin self-assigned this Jun 11, 2018
@zaolin zaolin added the enhancement New feature or request label Jun 11, 2018
@insomniacslk insomniacslk changed the title WIP: VerifiedBooter Implemented VerifiedBooter Jun 14, 2018
Copy link
Collaborator

@insomniacslk insomniacslk left a comment

Choose a reason for hiding this comment

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

I haven't actually reviewed pkg/verifiedbooter.go, just verifiedboot/main.go . That's because I'd split this PR in two parts, one where we implement the verifiedbooter command, and one where we implement the verified booting logic on top. I need to think more on how to plug verified booting on top of local/net booting (wrapper? embedding?) so let's speed up this PR and let's just do the verifiedboot command.

if *doDebug {
debug = log.Printf
recoverer = recovery.SecureRecoverer{
Reboot: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find counterintuitive that rebooting is a function of verbosity. I would leave Reboot: true in all cases, and add a -reboot-on-error flag that will flip this value.

Also please move the recoverer initialization outside of the if *doDebug check. Something like this:

recoverer = recovery.SecureRecoverer{
    Reboot: *doRebootOnError,
    Sync: false,
    Debug: *doDebug,
}
if *doDebug {
    debug = log.Printf
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

partly done, let's fix that finally afterwards


// Initialize random seeding
err := rng.UpdateLinuxRandomness(recoverer)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

just one line is enough:

if err := rng.UpdateLinuxRandomness(recoverer); err != nil {
    ...
}

}

// Initialize the TPM
if *bootMode == booter.BootModeMeasured || *bootMode == booter.BootModeBoth {
Copy link
Collaborator

Choose a reason for hiding this comment

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

In cases like this strings can be dangerous and inefficient to carry around, and they should just be a convention for a main package, not for a library (they are defined in pkg/booter). I would rather use a iota (similar, but not equal to an enum), or a bitmask, or even a lightweight struct with two methods, IsVerified and IsMeasured that will check the enum/bitmask (but this is probably overkill)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay let me think about it. Follow up

flag.Parse()
log.Print(banner)

var recoverer recovery.Recoverer
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 time to rename Recoverer to RecoveryHandler? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah

}

// Check FIT image existence and read it into memory
fitImage := mountPath + *fitFilePath
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should use path.Join too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

// Verify signature of FIT image on device
if *bootMode == booter.BootModeVerified || *bootMode == booter.BootModeBoth {
// Read fit image signature into memory
fitImageSignature := mountPath + *fitFilePath + SignatureFileExt
Copy link
Collaborator

Choose a reason for hiding this comment

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

path.Join here too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

BootMode string `json:"boot_mode"`
DeviceUUID string `json:"device_uuid"`
FitFile string `json:"fit_file"`
Debug string `json:"debug"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be bool. The JSON parser will take care of setting this appropriately for you

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -78,91 +78,85 @@ func main() {
flag.Parse()
log.Print(banner)

var recoverer recovery.Recoverer
var RecoveryHandler recovery.Recoverer
Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually meant to change the name in the recovery package

Copy link
Collaborator

@insomniacslk insomniacslk left a comment

Choose a reason for hiding this comment

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

Will review the rest on Monday

return nil, fmt.Errorf("False boot mode for VerifiedBooter: %s", nb.BootMode)
}

if _, err := uuid.FromString(nb.DeviceUUID); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about using Fiano's uuid package? I wrote that code originally, and it's equivalent in terms of features that we need, plus we have control over. Find it at https://github.com/linuxboot/fiano/tree/master/uuid .

@zaolin zaolin changed the title Implemented VerifiedBooter Implemented VerifiedBooter [4/4] Jun 30, 2018
@zaolin zaolin changed the title Implemented VerifiedBooter [4/4] Implemented VerifiedBooter [3/3] Jul 4, 2018
@zaolin zaolin changed the title Implemented VerifiedBooter [3/3] VerifiedBooter [3/3] Jul 5, 2018
@zaolin zaolin changed the title VerifiedBooter [3/3] VerifiedBooter - NOT FOR MERGE Jul 6, 2018
@codecov-io
Copy link

codecov-io commented Jul 9, 2018

Codecov Report

Merging #28 into master will increase coverage by 21%.
The diff coverage is 54.94%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master      #28    +/-   ##
========================================
+ Coverage   18.64%   39.64%   +21%     
========================================
  Files          17       11     -6     
  Lines         751      570   -181     
========================================
+ Hits          140      226    +86     
+ Misses        591      291   -300     
- Partials       20       53    +33
Impacted Files Coverage Δ
pkg/booter/bootentry.go 94.87% <100%> (+0.93%) ⬆️
pkg/bootconfig/parser.go 43.56% <43.56%> (ø)
pkg/booter/verifiedbooter.go 47.82% <47.82%> (ø)
pkg/crypto/ed25519.go 74% <74%> (ø)
localboot/bootconfig.go
pkg/recovery/securerecoverer.go
localboot/main.go
pkg/rng/entropy.go
pkg/recovery/permissiverecoverer.go
localboot/grub.go
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b3658e...2e5ee26. Read the comment docs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants