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

secboot: use uuid of luks2 instead of partition #14400

Conversation

valentindavid
Copy link
Contributor

@valentindavid valentindavid commented Aug 21, 2024

by-partuuid does not make much sense because it uselessly assumes that it is a partition. Conceptually we should not care about it. It also makes the resolution more complex as we need to fetch information about the device which we do not really need at this point.

It is more common to resolve by filesystem UUID than part UUID. For instance cryptsetup accepts path as UUID=deadbeef-dead-dead-dead-deaddeafbeef. But it does not accept this kind of syntax for partitions.

We will also need to register the old paths with something like canonical/secboot#331

@valentindavid valentindavid added FDE Manager Pull requests that target FDE manager branch Run nested The PR also runs tests inluded in nested suite labels Aug 21, 2024
@valentindavid valentindavid reopened this Aug 21, 2024
@valentindavid valentindavid force-pushed the valentindavid/use-luks2-uuid branch 5 times, most recently from c9cb79d to 6491f5f Compare September 20, 2024 11:57
@valentindavid valentindavid marked this pull request as ready for review September 20, 2024 14:15
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.

Small suggestion about a possible name tweak

func PartitionUUIDFromMountPoint(mountpoint string, opts *Options) (string, error) {
var dmUUIDRe = regexp.MustCompile(`^CRYPT-(?P<type>.*)-(?P<uuid1>[0-9a-f]{8})(?P<uuid2>[0-9a-f]{4})(?P<uuid3>[0-9a-f]{4})(?P<uuid4>[0-9a-f]{4})(?P<uuid5>[0-9a-f]{12})-(?P<name>.*)$`)

func DmCryptUUIDFromMountPoint(mountpoint string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe MapperCryptUUID... or DeviceMapper.., or simply DMCrypt... ?

@@ -963,41 +964,40 @@ func AllPhysicalDisks() ([]Disk, error) {
return disks, nil
}

// PartitionUUIDFromMountPoint returns the UUID of the partition which is a
// source of a given mount point.
func PartitionUUIDFromMountPoint(mountpoint string, opts *Options) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to have been used in non-encryption contexts, so the change should be fine

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.

Some minor comments, but besides that I think that the PR/commit needs a more detailed explanation on why we want to switch to using filesystem/dm-crypt uuids instead of the partitions uuids.

func PartitionUUIDFromMountPoint(mountpoint string, opts *Options) (string, error) {
var dmUUIDRe = regexp.MustCompile(`^CRYPT-(?P<type>.*)-(?P<uuid1>[0-9a-f]{8})(?P<uuid2>[0-9a-f]{4})(?P<uuid3>[0-9a-f]{4})(?P<uuid4>[0-9a-f]{4})(?P<uuid5>[0-9a-f]{12})-(?P<name>.*)$`)

func DmCryptUUIDFromMountPoint(mountpoint string) (string, error) {

Choose a reason for hiding this comment

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

This would need a function description

}

// PartitionUUID returns the UUID of a given partition
func PartitionUUID(node string) (string, error) {
func FilesystemUUID(node string) (string, error) {

Choose a reason for hiding this comment

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

This would need tests in the package, and a description

Copy link
Collaborator

Choose a reason for hiding this comment

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

still doesn't seem to have tests

Choose a reason for hiding this comment

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

Wouldn't this need a definition of the new package functions?

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 have opened #14557 to enable the tests.

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 was expecting a failure but nothing happened.

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 questions/comments

if err != nil {
return res, fmt.Errorf("error enumerating partitions for disk to find unencrypted device %q: %v", name, err)
}
}

partDevice := filepath.Join("/dev/disk/by-partuuid", partUUID)
partDevice := filepath.Join("/dev/disk/by-partuuid", part.PartitionUUID)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it intentional to keep using by-partuuid 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.

That requires more changes in snap-bootstrap. For now it is not needed. The main point here is to simplify everywhere where we need to get keys from keyring.

We will probably have to refactor snap-bootstrap to match primary keys, and we can do that refactoring in the same time.

}

// PartitionUUID returns the UUID of a given partition
func PartitionUUID(node string) (string, error) {
func FilesystemUUID(node string) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

still doesn't seem to have tests

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, thanks for the changes and clarifications

`by-partuuid` does not make much sense because it uselessly assumes
that it is a partition. Conceptually we should not care about it.  It
also makes the resolution more complex as we need to fetch information
about the device which we do not really need at this point.

It is more common to resolve by filesystem UUID than part UUID. For
instance cryptsetup accepts path as
`UUID=deadbeef-dead-dead-dead-deaddeafbeef`. But it does not accept
this kind of syntax for partitions.
@valentindavid
Copy link
Contributor Author

tests/nested/manual/core-factory-reset-new-secboot will fail until we have canonical/secboot#331

@pedronis pedronis merged commit 663bc3b into canonical:fde-manager-features Oct 2, 2024
42 of 52 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 The PR also runs tests inluded in nested suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants