]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
3 years agotest: make the resolved notifications check a bit more robust 24637/head
Frantisek Sumsal [Sun, 11 Sep 2022 12:17:56 +0000 (14:17 +0200)] 
test: make the resolved notifications check a bit more robust

Let's parse the resolved JSON notifications via `jq` and check them in a
bit more "controlled" manner - e.g. until now the `grep` was checking just
a one gigantic JSON string, as all received notifications via the
varlink socket are terminated by a NUL character, not a newline.

Also, as the notification delivery is asynchronous, retry the check
a couple of times if it fails (spotted in C8S jobs):

```
[ 2891.935879] testsuite-75.sh[36]: + : '--- nss-resolve/nss-myhostname tests'
[ 2891.935988] testsuite-75.sh[36]: + run getent -s resolve hosts ns1.unsigned.test
[ 2891.936542] testsuite-75.sh[177]: + getent -s resolve hosts ns1.unsigned.test
[ 2891.937499] testsuite-75.sh[178]: + tee /tmp/tmp.pqjNvbQ2eS
[ 2891.939977] testsuite-75.sh[178]: 10.0.0.1        ns1.unsigned.test
[ 2891.940258] testsuite-75.sh[36]: + grep -qE '^10\.0\.0\.1\s+ns1\.unsigned\.test' /tmp/tmp.pqjNvbQ2eS
[ 2891.942235] testsuite-75.sh[189]: + grep -qF '[10,0,0,1]'
[ 2891.942577] testsuite-75.sh[188]: + grep -aF ns1.unsigned.test /tmp/notifications.txt
[ 2891.943978] systemd[1]: testsuite-75.service: Child 36 belongs to testsuite-75.service.
[ 2891.944112] systemd[1]: testsuite-75.service: Main process exited, code=exited, status=1/FAILURE
[ 2891.944215] systemd[1]: testsuite-75.service: Failed with result 'exit-code'.
```

3 years agotest: install jq into all images
Frantisek Sumsal [Sun, 11 Sep 2022 12:16:34 +0000 (14:16 +0200)] 
test: install jq into all images

3 years agoMerge pull request #24593 from jamacku/main
Frantisek Sumsal [Sat, 10 Sep 2022 19:42:26 +0000 (19:42 +0000)] 
Merge pull request #24593 from jamacku/main

Update `advanced-issue-labeler` action - `@v1` -> `@v2`

3 years agotpm2-util: avoid trial
Lennart Poettering [Fri, 9 Sep 2022 21:06:58 +0000 (23:06 +0200)] 
tpm2-util: avoid trial

Let's avoid trial mode for putting together policies if we can, and use
the real policy whenever we can pull it off.

Fixes: #24401
3 years agotest-29-portable: set timeout for 'portablectl reattach'
Yu Watanabe [Fri, 9 Sep 2022 18:21:37 +0000 (03:21 +0900)] 
test-29-portable: set timeout for 'portablectl reattach'

Then, the test can fail earlier than the timeout of the whole test
specified by $QEMU_TIMEOUT=.

This is useful when we try to run the test multiple times.

Workaround for issue #24147.

3 years agoMerge pull request #24618 from yuwata/udev-split-synthesizing
Yu Watanabe [Fri, 9 Sep 2022 17:52:54 +0000 (02:52 +0900)] 
Merge pull request #24618 from yuwata/udev-split-synthesizing

udev: shorten synthesize_change() a bit

3 years agoblockdev-util: split out blockdev_reread_partition_table() 24618/head
Yu Watanabe [Fri, 9 Sep 2022 15:33:43 +0000 (00:33 +0900)] 
blockdev-util: split out blockdev_reread_partition_table()

No functional changes, just refactoring.

3 years agoMerge pull request #24458 from poettering/stub-embedd-sig
Lennart Poettering [Fri, 9 Sep 2022 16:18:37 +0000 (18:18 +0200)] 
Merge pull request #24458 from poettering/stub-embedd-sig

optionally, embed PCR signature and public key in new sd-stub PE sections

3 years agoudevd: use partition enumerator at one more place
Yu Watanabe [Fri, 9 Sep 2022 15:17:46 +0000 (00:17 +0900)] 
udevd: use partition enumerator at one more place

No functional changes, just refactoring.

3 years agoMerge pull request #24609 from yuwata/sd-device-enumerator-check-sysname
Yu Watanabe [Fri, 9 Sep 2022 14:32:15 +0000 (23:32 +0900)] 
Merge pull request #24609 from yuwata/sd-device-enumerator-check-sysname

sd-device-enumerator: check sysname earlier

3 years agoMerge pull request #24611 from yuwata/loop-util-refactoring
Yu Watanabe [Fri, 9 Sep 2022 14:31:19 +0000 (23:31 +0900)] 
Merge pull request #24611 from yuwata/loop-util-refactoring

loop-util: several cleanups

3 years agoblockdevi-util: also check sysname when enumerating partitions
Yu Watanabe [Thu, 8 Sep 2022 20:25:55 +0000 (05:25 +0900)] 
blockdevi-util: also check sysname when enumerating partitions

3 years agosd-device-enumerator: use _cleanup_free_ attribute for safety 24609/head
Yu Watanabe [Fri, 9 Sep 2022 11:55:45 +0000 (20:55 +0900)] 
sd-device-enumerator: use _cleanup_free_ attribute for safety

No functional changes, just improve readability.

Suggested by https://github.com/systemd/systemd/pull/24601#discussion_r966883459.

3 years agosd-device-enumerator: always ignore ENOENT from opendir()
Yu Watanabe [Fri, 9 Sep 2022 11:52:41 +0000 (20:52 +0900)] 
sd-device-enumerator: always ignore ENOENT from opendir()

But logs all errors.

3 years agosd-device-enumerator: check sysname earlier
Yu Watanabe [Thu, 8 Sep 2022 19:26:15 +0000 (04:26 +0900)] 
sd-device-enumerator: check sysname earlier

3 years agoupdate TODO 24458/head
Lennart Poettering [Fri, 26 Aug 2022 09:11:07 +0000 (11:11 +0200)] 
update TODO

3 years agoman: say early what a unified kernel image/UKI is
Lennart Poettering [Fri, 9 Sep 2022 09:24:12 +0000 (11:24 +0200)] 
man: say early what a unified kernel image/UKI is

3 years agoman: be more careful regarding TPM vs. TPM2
Lennart Poettering [Fri, 9 Sep 2022 09:09:30 +0000 (11:09 +0200)] 
man: be more careful regarding TPM vs. TPM2

We support PCR measurements for both classic TPM1.2 and TPM2, hence just
say "TPM" generically in that context. But the signed policies are
exclusive to TPM2, hence always say TPM2 there.

We mostly got that right, except at one place. Fix that.

3 years agoman: document the new .pcrsig/.pcrpkey sections for unified kernel images
Lennart Poettering [Fri, 9 Sep 2022 09:08:35 +0000 (11:08 +0200)] 
man: document the new .pcrsig/.pcrpkey sections for unified kernel images

3 years agotmpfiles: copy PCR sig/pkey from initrd /.extra/ into /run/
Lennart Poettering [Thu, 25 Aug 2022 15:16:52 +0000 (17:16 +0200)] 
tmpfiles: copy PCR sig/pkey from initrd /.extra/ into /run/

Now that sd-stub will place the PCR signature and its public key in
the initrd's /.extra/ directory, let's copy it from there into /run/
from userspace. This is done because /.extra/ is on the initrd's tmpfs
which will be emptied during the initrd → host transition. Since we want
these two files to survive we'll copy them – if they exist – into /run/
where they will survive the transition.

Thus, with this last change the files will have safely propagated from
their PE sections into files in /run/ where userspace can find them

The paths in /run/ happen to be the exact ones that
systemd-cryptenroll/systemd-cryptsetup/systemd-creds look for them.

