Commit Graph
59725 Commits
Author SHA1 Message Date
Yu Watanabe cdbcc33952 repart: check if existing partitions can grow
Fixes #24553.
2022-09-09 05:49:00 +09:00
Yu Watanabe 58b06ac1ab repart: split out free_area_{current,min}_end() from free_area_available_for_new_partitions()
No actual code changes, just preparation for later commits.
2022-09-09 05:49:00 +09:00
Yu Watanabe f39cf264a6 repart: reset assignments by previous context_allocate_partitions()
The function context_allocate_partitions() may be called multiple times.
If this is called multiple times, then dropped partitions may still
assigned to free area.
2022-09-09 05:48:56 +09:00
Yu Watanabe d7c46b5e1e repart: do not assign new size larger than acquired or the specified maximum
The acquired size may be larger than the requested maximum. So, let's
cap the value.

Note, at the final phase, the acquired size should be larger than the
requested minimum. Hence, the assertion about that is added.
2022-09-09 05:35:41 +09:00
Yu Watanabe bf99aed6e8 repart: set new size for foreign partitions at first
Otherwise, the new size may be larger than the acquired one.
2022-09-09 05:35:41 +09:00
Yu Watanabe 2a503ad2a9 repart: anyway run loop at the end even if the loop will be restarted later
The order of the partitions processed in each phase does not change
result for the first two phase (PHASE_OVERCHARGE and PHASE_UNDERCHARGE).
2022-09-09 05:35:41 +09:00
Yu Watanabe 0245e15afe repart: make scale_by_weight() always succeed 2022-09-09 05:35:40 +09:00
Yu Watanabe 19903a4335 repart: split out context_grow_partition_one()
No actual code changes, just refactoring.
2022-09-09 05:35:40 +09:00
Yu Watanabe a801bb0157 repart: introduce partition_{min,max}_padding()
No actual code changes, just refactoring.
2022-09-09 05:35:40 +09:00
Yu Watanabe b0fbf90b5a repart: ensure partition_max_size() >= partition_min_size() 2022-09-09 05:35:40 +09:00
Yu Watanabe 822d9b9adc repart: make partition_max_size() return UINT64_MAX if not specified
Previously, it did not return UINT64_MAX, but a huge value, as
`UINT64_MAX / grain_size * grain_size != UINT64_MAX`.

This also drops unnecessary conditions.
2022-09-09 05:35:40 +09:00
Yu Watanabe a80701e68f repart: constify partition_min_size() 2022-09-09 05:35:40 +09:00
Yu Watanabe f126038f83 repart: rename variables in config_parse_weight()
This is for Weight= or PaddingWeight=, not for Priority=.

No actual code changes, just refactoring.
2022-09-09 05:35:40 +09:00
Yu Watanabe 539b6597b2 Merge pull request #24601 from yuwata/sd-device-enumerator-drop-recursion
sd-device-enumerator: do not recursively find child devices
2022-09-09 04:30:42 +09:00
Frantisek Sumsal 8432b0cd20 Merge pull request #24351 from poettering/pcr-sign
support for signed TPM2 PCR policies in cryptsetup/cryptenrolls/credentials
2022-09-08 19:07:04 +00:00
Lennart Poettering d56f77e17f measure: print a helpful message if TPM2 PCR sysfs attributes are missing
Prompted by:

https://github.com/systemd/systemd/pull/24351#pullrequestreview-1100418585
2022-09-08 19:46:54 +02:00
Guillaume W. Bres b3fe33ff52 basic/missing_loop.h: fix missing lo_flags LO_FLAGS_DIRECT_IO 2022-09-08 18:46:19 +01:00
Luca Boccassi 90235a3df2 Merge pull request #24608 from bluca/example
docs: mention tmpfiles.d in CREDENTIALS.md and add example for ssh provisioning (to manpage too)
2022-09-08 17:42:07 +01:00
Lennart Poettering b2629096e2 Merge pull request #24600 from poettering/bootspec-chase-symlinks
bootspec: more chase_symlinks()
2022-09-08 18:40:10 +02:00
Luca Boccassi b60d3016eb docs: mention tmpfiles.d in CREDENTIALS.md and add example 2022-09-08 16:33:24 +01:00
Luca Boccassi 87d1886346 man: add example with one-liner for ssh provisioning via tmpfiles.d + Creds 2022-09-08 16:27:52 +01:00
Frantisek Sumsal f53d56f1a3 test: check the numa-test.service status directly
In a couple of recent CI runs I noticed TEST-36 failing due to a missed
service exit notification and a subsequent fail of the `grep` command:

```
[  257.112153] H systemd[1]: Started numa-test.service.
[  257.114343] H systemd[899]: numa-test.service: Failed to set NUMA memory policy: Invalid argument
[  257.118270] H systemd[899]: numa-test.service: Failed at step NUMA_POLICY spawning /bin/sleep: Invalid argument
[  257.126170] H systemd[1]: Bus private-bus-connection: changing state RUNNING → CLOSING
[  257.130290] H systemd[1]: numa-test.service: Failed to send unit change signal for numa-test.service: Connection reset by peer
[  257.131567] H systemd[1]: Received SIGCHLD from PID 899 ((sleep)).
[  257.132870] H systemd[1]: Got disconnect on private connection.
[  257.134299] H systemd[1]: systemd-journald.service: Got notification message from PID 498 (FDSTORE=1)
[  257.135611] H systemd[1]: systemd-journald.service: Added fd 38 (n/a) to fd store.
[  257.136999] H systemd[1]: systemd-journald.service: Received EPOLLHUP on stored fd 38 (stored), closing.
[  257.366996] H testsuite-36.sh[536]: + stopJournalctl
[  257.366996] H testsuite-36.sh[536]: + local unit=init.scope
[  257.366996] H testsuite-36.sh[536]: + echo 'Force journald to write all queued messages'
[  257.366996] H testsuite-36.sh[536]: Force journald to write all queued messages
[  257.366996] H testsuite-36.sh[536]: + journalctl --sync
[  257.488642] H systemd-journald[498]: Received client request to rotate journal.
[  257.520821] H testsuite-36.sh[536]: + journalctl -u init.scope --cursor-file=jounalCursorFile
[  257.981399] H testsuite-36.sh[536]: + pid1StopUnit numa-test.service
[  257.984533] H testsuite-36.sh[536]: + systemctl stop numa-test.service
[  258.173656] H systemd[1]: Bus private-bus-connection: changing state AUTHENTICATING → RUNNING
[  258.180710] H systemd[1]: numa-test.service: Trying to enqueue job numa-test.service/stop/replace
[  258.182424] H systemd[1]: Added job numa-test.service/stop to transaction.
[  258.185234] H systemd[1]: numa-test.service: Installed new job numa-test.service/stop as 738
[  258.187017] H systemd[1]: numa-test.service: Enqueued job numa-test.service/stop as 738
[  258.239930] H testsuite-36.sh[536]: + grep 'numa-test.service: Main process exited, code=exited, status=242/NUMA' journal.log
```

Let's mitigate this by checking the test service exit status directly
instead of relying on the notification.
2022-09-08 15:00:26 +00:00
Lennart Poettering 7c46b19718 TEST-70-TPM2: add test for new signed TPM2 PCR policies 2022-09-08 16:34:27 +02:00
Lennart Poettering 75a9681ec0 cryptsetup: hook up TPM2 token code with policies based on PCR signatures, too 2022-09-08 16:34:27 +02:00
Lennart Poettering 4d5cc0d453 tpm2-util: add helper for formatting PCR masks as string 2022-09-08 16:34:27 +02:00
Lennart Poettering fdf6c27cba tpm2-util: add common parser for the LUKS2 TPM2 JSON structure
This splits out the JSON parser used by the systemd-cryptsetup code.

This is preparation for later work to reuse it in the tpm2 cryptsetup
token module, which currently uses a separate but very similar parser
for the same data.

No change in behaviour.
2022-09-08 16:34:27 +02:00
Lennart Poettering dc63b2c909 cryptsetup: hook up signed PCR policies 2022-09-08 16:34:27 +02:00
Lennart Poettering 02ef97cde0 repart: hook up new TPM2 signed policies with repart 2022-09-08 16:34:27 +02:00
Lennart Poettering f0f4fcaeb7 cryptenroll: hook up new TPM2 signed policies with cryptenroll 2022-09-08 16:34:27 +02:00
Lennart Poettering 75ddec9301 creds-tool: expose new signed PCR policies in creds tool, too 2022-09-08 16:34:27 +02:00
Lennart Poettering 6a0779cbf9 creds-util: hook up new signed PCR policies 2022-09-08 16:34:27 +02:00
Lennart Poettering d9b5841d40 tpm2-util: extend TPM2 policies to optionally check PCR values against signed values
Traditionally, TPM2 PCR policies are bound against literal PCR values,
which makes them hard to work with when updating software that is
measured into PCRs: each update will change the PCR values, and thus
break TPM2 policies of existing objects.

Let's improve the situation: let's allow signed PCR policies. Secrets
and other TPM2 objects can be associated with a public key that signs a
PCR policy. Thus, if the signed policy and the public key is presented,
access to the TPM2 object can be granted. This allows a less brittle
handling of updates: for example, whenever a kernel image is updated a
new signed PCR policy can be shipped along with it, signed by a private
key owned by the kernel vendor (ideally: same private key that is used
to sign the kernel image itself). TPM2 objects can then be bound to the
associated public key, thus allowing objects that can only be unlocked
by kernels of the same vendor. This makes it very easy to update kernels
without affecting locked secrets.

