Commit Graph
67553 Commits
Author SHA1 Message Date
Jan Janssen 7d6fd7f099 elf2efi: Add next_section_address helper 2023-09-29 16:56:30 +02:00
Jan Janssen 5713c50d84 elf2efi: Check ELF image base if possible 2023-09-29 16:56:30 +02:00
Jan Janssen 142f0c61a3 elf2efi: Rework ELF section conversion
The main reason we need to apply a whole lot of logic to the section
conversion logic is because PE sections have to be aligned to the page
size (although, currently not even EDK2 enforces this). The process of
achieving this with a linker script is fraught with errors, they are a
pain to set up correctly and suck in general. They are also not
supported by mold, which requires us to forcibly use bfd, which also
means that linker feature detection is easily at odds as meson has a
differnt idea of what linker is in use.

Instead of forcing a manual ELF segment layout with a linker script we
just let the linker do its thing. We then simply copy/concatenate the
sections while observing proper page boundaries.
Note that we could just copy the ELF load *segments* directly and
achieve the same result. Doing this manually allows us to strip sections
we don't need at runtime like the dynamic linking information (the
elf2efi conversion is effectively the dynamic loader).

Important sections like .sbat that we emit directly from code will
currently *not* be exposed as individual PE sections as they are
contained within the ELF segments. A future commit will fix this.
2023-09-29 16:56:30 +02:00
Lennart Poettering 9551aa707d tpm2: move measurement log to /run/log/ (from /var/log/)
I have no idea what went on in my mind when I used a path in /var/ for
the tpm2 event log we now keep for userspace measurements. The
measurements are only valid for the current boot, hence should not be
persisted (in particular as they cannot be rotated, hence should not
grow without bounds).

Fix that, simply move from /var/log/ to /run/log/.
2023-09-29 14:35:56 +02:00
Daan De Meyer 4444564a95 Merge pull request #29193 from keszybz/path-util-adjustment
Make unit mangling follow paths
2023-09-29 11:33:12 +02:00
Daan De Meyer 10d14c872f Merge pull request #29241 from poettering/pidref-watch
pid1: move unit_watch_pid()/unit_unwatch_pid() logic over to PidRef
2023-09-29 11:32:19 +02:00
Valentin Lefebvre 750674da0d ukify: explicitly import attribute
* Explicitly import attributes rsa and serialization from cryptography.hazmat

Signed-off-by: Valentin Lefebvre <valentin.lefebvre@suse.com>
2023-09-29 11:31:12 +02:00
Daan De Meyer 6ab6da0d1e Merge pull request #29183 from ddstreet/tpm2_openssl_functions
Add openssl functions for use by TPM2 sealing calculations
2023-09-29 10:25:39 +02:00
Luca Boccassi e89bf66fa2 automount: fix unused value coverity warnings
'r' is no longer used, so no point in setting it before returning

CID#1522310
CID#1522312

Follow-up for bfeb10911e
2023-09-29 09:17:59 +01:00
Maanya Goenka f660c7fa56 fix: do not check/verify slice units if recursive errors are to be ignored
Before this fix, when recursive-errors was set to 'no' during a systemd-analyze
verification, the parent slice was checked regardless. The 'no' setting means that,
only the specified unit should be looked at and verified and errors in the slices should be
ignored. This commit fixes that issue.

Example:

Say we have a sample.service file:

[Unit]
Description=Sample Service

[Service]
ExecStart=/bin/echo "a"
Slice=support.slice

Before Change:

systemd-analyze verify --recursive-errors=no maanya/sample.service
Assertion 'u' failed at src/core/unit.c:153, function unit_has_name(). Aborting.
Aborted (core dumped)

After Change:
systemd-analyze verify --recursive-errors=no maanya/sample.service
{No errors}
2023-09-28 23:32:02 +01:00
Lennart Poettering d94dc50c46 update TODO 2023-09-28 23:22:58 +02:00
Lennart Poettering 495e75ed5c core: move pid watch/unwatch logic of the service manager to pidfd
This makes sure unit_watch_pid() and unit_unwatch_pid() will track
processes by pidfd if supported. Also ports over some related code.
Should not really change behaviour.