3 years agostub: pass .pcrsig and .pcrpkey PE sections as cpio into invoked kernel
Lennart Poettering [Thu, 25 Aug 2022 14:55:49 +0000 (16:55 +0200)] 
stub: pass .pcrsig and .pcrpkey PE sections as cpio into invoked kernel

Pick up the two new sections in sd-stub and pass them as initrds into
the booted kernels, where they'll show up as
/.extra/tpm2-pcr-signature.json and /.extra/tpm2-pcr-public-key.pem in
the initrd file system.

The initrd is then supposed to pick these files up from there and save
them at a place that will survive into the host OS.

3 years agostub: add new special PE sections ".pcrsig" and ".pcrpkey" in unified kernels
Lennart Poettering [Thu, 25 Aug 2022 14:55:01 +0000 (16:55 +0200)] 
stub: add new special PE sections ".pcrsig" and ".pcrpkey" in unified kernels

These aren't wired up yet to do anything useful. For now we just define
them.

This sections are supposed to carry a signature for expected
measurements on PCR 11 if this kernel is booted, in the JSON format
"systemd-measure sign" generates, and the public key used for the
signature.

The idea is to embedd the signature and the public key in unified
kernels and making them available to userspace, so that userspace can
easily access them and enroll (for which the public key is needed) or
unlock (for which the PCR signature is needed) LUKS2 volumes and
credentials that are bound to the currently used kernel version stream.

Why put these files in PE sections rather than just into simple files in
the initrd or into the host fs?

The signature cannot be in the initrd, since it is after all covering
the initrd, and thus the initrd as input for the calculation cannot
carry the result of the calculation. Putting the signature onto the root
fs sucks too, since we typically want to unlock the root fs with it,
hence it would be inaccessible for it's primary purpose then.

The public key could be in the initrd or in the root fs, there's no
technical restriction for that. However, I still think it's a good idea
to put it in a PE section as well, because this means the piece of code
that attaches the signature can also attach the public key easily in one
step, which is nice since it allows separating the roles of the
kernel/initrd/root fs builder, and the role of the signer, and the
former doesn't have to have knowledge about what the latter is going to
add to the image.

Note that the signature section is excluded from the TPM measurements
sd-stub does about its resource sections, since – as mentioned – it's
the expected output of the signing operation whose input are the
measurements, hence it cannot also be input to them. The public key
section is included in the measurements however.

3 years agocpio: add helper for packing cpios of literally specified data blobs
Lennart Poettering [Thu, 25 Aug 2022 14:54:03 +0000 (16:54 +0200)] 
cpio: add helper for packing cpios of literally specified data blobs

Let's add simple helpers for passing data blobs from the stub into the
booted kernel as initrds that are generated on-the-fly.

(Note used yet, a later commit will make use of this)

3 years agoImplement DNS notifications from resolved via varlink
Suraj Krishnan [Tue, 26 Apr 2022 22:09:02 +0000 (17:09 -0500)] 
Implement DNS notifications from resolved via varlink

* The new varlink interface exposes a method to subscribe to DNS
resolutions on the system. The socket permissions are open for owner and
group only.
* Notifications are sent to subscriber(s), if any, after successful
resolution of A and AAAA records.

This feature could be used by applications for auditing/logging services
downstream of the resolver. It could also be used to asynchronously
update the firewall. For example, a system that has a tightly configured
firewall could open up connections selectively to known good hosts based
on a known allow-list of hostnames. Of course, updating the firewall
asynchronously will require other design considerations (such as
queueing packets in the user space while a verdict is made).

See also:
https://lists.freedesktop.org/archives/systemd-devel/2022-August/048202.html
https://lists.freedesktop.org/archives/systemd-devel/2022-February/047441.html

3 years agoMerge pull request #24557 from yuwata/repart
Yu Watanabe [Fri, 9 Sep 2022 00:32:07 +0000 (09:32 +0900)] 
Merge pull request #24557 from yuwata/repart

repart: fix partition size calculation

