Skip to content

Commit 898872d

Browse files
authored
Merge pull request #81 from poettering/uki-measure-order
uki: document expected measurement order of PE sections
2 parents b56025a + d366a33 commit 898872d

1 file changed

Lines changed: 38 additions & 16 deletions

File tree

specs/unified_kernel_image.md

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ or through a boot loader
1515
(which is generally useful to allow multiple kernel versions with interactive or
1616
automatic selection of version to boot into).
1717

18-
Various components of the UKI are provided as PE/COFF sections of the executable.
19-
The stub is a small program that can be executed in UEFI mode
20-
that forms the main executable part of the combined image.
21-
The stub program loads other resources from its file,
22-
including in particular the kernel and initrd,
23-
and transitions into the kernel.
18+
Various components of the UKI are provided as PE/COFF sections of the
19+
executable. The stub is a small program that can be executed in UEFI
20+
mode that forms the initial executable part of the combined image.
21+
The stub program loads other resources from its executable, including
22+
in particular the kernel and initrd, and transitions into the kernel.
2423

2524
This specification defines the format and components (mandatory and optional) of UKIs.
2625

@@ -40,22 +39,45 @@ that glues the listed components together, generating one PE binary that then ca
4039
UKIs consist of the following resources:
4140

4241
* An UEFI boot stub that forms the initial program.
43-
It contains various sections normally required for a program,
42+
It contains various PE sections normally required for a program,
4443
including `.text`, `.reloc`, `.data`, and others.
45-
* The Linux kernel in the `.linux` section.
46-
* The initrd that the kernel shall unpack and invoke, in the `.initrd` section.
47-
* Optionally, the kernel command line in the `.cmdline` section. If this is absent, the loader implementation may allow local overrides instead.
44+
* The Linux kernel in the `.linux` PE section.
4845
* Optionally, information describing the OS this kernel is intended for, in the `.osrel` section. The contents of this section are derived from `/etc/os-release` of the target OS. They can be useful for presentation of the UKI in the boot loader menu, and ordering it against other entries using the included version information.
49-
* Optionally, information describing kernel release information (i.e. `uname -r` output) in the `.uname` section. This is also useful for presentation of the UKI in the boot loader menu, and ordering it against other entries.
46+
* Optionally, the kernel command line in the `.cmdline` section. If this is absent, the loader implementation may allow local overrides instead.
47+
* The initrd that the kernel shall unpack and invoke, in the `.initrd` section.
5048
* Optionally, a splash image to bring to screen before transitioning into the Linux kernel, in the `.splash` section.
5149
* Optionally, one or more compiled Device Trees, for systems which need it, each in its separate `.dtb` section. If multiple `.dtb` sections exist then one of them is selected according to an implementation-specific algorithm.
52-
* Optionally, the public part of a public-private key pair in PEM format used to sign the image, in the `.pcrpkey` section.
53-
* Optionally, a JSON file encoding expected PCR 11 hash values seen from userspace once the UKI has booted up, along with signatures of these expected PCR 11 hash values, in the `.pcrsig` section. The signatures must also match the abovementioned key pair.
50+
* Optionally, information describing kernel release information (i.e. `uname -r` output) in the `.uname` section. This is also useful for presentation of the UKI in the boot loader menu, and ordering it against other entries.
5451
* Optionally, a CSV file encoding the SBAT metadata for the image, in the `.sbat` section. The [SBAT format is defined by the Shim project](https://github.com/rhboot/shim/blob/main/SBAT.md), and used for UEFI revocation purposes.
52+
* Optionally, a JSON file encoding expected PCR 11 hash values seen from userspace once the UKI has booted up, along with signatures of these expected PCR 11 hash values, in the `.pcrsig` section. The signatures must also match the key pair described below.
53+
* Optionally, the public part of a public-private key pair in PEM format used to sign the expected PCR 11 value of the image, in the `.pcrpkey` section.
54+
55+
Note that all of the sections defined above are singletons: they may
56+
appear once at most – except for the `.dtb` section which may
57+
appear more than once.
58+
59+
## UKI TPM PCR Measurements
60+
61+
On systems with a Trusted Platform Module (TPM) the UEFI boot stub
62+
shall measure the payload sections (i.e. the PE sections listed above,
63+
starting from the `.linux` one), in the order as listed above (which
64+
should be considered the *canonical* *order*).
65+
66+
For each section two measurements shall be made into PCR 11 with the
67+
event code `EV_IPL`:
68+
69+
1. The section name in ASCII (including one trailing NUL byte)
70+
2. The (binary) section contents
71+
72+
The above should be repeated for every section defined above, so that
73+
the measurements are interleaved: section name followed by section
74+
data, followed by the next section name and its section data, and so
75+
on.
5576

56-
Note that all of the sections defined above are singletons: they may appear once at most – except for the `.dtb` section which may be appear more than once.
77+
If multiple `.dtb` sections are present, they shall be measured in the
78+
order they appear in the PE file.
5779

58-
### JSON Format for `.pcrsig`
80+
## JSON Format for `.pcrsig`
5981
The format is a single JSON object, encoded as a zero-terminated `UTF-8` string. Each name in the object
6082
shall be unique as per recommendations of
6183
[RFC8259](https://datatracker.ietf.org/doc/html/rfc8259#section-4). Strings shall not contain any control
@@ -108,7 +130,7 @@ through single file atomic updates, which is useful given that the primary expec
108130
UKIs is the UEFI System Partition (ESP), which is a vFAT file system, with its limited data safety guarantees.
109131

110132
## Security
111-
Given UKIs are regular UEFI PE files, they can thus be signed as one for SecureBoot, protecting all of the
133+
Given UKIs are regular UEFI PE files, they can thus be signed as one for Secure Boot, protecting all of the
112134
individual resources listed above at once, and their combination. Standard Linux tools such as
113135
[`sbsigntool`](https://manpages.debian.org/unstable/sbsigntool/sbsign.1.en.html) and
114136
[`pesign`](https://github.com/rhboot/pesign) can be used to sign UKI files. The signature format and process

0 commit comments

Comments
 (0)