Note that this does *not* add support waiting for POLLIN on the pidfds
as additional exit notification. This is left for a later commit (this
commit is already large enough), in particular as that would add new
logic and not just convert existing logic.
2023-09-28 23:22:58 +02:00
Lennart Poettering c407bfa68f test-watch-pid: use a real PID, not a made up one
This matters once we track processes with pidfds rather than just pid_t,
because made up PIDs likely won't exist.

The essence of the test remains unmodified, we just use a real, existing
PID instead of 4711.
2023-09-28 23:22:58 +02:00
Lennart Poettering ec8dc83530 pidref: add pidref_verify() helper
This new helper can be used after reading process info from procfs, to
verify that the data that was just read actually matches the pidfd, and
does not belong to some new process that just reused the numeric PID of
the process we originally pinned.
2023-09-28 23:22:58 +02:00
Lennart Poettering 9cb7e49f11 pidref: add pidref_hash_ops
This adds a "hash_ops" structure, which allows using PidRef structures
as keys in Hashmap and Set objects.
2023-09-28 23:22:58 +02:00
Lennart Poettering 837659825f pidref: add helpers for managing PidRef on the heap
Usually we want to embed PidRef in other structures, but sometimes it
makes sense to allocate it on the heap in case it should be used
standalone. Add helpers for that.

Primary usecase: use as key in Hashmap objects, that for example map
process to unit objects in PID 1.

This adds pidref_free()/pidref_freep() for freeing such an allocated
struct, as well as pidref_dup() (for duplicating an existing PidRef
on the heap 1:1), and pidref_new_pid() (for allocating a new PidRef from a
PID).
2023-09-28 23:22:58 +02:00
Lennart Poettering dcfcea6d02 pidref: add PIDREF_MAKE_FROM_PID()
This helper truns a pid_t into a PidRef. It's different from
pidref_set_pid() in being "passive", i.e. it does not attempt to acquire
a pidfd for the pid.

This is useful when using the PidRef as a lookup key that shall also
work after a process is already dead, and hence no conversion to a pidfd
is possible anymore.
2023-09-28 23:22:58 +02:00
Lennart Poettering 12c7d27b65 cgroup-util: add cg_read_pidref() helper
Just like cg_read_pid() but returns a PidRef
2023-09-28 23:22:58 +02:00
Luca Boccassi 76dc9e249f Merge pull request #29249 from poettering/pid1-error-message
pid1: refactoring of unit state machine logging and unit timer refactoring
2023-09-28 22:18:15 +01:00
Bertrand Jacquin 7406ebd5b6 resolved: register ipv4only.arpa are private domain
From RFC 8880:

Because the 'ipv4only.arpa' zone has to be an insecure delegation,
DNSSEC cannot be used to protect these answers from tampering by
malicious devices on the path.

Consequently, the 'ipv4only.arpa' zone MUST be an insecure delegation to
give DNS64/NAT64 gateways the freedom to synthesize answers to those
queries at will, without the answers being rejected by DNSSEC-capable
resolvers. DNSSEC-capable resolvers that follow this specification MUST
NOT attempt to validate answers received in response to queries for the
IPv6 AAAA address records for 'ipv4only.arpa'. Note that the name
'ipv4only.arpa' has no use outside of being used for this special DNS
pseudo-query used to learn the DNS64/NAT64 address synthesis prefix, so
the lack of DNSSEC security for that name is not a problem.

See: https://datatracker.ietf.org/doc/html/rfc8880#name-security-considerations
2023-09-28 21:55:00 +01:00
Dan Streetman 8c2205bb1c openssl: add kdf_ss_derive()
Add function to perform KDF-SS ("concat" KDF).

