Commit Graph
59784 Commits
Author SHA1 Message Date
Yu Watanabe 6d64cb0625 Merge pull request #23087 from yuwata/udev-watch
udev: resolve race in saving inotify watch handle
2022-09-12 23:41:00 +09:00
Yu Watanabe 75a5a143bb Merge pull request #23043 from yuwata/udev-node-use-flock
udev-node: use flock() for symlink stack directory
2022-09-12 23:40:34 +09:00
Ansgar Burchardt 4167e2135e base-filesystem.c: add trailing zero byte for s390x entry 2022-09-12 23:35:09 +09:00
Hans de Goede 5092f7c86d hwdb: Fix Acer Aspire One AOD270/Packard Bell Dot keymappings
The Acer Aspire One AOD270 and the same hardware rebranded as
Packard Bell Dot SC need a couple of keymap fixups:

1. The switch-video-mode key does not do anything. Standard acer-wmi
   maps scancode 0x61 to KEY_IGNORE since typically these events are
   duplicate with the ACPI video bus. But on these models the ACPI video
   bus does not send events for this key, so map it.

2. The Brightness up / down hotkeys send atkbd scancode 0xce / 0xef
   which by default are mapped to KEY_KPPLUSMINUS and KEY_MACRO.
   These actually are duplicate events with the ACPI video bus,
   so map these to KEY_IGNORE.
2022-09-12 22:02:54 +09:00
Lennart Poettering 1135779156 update TODO 2022-09-12 11:03:42 +01:00
Lennart Poettering 4e0ceefeb6 update TODO 2022-09-12 00:13:44 +01:00
Yu Watanabe ee27501225 test: add testcase for udev-watch 2022-09-12 01:36:06 +09:00
Yu Watanabe 3fb94c7062 sd-device: move device_new_from_watch_handle_at() to udev-watch.c
And drop unused watch handle related functions.
2022-09-12 01:36:06 +09:00
Yu Watanabe 790da548b0 udev: warn on udev_watch_{begin,end}() failure 2022-09-12 01:36:06 +09:00
Yu Watanabe 4443b1857b udev: drop unnecessary call of udev_watch_end()
As it is already called by udev_event_execute_rules().
2022-09-12 01:36:06 +09:00
Yu Watanabe 2369152394 udev: use rm_rf() to remove old watch directory 2022-09-12 01:36:02 +09:00
Yu Watanabe 691a596da1 udev-watch: remove symlink for saving inotify watch handle only when it is owned by the processing device
Before removing symlinks that stores watch handles, this makes udev
worker check if the symlink is owned by the processing device.
Then, we can avoid TOCTOU and drop the try-and-wait loop.

This partially reverts 2d3af41f0e.
2022-09-12 01:32:32 +09:00
Yu Watanabe cd66f972d1 udev: ignore IN_IGNORED inotify event earlier 2022-09-12 01:23:08 +09:00
Yu Watanabe ea8213dc47 udev: not necessary to return 1 from on_inotify() 2022-09-12 01:23:08 +09:00
Yu Watanabe 03f48fc7c3 Merge pull request #24637 from mrc0mmand/TEST-75-tweaks
test: make the resolved notifications check a bit more robust
2022-09-12 01:17:36 +09:00
Frantisek Sumsal e3cccd3c2b 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'.
```
2022-09-11 14:29:34 +02:00
Frantisek Sumsal 7906b790e4 test: install jq into all images 2022-09-11 14:16:34 +02:00
Frantisek Sumsal 6c14f9ae57 Merge pull request #24593 from jamacku/main
Update `advanced-issue-labeler` action - `@v1` -> `@v2`
2022-09-10 19:42:26 +00:00
Lennart Poettering 251d2ea269 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
2022-09-10 20:58:41 +02:00
Yu Watanabe 706c9a30ac 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.
2022-09-10 08:00:44 +00:00
Yu Watanabe 9a18458834 Merge pull request #24618 from yuwata/udev-split-synthesizing
udev: shorten synthesize_change() a bit
2022-09-10 02:52:54 +09:00
Yu Watanabe 86f9b69a6a blockdev-util: split out blockdev_reread_partition_table()
No functional changes, just refactoring.
2022-09-10 01:19:41 +09:00
Lennart Poettering 329984037b Merge pull request #24458 from poettering/stub-embedd-sig
optionally, embed PCR signature and public key in new sd-stub PE sections
2022-09-09 18:18:37 +02:00
Yu Watanabe 9409174ee7 udevd: use partition enumerator at one more place
No functional changes, just refactoring.
2022-09-10 00:48:34 +09:00
Yu Watanabe e97589cf38 Merge pull request #24609 from yuwata/sd-device-enumerator-check-sysname
sd-device-enumerator: check sysname earlier
2022-09-09 23:32:15 +09:00
Yu Watanabe 9cce72ee5d Merge pull request #24611 from yuwata/loop-util-refactoring
loop-util: several cleanups
2022-09-09 23:31:19 +09:00
Yu Watanabe e0993236d3 blockdevi-util: also check sysname when enumerating partitions 2022-09-09 22:30:19 +09:00
Yu Watanabe 88b5080ea9 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.
2022-09-09 21:16:37 +09:00
Yu Watanabe 89ad604839 sd-device-enumerator: always ignore ENOENT from opendir()
But logs all errors.
2022-09-09 21:16:37 +09:00
Yu Watanabe 0f519b9c2e sd-device-enumerator: check sysname earlier 2022-09-09 21:16:32 +09:00
Lennart Poettering 1d5f14ef3d update TODO 2022-09-09 11:53:06 +02:00
Lennart Poettering 6d856e26a7 man: say early what a unified kernel image/UKI is 2022-09-09 11:53:06 +02:00
Lennart Poettering 4889e809be 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.
2022-09-09 11:53:05 +02:00
Lennart Poettering 2deca517f6 man: document the new .pcrsig/.pcrpkey sections for unified kernel images 2022-09-09 11:53:05 +02:00
Lennart Poettering f51b49c675 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.
2022-09-09 11:31:04 +02:00
Lennart Poettering 23002b45b1 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.
2022-09-09 11:30:04 +02:00
Lennart Poettering df7ee6f8b0 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.
2022-09-09 11:28:38 +02:00
Lennart Poettering e139565b01 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)
2022-09-09 11:27:08 +02:00
Suraj Krishnan cb456374e0 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
2022-09-09 09:22:57 +01:00
Yu Watanabe 761787fc88 Merge pull request #24557 from yuwata/repart
repart: fix partition size calculation
2022-09-09 09:32:07 +09:00
Yu Watanabe 3b19e16056 test-58-repart: add test case for issue #24553 2022-09-09 05:53:01 +09:00
Yu Watanabe 9ccceb9d2b 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.
2022-09-09 05:52:57 +09:00
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