3 years agotest-58-repart: add test case for issue #24553 24557/head
Yu Watanabe [Mon, 5 Sep 2022 13:11:55 +0000 (22:11 +0900)] 
test-58-repart: add test case for issue #24553

3 years agorepart: make existing partition can be also 'dropped'
Yu Watanabe [Mon, 5 Sep 2022 16:58:34 +0000 (01:58 +0900)] 
repart: make existing partition can be also 'dropped'

Previously, when an existing partition cannot grow, then entire process
fails. This makes such an existing partion handled as an foreign
partition, i.e. it is not managed by us.

3 years agorepart: check if existing partitions can grow
Yu Watanabe [Mon, 5 Sep 2022 12:57:38 +0000 (21:57 +0900)] 
repart: check if existing partitions can grow

Fixes #24553.

3 years agorepart: split out free_area_{current,min}_end() from free_area_available_for_new_part...
Yu Watanabe [Mon, 5 Sep 2022 12:56:49 +0000 (21:56 +0900)] 
repart: split out free_area_{current,min}_end() from free_area_available_for_new_partitions()

No actual code changes, just preparation for later commits.

3 years agorepart: reset assignments by previous context_allocate_partitions()
Yu Watanabe [Mon, 5 Sep 2022 16:23:19 +0000 (01:23 +0900)] 
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.

3 years agorepart: do not assign new size larger than acquired or the specified maximum
Yu Watanabe [Sun, 4 Sep 2022 09:54:52 +0000 (18:54 +0900)] 
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.

3 years agorepart: set new size for foreign partitions at first
Yu Watanabe [Sun, 4 Sep 2022 09:48:15 +0000 (18:48 +0900)] 
repart: set new size for foreign partitions at first

Otherwise, the new size may be larger than the acquired one.

3 years agorepart: anyway run loop at the end even if the loop will be restarted later
Yu Watanabe [Sun, 4 Sep 2022 09:51:55 +0000 (18:51 +0900)] 
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).

3 years agorepart: make scale_by_weight() always succeed
Yu Watanabe [Sun, 4 Sep 2022 06:20:29 +0000 (15:20 +0900)] 
repart: make scale_by_weight() always succeed

3 years agorepart: split out context_grow_partition_one()
Yu Watanabe [Sun, 4 Sep 2022 09:43:55 +0000 (18:43 +0900)] 
repart: split out context_grow_partition_one()

No actual code changes, just refactoring.

3 years agorepart: introduce partition_{min,max}_padding()
Yu Watanabe [Sun, 4 Sep 2022 09:26:04 +0000 (18:26 +0900)] 
repart: introduce partition_{min,max}_padding()

No actual code changes, just refactoring.

3 years agorepart: ensure partition_max_size() >= partition_min_size()
Yu Watanabe [Sun, 4 Sep 2022 09:25:03 +0000 (18:25 +0900)] 
repart: ensure partition_max_size() >= partition_min_size()

3 years agorepart: make partition_max_size() return UINT64_MAX if not specified
Yu Watanabe [Sun, 4 Sep 2022 06:19:18 +0000 (15:19 +0900)] 
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.

3 years agorepart: constify partition_min_size()
Yu Watanabe [Sun, 4 Sep 2022 09:24:13 +0000 (18:24 +0900)] 
repart: constify partition_min_size()

3 years agorepart: rename variables in config_parse_weight()
Yu Watanabe [Mon, 5 Sep 2022 16:42:44 +0000 (01:42 +0900)] 
repart: rename variables in config_parse_weight()

This is for Weight= or PaddingWeight=, not for Priority=.

No actual code changes, just refactoring.

3 years agoloop-util: do not try to enumerate partitions twice 24611/head
Yu Watanabe [Thu, 8 Sep 2022 20:12:07 +0000 (05:12 +0900)] 
loop-util: do not try to enumerate partitions twice

3 years agoloop-util: always check if backing file is not attached yet
Yu Watanabe [Thu, 8 Sep 2022 20:04:08 +0000 (05:04 +0900)] 
loop-util: always check if backing file is not attached yet

