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

Loader protocol (with Device Path resolution support) #656

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

kukrimate
Copy link

This rebases the current loader protocol work on main and adds support for loading executables if only a device path is provided. Currently the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and EFI_LOAD_FILE2_PROTOCOL are supported, which should be sufficient for most users.

@kukrimate kukrimate force-pushed the loader-protocol branch 3 times, most recently from d57be0b to b997ca7 Compare April 18, 2024 10:54
loader-proto.c Outdated Show resolved Hide resolved
loader-proto.c Show resolved Hide resolved
ardbiesheuvel and others added 8 commits October 22, 2024 08:38
Define a new protocol for loading and starting images, encapsulating
shim's PE loading facilities and verification/authentication against the
same set of certificates that shim_lock::verify() authenticates against.

This removes the need for loaders like GRUB to implement their own PE
loader in order to be able to invoke loaded images as PE applications,
rather than implementing a bespoke OS dependent handover protocol (e.g.,
invoke Linux via its EFI stub)

Signed-off-by: Ard Biesheuvel <[email protected]>
Currently the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and EFI_LOAD_FILE2_PROTOCOL
are supported.

Signed-off-by: Mate Kukri <[email protected]>
This will bring SBAT enforcement in-line with the shim_lock protocol.

Signed-off-by: Mate Kukri <[email protected]>
…in_protocol

This isn't desirable when GRUB has control of the screen, and would mess
its content up.

Signed-off-by: Mate Kukri <[email protected]>
@kukrimate kukrimate changed the title [RFC] Loader protocol with support for device path resolution and loading executables Loader protocol (with Device Path resolution support) Oct 22, 2024
@vathpela vathpela added this to the shim 16 milestone Nov 19, 2024
include/lf2.h Show resolved Hide resolved
/* get file size */
bprop->size = 0; /* this shouldn't be read when Buffer=NULL but better be safe */
status = lf2->LoadFile(lf2, bprop->dp, /*BootPolicy=*/false, &bprop->size, NULL);
/* NOTE: the spec is somewhat ambiguous what is the correct return status code
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Comment format.

@jsetje
Copy link
Collaborator

jsetje commented Nov 23, 2024

This is actually looking pretty good. Thank you for getting it this far!

Some of the comment style is unfamiliar to me and may be fine, but it might be worth using a single style for the multi-line ones. That's really a nit though.

I have gotten this to work, but will do more testing with this on Monday.

@jsetje
Copy link
Collaborator

jsetje commented Nov 28, 2024

When trying to load a kernel with an untrusted signature, we end up with the following error message:

Verification failed: Security Policy Violation
error: bad shim signature.
error: you need to load the kernel first.
Press any key to continue...

"bad shim signature" seems misleading.

Otherwise this generally works for me.

This also needs a signed-off-by, but you know that. :)

@jsetje
Copy link
Collaborator

jsetje commented Dec 10, 2024

Here's a quick cleanup pass, mostly this needs Signed-off-bys from @vathpela on those three patches:

https://github.com/jsetje/shim/tree/loader-protocol-nit-cleanup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants