Skip to content

Commit 391fa39

Browse files
committed
Document setup needed for UEFI Secureboot signing
This includes how to setup builder disposable template, socket->qrexec proxy and all relevant parameters This moves some of the setup steps from README.md in vmm-xen-unified repo. QubesOS/qubes-issues#8206
1 parent dd8e333 commit 391fa39

File tree

4 files changed

+113
-0
lines changed

4 files changed

+113
-0
lines changed

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,88 @@ $ qvm-prefs work-qubesos default_dispvm qubes-builder-dvm
131131
```
132132

133133

134+
### Qubes executor for secureboot signing
135+
136+
The `vmm-xen-unified` component builds a signed unified Xen+Linux binary. It
137+
requires additional setup for the signing process. This approach will use
138+
separate disposable template for just `vmm-xen-unified` component and have that
139+
disposable access to the signing service.
140+
141+
Building `vmm-xen-unified` with docker executor is currently not supported.
142+
143+
First, you will need to generate (or otherwise obtain) signing key. This step
144+
is not specific to qubes-builderv2, can be done with any tool. See README in
145+
`vmm-xen-unified` for example approach. Store the keys in a separate
146+
(preferably network-disconnected) qube (if you use HSM or other hardware token
147+
- configure its usage in that qube). Later steps in this instruction use
148+
`vault-pesign` name for this qube, but it can be anything. Copy
149+
`rpc/qubesbuilder.PESign` to `/usr/local/etc/qubes-rpc` in the key-holding qube
150+
and make sure it's executable:
151+
```
152+
chmod +x /usr/local/etc/qubes-rpc/qubesbuilder.PESign
153+
```
154+
155+
If extra parameters for using the key are needed for `pesign`, add `/home/user/.config/qubes-pesign/CERT_NICKNAME` (where `CERT_NICKNAME` is a name used for `KEY_NAME` value later in this instruciton) to set the arguments, for example:
156+
```
157+
# dbpath with pkcs11 module configured
158+
PESIGN_ARGS+=( "--certdir=$HOME/pesign-token-db" )
159+
# token name
160+
PESIGN_ARGS+=( "--token=token name" )
161+
# pinfile path, if relevant
162+
PESIGN_ARGS+=( "--pinfile=$HOME/pesign-token-pin.txt" )
163+
# you can also override CERTIFICATE
164+
CERTIFICATE="certificate name as on the token"
165+
```
166+
167+
After doing that, create new disposable template following the above
168+
instructions, but name it `qubes-pesign-builder-dvm`.
169+
170+
Then, in the `qubes-pesign-builder-dvm` do the following:
171+
```
172+
mkdir -p /rw/bind-dirs/etc/systemd/system/
173+
mkdir -p /usr/local/etc/default
174+
# adjust value if you used different key nickname, replace spaces with __
175+
echo 'KEY_NAME="Qubes__OS__Unified__Kernel__Image__Signing__Key"' > /usr/local/etc/default
176+
mkdir -p /rw/config/qubes-bind-dirs.d
177+
cat <<EOF > /rw/config/qubes-bind-dirs.d/50_qubes-pesign.conf
178+
binds+=( '/etc/systemd/system/qubes-pesign.socket' )
179+
binds+=( '/etc/systemd/system/qubes-pesign@.service' )
180+
EOF
181+
```
182+
183+
Copy `rpc/qubes-pesign*` from qubes-builderv2 into `/rw/bind-dirs/etc/systemd/system/` in `qubes-pesign-builder-dvm` and set appropriate SELinux context (if SELinux is enabled there):
184+
```
185+
restorecon /rw/bind-dirs/etc/systemd/system/*
186+
```
187+
188+
Add starting the service in `/rw/config/rc.local`:
189+
```
190+
systemctl daemon-reload
191+
systemctl start qubes-pesign.socket
192+
```
193+
194+
Next step is to adjust qrexec policy to allow signing. To not depend on specific dispvm name, the policy will use tags. The `rpc/policy/50-qubesbuilder.policy` file contains commented-out example. Adjust key-holding qube name and possibly certificat nickname there.
195+
And then add appropriate tag to the `qubes-pesign-builder-dvm`:
196+
```
197+
qvm-tags qubes-pesign-builder-dvm add pesign-allow
198+
```
199+
200+
And finally, enable building `vmm-xen-unified` using just configured disposable
201+
template by adding the following to your `builder.yml`:
202+
203+
```
204+
+components:
205+
- vmm-xen-unified:
206+
packages: true
207+
stages:
208+
- build:
209+
executor:
210+
type: qubes
211+
options:
212+
dispvm: qubes-pesign-builder-dvm
213+
```
214+
215+
134216
## Build stages
135217

136218
The build process consists of the following stages:

rpc/policy/50-qubesbuilder.policy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ qubesbuilder.FileCopyOut * work-qubesos @tag:disp-created-by-work-qubesos allow
99
qubes.Filecopy * work-qubesos @tag:disp-created-by-work-qubesos allow
1010
qubes.WaitForSession * work-qubesos @tag:disp-created-by-work-qubesos allow
1111
qubes.VMShell * work-qubesos @tag:disp-created-by-work-qubesos allow
12+
13+
14+
# Enable for secureboot signing
15+
#admin.vm.CreateDisposable * work-qubesos qubes-pesign-builder-dvm allow target=dom0
16+
# adjust key-holding qube name (vault-pesign) and cert nickname (the service
17+
# argument)
18+
#qubesbuilder.PESign +Qubes__OS__Unified__Kernel__Image__Signing__Key @tag:pesign-allow @default allow target=vault-pesign

rpc/qubes-pesign.socket

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=Forward pesign call to vault
3+
4+
[Socket]
5+
ListenStream=/run/qubes-pesign
6+
Accept=yes
7+
SocketGroup=qubes
8+
9+
[Install]
10+
WantedBy=sockets.target

rpc/qubes-pesign@.service

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Forward pesign call to vault
3+
CollectMode=inactive-or-failed
4+
5+
[Service]
6+
EnvironmentFile=/usr/local/etc/default/qubes-pesign
7+
ExecStart=/usr/bin/qrexec-client-vm @default qubesbuilder.PESign+${KEY_NAME}
8+
StandardInput=socket
9+
StandardOutput=inherit
10+
StandardError=journal
11+
12+
13+
binds+=( '/etc/systemd/system/qubes-pesign.socket' )
14+
binds+=( '/etc/systemd/system/qubes-pesign@.service' )

0 commit comments

Comments
 (0)