An image file without partition table may be attached.

3 years agoloop-util: open loopback block device in loop_configure()
Yu Watanabe [Thu, 8 Sep 2022 08:18:49 +0000 (17:18 +0900)] 
loop-util: open loopback block device in loop_configure()

And make it return LoopDevice object on success.
No functional changes, just refactoring.

3 years agoloop-util: save the flag about if LOOP_CONFIGURE ioctl works or not in loop_configure()
Yu Watanabe [Thu, 8 Sep 2022 08:01:45 +0000 (17:01 +0900)] 
loop-util: save the flag about if LOOP_CONFIGURE ioctl works or not in loop_configure()

When LOOP_CONFIGURE fail, then it is not necessary to call it on any
later call of loop_configure(). Let's save the flag in a static variable
in the function.

3 years agoloop-util: split out several functions fron loop_configure() and loop_device_make_int...
Yu Watanabe [Thu, 8 Sep 2022 07:44:40 +0000 (16:44 +0900)] 
loop-util: split out several functions fron loop_configure() and loop_device_make_internal()

The two functions were quite long, and hard to understand its logic.
No functional change, just refactoring.

3 years agoMerge pull request #24601 from yuwata/sd-device-enumerator-drop-recursion
Yu Watanabe [Thu, 8 Sep 2022 19:30:42 +0000 (04:30 +0900)] 
Merge pull request #24601 from yuwata/sd-device-enumerator-drop-recursion

sd-device-enumerator: do not recursively find child devices

3 years agoMerge pull request #24351 from poettering/pcr-sign
Frantisek Sumsal [Thu, 8 Sep 2022 19:07:04 +0000 (19:07 +0000)] 
Merge pull request #24351 from poettering/pcr-sign

support for signed TPM2 PCR policies in cryptsetup/cryptenrolls/credentials

3 years agomeasure: print a helpful message if TPM2 PCR sysfs attributes are missing
Lennart Poettering [Thu, 8 Sep 2022 10:57:23 +0000 (12:57 +0200)] 
measure: print a helpful message if TPM2 PCR sysfs attributes are missing

Prompted by:

https://github.com/systemd/systemd/pull/24351#pullrequestreview-1100418585

3 years agobasic/missing_loop.h: fix missing lo_flags LO_FLAGS_DIRECT_IO
Guillaume W. Bres [Thu, 8 Sep 2022 13:54:57 +0000 (15:54 +0200)] 
basic/missing_loop.h: fix missing lo_flags LO_FLAGS_DIRECT_IO

3 years agoMerge pull request #24608 from bluca/example
Luca Boccassi [Thu, 8 Sep 2022 16:42:07 +0000 (17:42 +0100)] 
Merge pull request #24608 from bluca/example

docs: mention tmpfiles.d in CREDENTIALS.md and add example for ssh provisioning (to manpage too)

3 years agoMerge pull request #24600 from poettering/bootspec-chase-symlinks
Lennart Poettering [Thu, 8 Sep 2022 16:40:10 +0000 (18:40 +0200)] 
Merge pull request #24600 from poettering/bootspec-chase-symlinks

bootspec: more chase_symlinks()

3 years agodocs: mention tmpfiles.d in CREDENTIALS.md and add example 24608/head
Luca Boccassi [Thu, 8 Sep 2022 15:33:24 +0000 (16:33 +0100)] 
docs: mention tmpfiles.d in CREDENTIALS.md and add example

3 years agoman: add example with one-liner for ssh provisioning via tmpfiles.d + Creds
Luca Boccassi [Thu, 8 Sep 2022 15:27:52 +0000 (16:27 +0100)] 
man: add example with one-liner for ssh provisioning via tmpfiles.d + Creds

3 years agotest: check the numa-test.service status directly
Frantisek Sumsal [Thu, 8 Sep 2022 10:27:46 +0000 (12:27 +0200)] 
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.