While Openssl allows a digest, HMAC, or KMAC for the auxiliary function H, this
currently only allows using a digest for H.
2023-09-28 16:44:42 -04:00
Dan Streetman 779b80d803 openssl: add ecc_edch()
Add function to perform ECC EDCH.
2023-09-28 16:44:42 -04:00
Dan Streetman 58f215a0ac openssl: add openssl_cipher_many()
Add function to perform openssl cipher operations.
2023-09-28 16:44:42 -04:00
Dan Streetman a65a25bec7 openssl: add kdf_kb_hmac_derive()
Add function to perform key-based (KB) key derivation function (KDF) using
hash-based message authentication code (HMAC).

Also alphabetize openssl-util.c header list, and include string-util.h.
2023-09-28 16:44:42 -04:00
Dan Streetman 816b1dc4eb openssl: add rsa_oaep_encrypt_bytes()
Add function to encrypt bytes, similar to rsa_encrypt_bytes() but using OAEP
(Optimal Asymmetric Encryption Padding).
2023-09-28 16:44:42 -04:00
Dan Streetman a95e8fa2a3 openssl: add openssl_hmac_many()
Add function to perform HMAC on multiple buffers.

Also update test-openssl with associated testing, and replace some memcmp()
with memcmp_nn().
2023-09-28 16:44:42 -04:00
Dan Streetman 11f7bc5e9c openssl: replace openssl_hash() with openssl_digest()
The openssl_hash() function was used only by string_hashnum(); change it to use
openssl_digest() instead.
2023-09-28 16:44:42 -04:00
Dan Streetman bed4831ce2 openssl: add openssl_digest_many()
Add function to perform openssl digest calculation on multiple buffers.
2023-09-28 16:44:42 -04:00
Dan Streetman c52a003dc8 openssl: add openssl_digest_size()
Add function to get digest hash size for provided digest name.
2023-09-28 16:44:13 -04:00
Luca Boccassi 081c50ed3c Merge pull request #29361 from keszybz/kernel-install-work
Advertise installkernel ↔ kernel-install duality
2023-09-28 17:16:15 +01:00
Daan De Meyer eafa923f81 Remove json_variant_merge_pair() in favor of json_variant_set_field_non_null() 2023-09-28 17:13:11 +01:00
Luca Boccassi 1e49f4ed8b Merge pull request #28545 from bluca/softreboot_survive
pid1: add SurviveFinalKillSignal= to skip units on final sigterm/sigkill spree
2023-09-28 17:12:03 +01:00
Daan De Meyer 67c92f3fec kmod-setup: Load virtiofs and virtio_pci early
There's no way for us to wait for specific virtiofs tags to appear,
so we have to try and make sure that the tags are all available by
the time we try to mount any virtiofs tag. Let's try to do that by
loading the necessary modules as early as we can.
2023-09-28 15:21:50 +01:00
наб e2e0125921 show-logs: add assert and fix local variable type
Follows-up for: 0693e6b246

#29355
2023-09-28 15:21:15 +01:00
Mike Yuan a82b8b3dc8 core: mark units as need daemon-reload if unit file operations are
performed

systemctl would issue daemon-reload after unit file operations
(enable/disable/preset/...) succeed. However, such operations
are not atomic, meaning that the unit file state could still change
even if the operation generally fails, and the unit_file_state
cached by manager becomes outdated.

Fixes #29341
2023-09-28 15:19:24 +01:00
Luca Boccassi 13b3af4aa2 core: improve error message when setting up service mounts
Right now we include the private working directory when we say some files
where not found, which is confusing. Strip it from the error string.

For example, with a BindPaths=/var/bar that does not exist on the host:

Before:

  foo.service: Failed to set up mount namespacing: /run/systemd/unit-root/var/bar: No such file or directory

After:

  foo.service: Failed to set up mount namespacing: /var/bar: No such file or directory
