-
Notifications
You must be signed in to change notification settings - Fork 17
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: Make use of the grub's prefix for detection #268
efi: Make use of the grub's prefix for detection #268
Conversation
73d2efa
to
3a7fd0b
Compare
Grub detection will be fixed separately in canonical#268
40fbab3
to
12a3c33
Compare
…aries efi: Add support for shim binaries used during snapd spread tests. Snapd re-signs production shim and grub binaries (previously signed by Microsoft and Canonical) with a snakeoil key, so recognize this as part of the Microsoft hierarchy during testing. Some tests also recompile our patched shim v15, which we use an image digest match to recognize it as having patches backported from 15.2. Recognize any shim v15 signed with the snakeoil key as being supported during testing. #268 will contain changes required for grub.
Avoid relying on the signature in order to detect an Ubuntu production grub binary for binaries without a SBAT section, as this breaks test cases in snapd where grub is re-signed. Instead, obtain the prefix from the "mods" section (which is set to "/EFI/ubuntu" in Ubuntu).
12a3c33
to
8cace2b
Compare
3ab72af
to
421f90a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, couple small comments and questions
case pe.IMAGE_FILE_MACHINE_ARM, pe.IMAGE_FILE_MACHINE_I386, pe.IMAGE_FILE_MACHINE_RISCV32: | ||
var info grubModuleInfo32 | ||
if err := binary.Read(section, binary.LittleEndian, &info); err != nil { | ||
return nil, fmt.Errorf("cannot obtain modules info: %w", err) | ||
} | ||
if info.Magic != grubModuleMagic { | ||
return nil, errors.New("invalid module magic") | ||
} | ||
if info.Size < info.Offset { | ||
return nil, errors.New("invalid modules size") | ||
} | ||
r = io.NewSectionReader(section, int64(info.Offset), int64(info.Size)-int64(info.Offset)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this case is not tested
@@ -163,7 +163,7 @@ func makeMicrosoftUEFICASecureBootNamespaceRules() *secureBootNamespaceRules { | |||
), | |||
imageMatchesAll( | |||
imageSectionExists("mods"), | |||
imageSignedByOrganization("Canonical Ltd."), | |||
grubHasPrefix("/EFI/ubuntu"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still need all the changes from the snakeoil PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor thing.
efi/grub.go
Outdated
if info.Magic != grubModuleMagic { | ||
return nil, errors.New("invalid modules magic") | ||
} | ||
if info.Size > math.MaxInt64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info.Offset
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was addressed with 421f90a
2b485a2
to
8e2219e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
Avoid relying on the signature in order to detect an Ubuntu production
grub binary for binaries without a SBAT section, as this breaks test cases
in snapd where grub is re-signed. Instead, obtain the prefix from the
"mods" section (which is set to "/EFI/ubuntu" in Ubuntu).