3 years agoTEST-70-TPM2: add test for new signed TPM2 PCR policies 24351/head
Lennart Poettering [Fri, 19 Aug 2022 09:26:49 +0000 (11:26 +0200)] 
TEST-70-TPM2: add test for new signed TPM2 PCR policies

3 years agocryptsetup: hook up TPM2 token code with policies based on PCR signatures, too
Lennart Poettering [Fri, 19 Aug 2022 20:18:40 +0000 (22:18 +0200)] 
cryptsetup: hook up TPM2 token code with policies based on PCR signatures, too

3 years agotpm2-util: add helper for formatting PCR masks as string
Lennart Poettering [Fri, 19 Aug 2022 20:18:31 +0000 (22:18 +0200)] 
tpm2-util: add helper for formatting PCR masks as string

3 years agotpm2-util: add common parser for the LUKS2 TPM2 JSON structure
Lennart Poettering [Fri, 19 Aug 2022 20:15:12 +0000 (22:15 +0200)] 
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.

3 years agocryptsetup: hook up signed PCR policies
Lennart Poettering [Thu, 18 Aug 2022 09:10:30 +0000 (11:10 +0200)] 
cryptsetup: hook up signed PCR policies

3 years agorepart: hook up new TPM2 signed policies with repart
Lennart Poettering [Wed, 17 Aug 2022 15:30:11 +0000 (17:30 +0200)] 
repart: hook up new TPM2 signed policies with repart

3 years agocryptenroll: hook up new TPM2 signed policies with cryptenroll
Lennart Poettering [Wed, 17 Aug 2022 15:29:44 +0000 (17:29 +0200)] 
cryptenroll: hook up new TPM2 signed policies with cryptenroll

3 years agocreds-tool: expose new signed PCR policies in creds tool, too
Lennart Poettering [Wed, 17 Aug 2022 15:28:49 +0000 (17:28 +0200)] 
creds-tool: expose new signed PCR policies in creds tool, too

3 years agocreds-util: hook up new signed PCR policies
Lennart Poettering [Wed, 17 Aug 2022 15:28:05 +0000 (17:28 +0200)] 
creds-util: hook up new signed PCR policies

3 years agotpm2-util: extend TPM2 policies to optionally check PCR values against signed values
Lennart Poettering [Wed, 17 Aug 2022 15:21:57 +0000 (17:21 +0200)] 
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.

3 years agomeasure: add 'sign' verb
Lennart Poettering [Wed, 17 Aug 2022 16:40:42 +0000 (18:40 +0200)] 
measure: add 'sign' verb

3 years agoopenssl-util: add helper for calculating fingerprint of a DER public key
Lennart Poettering [Wed, 17 Aug 2022 08:02:02 +0000 (10:02 +0200)] 
openssl-util: add helper for calculating fingerprint of a DER public key

3 years agotpm2-util: allow external code to create tpm2 contexts
Lennart Poettering [Fri, 12 Aug 2022 13:36:14 +0000 (15:36 +0200)] 
tpm2-util: allow external code to create tpm2 contexts

3 years agotpm2-util: pick up 4 more symbols of tpm2-tss
Lennart Poettering [Fri, 12 Aug 2022 13:12:29 +0000 (15:12 +0200)] 
tpm2-util: pick up 4 more symbols of tpm2-tss

3 years agoCODING_STYLE: fix header level
Lennart Poettering [Thu, 8 Sep 2022 14:12:57 +0000 (16:12 +0200)] 
CODING_STYLE: fix header level

3 years agobootctl: don't start "bootctl list" output with a title line 24600/head
Lennart Poettering [Wed, 7 Sep 2022 16:23:36 +0000 (18:23 +0200)] 
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.

3 years agobootspec: don't follow symlinks when opening type1/type2 files
Lennart Poettering [Wed, 7 Sep 2022 16:22:11 +0000 (18:22 +0200)] 
bootspec: don't follow symlinks when opening type1/type2 files

