Commit Graph

12 Commits

Author SHA1 Message Date
Yu Watanabe
6529ab0b06 pe-binary: fix array overrun
This is a kind of paranoia, as memeqzero() does not read anyting if
length is zero. But, strictly speaking C language does not allow such,
and Coverity warn about that.

Fixes CID#1561177.
2025-03-04 05:18:15 +09:00
Yu Watanabe
2bf5d698d6 pe-binary: trivial coding style fixlets 2025-03-04 05:18:15 +09:00
Luca Boccassi
f6928e6b5d pe: do not warn about .initrd addons
We now support them, so stop warning about them.
2025-01-30 09:27:42 +01:00
Daan De Meyer
5f163921e9 Introduce systemd-sbsign to do secure boot signing
Currently in mkosi and ukify we use sbsigntools to do secure boot
signing. This has multiple issues:

- sbsigntools is practically unmaintained, sbvarsign is completely
broken with the latest gnu-efi when built without -fshort-wchar and
upstream has completely ignored my bug report about this.
- sbsigntools only supports openssl engines and not the new providers
API.
- sbsigntools doesn't allow us to cache hardware token pins in the
kernel keyring like we do nowadays when we sign stuff ourselves in
systemd-repart or systemd-measure

There are alternative tools like sbctl and pesign but these do not
support caching hardware token pins in the kernel keyring either.

To get around the issues with sbsigntools, let's introduce our own
tool systemd-sbsign to do secure boot signing. This allows us to
take advantage of our own openssl infra so that hardware token pins
are cached in the kernel keyring as expected and we get openssl
provider support as well.
2024-11-06 14:00:49 +01:00
Daan De Meyer
cf0238d854 pcrlock: Move pe_hash() and uki_hash() to pe-binary.h
Let's move these to shared so we can reuse pe_hash() in the upcoming
systemd-sbsign.
2024-11-05 14:26:21 +01:00
Lennart Poettering
9de565dd5d pe-binary: add pe_is_native() for checking if PE is native 2024-09-12 10:02:15 +02:00
Lennart Poettering
e6c49f7f11 pe-binary: split pe_header_find_section() in two
This splits out the core part into a new function
pe_section_table_find().

pe_header_find_section() takes a PeHeader as input, while
pe_section_table_find() just takes the section table and its size.
2024-09-12 10:02:15 +02:00
Lennart Poettering
f3c1d7fea1 pe-binary: split pe_read_section_data() into two
This renames pe_read_section_data() to pe_read_section_data_by_name()
and makes pe_read_section_data() a bit more low-level: it takes a header
table entry directly, instead of searching it first by name.
2024-09-12 10:02:15 +02:00
Lennart Poettering
a8e912f01b pe-binary: add helper pe_is_addon() for detecting whether we are looking at PE EFI add-on 2024-09-12 10:02:15 +02:00
Yu Watanabe
2e93331605 pe-binary: .initrd section is optional for UKI
.osrel is also optional, but sd-boot and bootctl requires it.
So, let's keep .osrel section at least now.

Fixes #32774.
2024-05-16 12:56:22 +02:00
Lennart Poettering
ef2dbc9c40 pe-binary: actually check if PE binary is UEFI binary when determining if UKI
If it's not a UEFI binary, then it's not a UKI.
2023-09-29 21:54:16 +02:00
Lennart Poettering
0786b03969 shared: add common implementation of PE parser 2023-08-29 11:25:52 +02:00