2023-09-28 15:19:03 +01:00
Luca Boccassi 3cb5d34ce0 Merge pull request #29295 from valentindavid/valentindavid/sysupdate-patterns-in-directory
sysupdate: Allow patterns to match path with directories
2023-09-28 15:18:45 +01:00
Luca Boccassi 8e78e3b620 Merge pull request #29359 from poettering/bootctl-uki-measured
bootctl: show whether we booted in a measured UKI in status output (plus some minor other stuff)
2023-09-28 15:18:12 +01:00
Luca Boccassi 2c0ca3e398 docs: note root storage daemons can now also use SurviveFinalKillSignal=yes 2023-09-28 13:48:14 +01:00
Frantisek Sumsal d37b9154a7 test: check soft-reboot behavior wrt argv[0][0] == '@' 2023-09-28 13:48:14 +01:00
Luca Boccassi 559214cbbd pid1: add SurviveFinalKillSignal= to skip units on final sigterm/sigkill spree
Add a new boolean for units, SurviveFinalKillSignal=yes/no. Units that
set it will not have their process receive the final sigterm/sigkill in
the shutdown phase.

This is implemented by checking if a process is part of a cgroup marked
with a user.survive_final_kill_signal xattr (or a trusted xattr if we
can't set a user one, which were added only in kernel v5.7 and are not
supported in CentOS 8).
2023-09-28 13:48:14 +01:00
Lennart Poettering 69feab97f9 update TODO 2023-09-28 13:22:45 +02:00
Zbigniew Jędrzejewski-Szmek 5342eb4633 Rework unit_name_mangle_with_suffix() to (very slightly) simplify the path
'systemctl status /../dev' now looks for 'dev.mount', not '-..-dev.service',
and 'systemctl status /../foo' looks for 'foo.mount', not '-..-foo.service'. I
think this much more useful. I think the escaping is not very useful, so I plan
to submit a later series which changes that behaviour. But I think this first
step here is already useful on its own.

Note that the patch is smaller than it seems: before, is_device_path() would
return true only for absolute paths, so moving of is_device_path() under the
path_is_absolute() conditional doesn't influence the logic.
2023-09-28 13:09:25 +02:00
Zbigniew Jędrzejewski-Szmek 9ec4f7c7a4 exec-util: print executed commands in do_execute()
kernel-install uses do_execute(). We would log whenever a spawned child
finished, but we would not log anything when the child is launched. When the
children log output without a prefix (as the kernel-install plugins do), it
is hard to see where that output is coming from.
2023-09-28 12:46:22 +02:00
Zbigniew Jędrzejewski-Szmek eb25844f83 kernel-install: describe usage as installkernel
For us, this is a compatibility mode, but most likely it is there to stay: the
kernel Makefile's install target expects to be able to call /bin/installkernel.
We want people who build their own kernels to use this, so that they use
kernel-install and get support for all the functionality provided by it,
including building of UKIs and other new features. So let's actually advertise
that this exists and works.
2023-09-28 12:40:28 +02:00
Bertrand Jacquin bdf58b47c3 resolved: never respond to .alt pseudo-TLD.
From RFC 9476:

Because names beneath .alt are in an alternative namespace, they have no
significance in the regular DNS context. DNS stub and recursive
resolvers do not need to look them up in the DNS context.

See: https://datatracker.ietf.org/doc/html/rfc9476#name-the-alt-namespace
2023-09-28 12:07:47 +02:00
Lennart Poettering 4ed9e2619c bootctl: highlight SecureBoot enabled state in green 2023-09-28 12:07:15 +02:00
Lennart Poettering a730a8f608 bootctl: if we can't access the ESP, show this in regular status output 2023-09-28 12:07:15 +02:00
Mike Yuan b92abd712e Merge pull request #29333 from YHNdnzj/systemctl-warn-half-masked
systemctl-enable: warn if disabled/masked unit has active triggering units
2023-09-28 17:58:21 +08:00
Valentin David deafbeb0b9 sysupdate: Add documentation for new MatchPattern behavior 2023-09-28 11:41:29 +02:00