let's not follow symlinks when going from enumeraiton dir to enumerated
file either.

3 years agobootspec: use chase_symlinks() where appropriate
Lennart Poettering [Wed, 7 Sep 2022 16:19:46 +0000 (18:19 +0200)] 
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.

3 years agoupdate TODO
Lennart Poettering [Wed, 7 Sep 2022 16:17:33 +0000 (18:17 +0200)] 
update TODO

3 years agoMerge pull request #24572 from DaanDeMeyer/repart-verity
Lennart Poettering [Thu, 8 Sep 2022 10:02:27 +0000 (12:02 +0200)] 
Merge pull request #24572 from DaanDeMeyer/repart-verity

repart: Add support for formatting verity partitions

3 years agoMerge pull request #24434 from medhefgo/boot-fixes
Lennart Poettering [Thu, 8 Sep 2022 09:17:12 +0000 (11:17 +0200)] 
Merge pull request #24434 from medhefgo/boot-fixes

boot: Small fixes

3 years agotpm2: add bind key
William Roberts [Wed, 7 Sep 2022 12:52:16 +0000 (07:52 -0500)] 
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>
3 years agotest: add test for sd_device_enumerator_add_match_parent() 24601/head
Yu Watanabe [Thu, 8 Sep 2022 06:21:21 +0000 (15:21 +0900)] 
test: add test for sd_device_enumerator_add_match_parent()

3 years agosd-device-enumerator: rewrite child enumeration without recursion
Yu Watanabe [Thu, 8 Sep 2022 05:57:41 +0000 (14:57 +0900)] 
sd-device-enumerator: rewrite child enumeration without recursion

3 years agosd-device-enumerator: do not fail when a directory vanishes on enumerate
Yu Watanabe [Thu, 8 Sep 2022 05:54:54 +0000 (14:54 +0900)] 
sd-device-enumerator: do not fail when a directory vanishes on enumerate

3 years agosd-device-enumerator: use test_matches() more
Yu Watanabe [Thu, 8 Sep 2022 06:55:23 +0000 (15:55 +0900)] 
sd-device-enumerator: use test_matches() more

3 years agoupdate TODO 24572/head
Daan De Meyer [Thu, 8 Sep 2022 06:43:50 +0000 (08:43 +0200)] 
update TODO

3 years agorepart: Add support for formatting verity partitions
Daan De Meyer [Mon, 5 Sep 2022 22:45:32 +0000 (00:45 +0200)] 
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

3 years agoMerge pull request #24587 from yuwata/sd-device-monitor-running-user-ns
Yu Watanabe [Thu, 8 Sep 2022 05:27:21 +0000 (14:27 +0900)] 
Merge pull request #24587 from yuwata/sd-device-monitor-running-user-ns

sd-device-monitor: relax sender uid check when running in user namespace

3 years agosd-device-monitor: relax sender uid check when running in user namespace 24587/head
Yu Watanabe [Tue, 6 Sep 2022 19:43:18 +0000 (04:43 +0900)] 
sd-device-monitor: relax sender uid check when running in user namespace

If sd-device-monitor is running in a user namespace, the sender uid is
not zero. Let's relax the verification in that case.

3 years agouid-range: move to src/basic/
Yu Watanabe [Wed, 7 Sep 2022 10:08:26 +0000 (19:08 +0900)] 
uid-range: move to src/basic/

To make the functions defined in the files usable by libsystemd library.

3 years agouid-range: error code tweak for uid_range_load_userns()
Lennart Poettering [Wed, 7 Sep 2022 16:25:37 +0000 (18:25 +0200)] 
uid-range: error code tweak for uid_range_load_userns()

Let's return ENOSYS if /proc/ is not mounted (as that's what we usually
return in that case in various helpers that operate on /proc/). Return
EOPNOTSUPP if the kernel simply doesn't support userns.

3 years agoMerge pull request #24571 from yuwata/dissect-loop-image-use-backing-file
Yu Watanabe [Wed, 7 Sep 2022 14:45:29 +0000 (23:45 +0900)] 
Merge pull request #24571 from yuwata/dissect-loop-image-use-backing-file

