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

feat: in-memory assembling of the PE binaries #279

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

RaitoBezarius
Copy link
Member

@RaitoBezarius RaitoBezarius commented Jan 5, 2024

Finally, @nikstur, rejoice. This stops using objcopy to assemble the PE binary

I need to finish merging this back to Goblin before we can really merge it, i.e. depends on m4b/goblin#381 m4b/goblin#389.

Depends on #278 for practical reasons.

…t packages

Now, it is possible to build any package of the workspace in a fine grained fashion.
We want here to capture the required data to assemble a stub, here is a partial structure
modulo ESP generation paths.

Other pieces of code can consume this structure, validate it before passing it to the PE assembler
and the signer.

We convert everything into owned structures because we cannot really do
deserialization in any context with lifetimes going around, but,
allocations are generally very cheap in this context.
In order to offer more flexible signature mechanisms in lanzaboote,
we need to take a step back and offer a general PE signature trait.

After this, we will be able to plug various different implementations.
Remote signing enables a user to request for:

- PE signature of a given store path, which is assumed to be available on the server side
- PE signature oi a stub given by its parameters, which are assumed to be analyzable on the server side
  (i.e. computing hashes is possible.)
- Verifying if a PE signature is correct according to PE signatures and Secure Boot policy
It is now possible to use remote signature inside lzbt-systemd.
This is an example server to perform remote signatures
based on stub parameters provided.
Our lanzaboote integration tests are getting more and more sophisticated and ambitious.

Let's extract them into a "lanzalib", so they can be used with multiple backends.
We build lanzasignd now as part of the flake as an additional software we provide.
Introduces the Secure Boot remote signing server for NixOS.
Lanzaboote boot module now supports using a potential remote signer server,
but this support is limited to the lanzaboote bootables and not the fwupd ones.
A simple test harness for remote signatures with lanzasignd.
We didn't test if there *was* a signature, idempotency of removal of signatures (i.e. removing an non-existent signature
is the identity operation) could fool us into believing we had a signed thing then not signed.
This is relevant for a remote signer who relies on the existence of store paths
remotely, for example.
…ot needed

We should wait on the upstream PR to be merged so we can get rid of the
flake reference.
Life is too short to guess why EDK2 is broken, hence, I needed to debug the PE loader
and I wrote that in another project for debugging a kernel.

Here we go for this project.
`lanzaboote_image` is no more, we directly go from a set of stub parameters to the in-memory
representation of the final image.

Whatever the consumer wants to do with it, they are free to do so.

For now, we redump it into a temporary directory to make the changes minimal.

This depends on an unreleased branch of Goblin.
@nikstur
Copy link
Member

nikstur commented Jan 6, 2024

It'd be awesome if you can untangle this from #278

@RaitoBezarius
Copy link
Member Author

I'd find it easier for me to keep it tangled and just rebase once 278 goes in

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.

None yet

2 participants