This does not hook up any of the consuming code (just passes NULL/0
everywhere). This is for later commits.
2022-09-08 16:34:27 +02:00
Lennart Poettering cdaaa62ca1 measure: add 'sign' verb 2022-09-08 16:27:07 +02:00
Lennart Poettering e8ccb5c7e1 openssl-util: add helper for calculating fingerprint of a DER public key 2022-09-08 16:27:07 +02:00
Lennart Poettering bad4c73c37 tpm2-util: allow external code to create tpm2 contexts 2022-09-08 16:27:07 +02:00
Lennart Poettering 0d75641388 tpm2-util: pick up 4 more symbols of tpm2-tss 2022-09-08 16:27:07 +02:00
Lennart Poettering bbb71e5c98 CODING_STYLE: fix header level 2022-09-08 16:13:07 +02:00
Lennart Poettering 8c87f2473f bootctl: don't start "bootctl list" output with a title line
Let's not output a title line given that we don't output multiple
different things here anyway, and the "bootctl list" command is about
listing boot entries anyway and it's documented that way.

Having titles for sections if we have mutliple sections of output
definitely makes sense, but if there's only one kind of information we
list it's redundant clutter.
2022-09-08 13:14:05 +02:00
Lennart Poettering f2c513048c bootspec: don't follow symlinks when opening type1/type2 files
let's not follow symlinks when going from enumeraiton dir to enumerated
file either.
2022-09-08 13:14:05 +02:00
Lennart Poettering 2683ae2d73 bootspec: use chase_symlinks() where appropriate
Let's better be safe than sorry, and follow symlinks in ESP + XBOOTLDR
via chase_symlinks() relative to the root of these files systems. This is
not a big issue given that ESP/XBOOTLDR are supposed to be VFAT where
symlinks don't exist, but the specs don't strictly require this, and by
loading efifs drivers in uefi it would be possible to support symlinks,
but we'd rather not have that here.

No real change in behaviour, just stricter rules to make me sleep better
at night.
2022-09-08 13:14:05 +02:00
Lennart Poettering be429c8ff6 update TODO 2022-09-08 13:14:04 +02:00
Lennart Poettering 3d83c3eacf Merge pull request #24572 from DaanDeMeyer/repart-verity
repart: Add support for formatting verity partitions
2022-09-08 12:02:27 +02:00
Lennart Poettering e586cc4cc5 Merge pull request #24434 from medhefgo/boot-fixes
boot: Small fixes
2022-09-08 11:17:12 +02:00
William Roberts 0e15c14f63 tpm2: add bind key
Currently, the tpm2 support will use encrypted sessions by creating a
primary key that is used to encrypt traffic. This creates a problem as
the key created for encrypting the traffic could be faked by an active
interposer on the bus. In cases when a pin is used, we can introduce the
bind key. The pin is used as the auth value for the seal key, aka the
disk encryption key, and that auth value can be used in the session
establishment. An attacker would need the pin value to create the secure
session and thus an active interposer without the pin could not
interpose on TPM traffic.

Related-to: #22637

Signed-off-by: William Roberts <william.c.roberts@intel.com>
2022-09-08 11:16:28 +02:00
Yu Watanabe 2d9c58d786 test: add test for sd_device_enumerator_add_match_parent() 2022-09-08 18:10:50 +09:00
Yu Watanabe 6c876f0c20 sd-device-enumerator: rewrite child enumeration without recursion 2022-09-08 18:10:50 +09:00
Yu Watanabe bae477676a sd-device-enumerator: do not fail when a directory vanishes on enumerate 2022-09-08 18:10:50 +09:00
Yu Watanabe cdffb95cce sd-device-enumerator: use test_matches() more 2022-09-08 18:10:50 +09:00
Daan De Meyer 0fc40a0ef6 update TODO 2022-09-08 08:43:50 +02:00
Daan De Meyer b5b7879a5d repart: Add support for formatting verity partitions
This commit adds a new Verity= setting to repart definition files
with two possible values: "data" and "hash".

If Verity= is set to "data", repart works as before, and populates
the partition with the content from CopyBlocks= or CopyFiles=.

If Verity= is set to "hash", repart will try to find a matching
data partition with Verity=data and equal values for CopyBlocks=
or CopyFiles=, Format= and MakeDirectories=. If a matching data
partition is found, repart will generate verity hashes for that
data partition in the verity partition. The UUID of the data
partition is set to the first 128 bits of the verity root hash. The
UUID of the hashes partition is set to the final 128 bits of the
verity root hash.

Fixes #24559
2022-09-08 08:43:07 +02:00