dissect: save image path to LoopDevice and use it when dissect loop device

3 years agorepart: Invert no_dropin_files boolean
Daan De Meyer [Tue, 6 Sep 2022 12:26:57 +0000 (14:26 +0200)] 
repart: Invert no_dropin_files boolean

3 years agorepart: Extract context dump into a separate function
Daan De Meyer [Mon, 5 Sep 2022 20:37:20 +0000 (22:37 +0200)] 
repart: Extract context dump into a separate function

3 years agodissect-image: drop unnecessary duplication of partition device node 24571/head
Yu Watanabe [Tue, 6 Sep 2022 01:50:19 +0000 (10:50 +0900)] 
dissect-image: drop unnecessary duplication of partition device node

3 years agodissect-image: reuse LoopDevice.node in dissect_image()
Yu Watanabe [Tue, 6 Sep 2022 13:43:47 +0000 (22:43 +0900)] 
dissect-image: reuse LoopDevice.node in dissect_image()

Currently, dissect_image() is only called through dissect_loop_device(),
and the LoopDevice object has device name. Hence, it is not necessary to
get device name in dissect_image().

3 years agodissect-image: drop currently unused arguments
Yu Watanabe [Tue, 6 Sep 2022 13:39:31 +0000 (22:39 +0900)] 
dissect-image: drop currently unused arguments

3 years agodissect-image: drop currently unused code
Yu Watanabe [Tue, 6 Sep 2022 13:50:33 +0000 (22:50 +0900)] 
dissect-image: drop currently unused code

Currently, dissect_image() is called only through dissect_loop_device(),
and image_path is always specified. Let's drop it.

3 years agodissect-image: use loop backing file or device node as name of the image
Yu Watanabe [Tue, 6 Sep 2022 01:58:26 +0000 (10:58 +0900)] 
dissect-image: use loop backing file or device node as name of the image

Note, currently, for each call of dissect_loop_device_and_warn(), the
specified name is equivalent to the path passed to loop_device_make_by_path().
Hence, this should not change the current behavios.

3 years agogpt-auto: use LoopDevice object to manage whole block disk
Yu Watanabe [Tue, 6 Sep 2022 01:25:56 +0000 (10:25 +0900)] 
gpt-auto: use LoopDevice object to manage whole block disk

3 years agodissect-image: use backing_file stored in LoopDevice object to generate image name
Yu Watanabe [Mon, 5 Sep 2022 20:37:13 +0000 (05:37 +0900)] 
dissect-image: use backing_file stored in LoopDevice object to generate image name

Follow-up for e374439f4b8def786031ddbbd7dfdae3a335d4d2 (#24322).

This also simplify the logic of generating image name from image path.

3 years agoloop-util: save backing file of loopback block device
Yu Watanabe [Mon, 5 Sep 2022 20:19:46 +0000 (05:19 +0900)] 
loop-util: save backing file of loopback block device

It will be used in later commits.

3 years agoloop-util: move device_has_block_children() to blockdev-util.c
Yu Watanabe [Mon, 5 Sep 2022 20:01:34 +0000 (05:01 +0900)] 
loop-util: move device_has_block_children() to blockdev-util.c

As the function is not only for loopback block device.

No actual code changes, just refactoring.

3 years agoblockdev-util: check if provided sd_device is for a whole block device
Yu Watanabe [Mon, 5 Sep 2022 20:00:49 +0000 (05:00 +0900)] 
blockdev-util: check if provided sd_device is for a whole block device

And split out partition_generator_new(), to make it usable in other
functions.

3 years agoblockdev-util: make block_device_remove_all_partitions() take sd_device object
Yu Watanabe [Mon, 5 Sep 2022 19:46:04 +0000 (04:46 +0900)] 
blockdev-util: make block_device_remove_all_partitions() take sd_device object

Then, it is not necessary to recreate sd_device object when we already
have.