1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-26 03:22:00 +03:00
Commit Graph

67882 Commits

Author SHA1 Message Date
Yu Watanabe
b63f09e4ee sd-journal: merge two bump_entry_array() calls
No functional changes, just refactoring.
2023-09-30 20:10:15 +09:00
Yu Watanabe
b7264911aa sd-journal: make bump_entry_array() return positive when a valid offset found
When it returns 0 offset, then the subsequent
journal_file_move_to_object() will fail. Let's return
generic_array_get() earlier in such situation.
2023-09-30 20:10:15 +09:00
Yu Watanabe
eb6ba87344 sd-journal: drop redundant re-read of entry array object
This effectively reverts d9b61db922.

In the do-while loop, we do not read any other entry array object, hence
the current object is always in the mmap cache and not necessary to re-read it.
2023-09-30 20:10:15 +09:00
Lennart Poettering
cb88da8254 logind: add HANDLE_ACTION_IS_SLEEP() and HANDLE_ACTION_IS_SHUTDOWN() helpers
Let's group this HandleAction types in nice little helpers.

Prompted by #28579
2023-09-30 10:56:28 +01:00
Luca Boccassi
4f45ae4d1d
Merge pull request #29380 from medhefgo/ms-certs
man: man: Adjust Microsoft UEFI certificate links
2023-09-30 09:51:58 +01:00
Frantisek Sumsal
e11fd4df14
Merge pull request #29378 from mrc0mmand/more-test-tweaks
test: a couple of TEST-82-SOFTREBOOT tweaks
2023-09-30 07:35:35 +00:00
Jan Janssen
658394e826 man: Verify Microsoft keys 2023-09-30 09:30:46 +02:00
Jan Janssen
5f5160d3b2 man: Adjust Microsoft UEFI certificate links
The files were fixed to all be properly der encoded.
2023-09-30 09:30:46 +02:00
Luca Boccassi
69f99d1e4e
Merge pull request #29363 from medhefgo/elf2efi
elf2efi: Rework to allow using any linker
2023-09-29 23:01:53 +01:00
Frantisek Sumsal
bd0f9858f7 test: don't pipe the whole journal through jq
Doing that in VMs without acceleration is prohibitively expensive (i.e.
20+ seconds in the C8S job). Thankfully, the recent [0] --lines=+n syntax
makes this all quite easy to fix.

[0] 8d6791d2aa
2023-09-29 23:26:15 +02:00
Frantisek Sumsal
82abce7a89 test: use Type=exec for the auxiliary services
To make sure the respective binaries are exec()ed before moving further
with the test.
2023-09-29 22:10:42 +02:00
Frantisek Sumsal
47f6baccfe test: shutdown the machine on fail after soft-reboot
Since the soft-reboot drops the enqueued end.service, we won't shutdown
the test VM if the test fails and have to wait for the watchdog to kill
us (which may take quite a long time). Let's just forcibly kill the
machine instead to save CI resources.
2023-09-29 22:07:12 +02:00
Lennart Poettering
68849251a2
Merge pull request #29344 from poettering/tpm2-setup
tpm2-setup: set up TPM2 Storage Root Key (SRK) in a separate service
2023-09-29 21:56:28 +02:00
Lennart Poettering
81df5cd185 sysext: validate against the right API level
Let's ake sure we check confexts against the confext api level, and
sysext against the sysext api level.

Previously the test would simply be skipped for confexts...
2023-09-29 21:54:46 +02:00
Lennart Poettering
ef2dbc9c40 pe-binary: actually check if PE binary is UEFI binary when determining if UKI
If it's not a UEFI binary, then it's not a UKI.
2023-09-29 21:54:16 +02:00
Luca Boccassi
16f094cfbb
Merge pull request #29374 from mrc0mmand/test-tweaks
test: use "test-" prefix for units
2023-09-29 19:07:59 +01:00
Lennart Poettering
1a9454a942 update TODO 2023-09-29 19:36:06 +02:00
Lennart Poettering
2e64cb71b9 tpm2-setup: add new early boot tool for initializing the SRK
This adds an explicit service for initializing the TPM2 SRK. This is
implicitly also done by systemd-cryptsetup, hence strictly speaking
redundant, but doing this early has the benefit that we can parallelize
this in a nicer way. This also write a copy of the SRK public key in PEM
format to /run/ + /var/lib/, thus pinning the disk image to the TPM.
Making the SRK public key is also useful for allowing easy offline
encryption for a specific TPM.

Sooner or later we should probably grow what this service does, the
above is just the first step. For example, the service should probably
offer the ability to reset the TPM (clear the owner hierarchy?) on a
factory reset, if such a policy is needed. And we might want to install
some default AK (?).

Fixes: #27986
Also see: #22637
2023-09-29 19:36:04 +02:00
Lennart Poettering
baab1b3faa
Merge pull request #29234 from ddstreet/tpm2_marshal_serialize_handle_index
add tpm2 functions for marshalling blobs, serializing handles, and handle/index conversion
2023-09-29 19:15:15 +02:00
Jan Janssen
823bf39a49 elf2efi: Add GNU_RELRO support 2023-09-29 17:05:11 +02:00
Jan Janssen
79ae0d0b3e ci: Update compiler build matrix
Given that gold is pretty much unmaintained and does not support
`-static-pie` for bootloader components it should be safe to drop.

Also switch to clang-17 while we're at it.
2023-09-29 16:56:30 +02:00
Jan Janssen
0b042d3de8 boot: Lift linker requirements
The biggest reason for forcing bfd was the use of linker scrips. Since
we don't rely on those anymore we can lift the requirement.

The biggest issue is gold as it does not understand -static-pie. Given
that it's pretty much on life support it's safe to just declare it not
supported anymore.

Don't link addons with libefi as clang/lld is sometimes very eager to
include memset etc., causing needless binary bloat and link errors with
LTO.

Fixes: #29165
2023-09-29 16:56:30 +02:00
Jan Janssen
898e9edc46 elf2efi: Add --copy-sections option
This makes the special PE sections available again in our output EFI
images.

Since the compiler provides no way to mark a section as not allocated,
we use GNU assembler syntax to emit the sections instead. This ensures
the section data isn't emitted twice as load segments will only contain
allocating input sections.
2023-09-29 16:56:30 +02:00
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
Dan Streetman
13cf98f362 tpm2: add tpm2_index_to_handle() and tpm2_index_from_handle()
Adjust the tpm2_esys_handle_from_tpm_handle() function into better-named
tpm2_index_to_handle(), which operates like tpm2_get_srk() but allows using any
handle index. Also add matching tpm2_index_from_handle().

Also change the references to 'location' in tpm2_persist_handle() to more
appropriate 'handle index'.
2023-09-29 10:14:28 -04:00
Dan Streetman
1eff424295 tpm2: add tpm2_serialize() and tpm2_deserialize()
Add functions to perform serialization and deserialization of ESYS_TR objects.
2023-09-29 10:14:28 -04:00
Dan Streetman
653c3fe908 tpm2: add tpm2_marshal_blob() and tpm2_unmarshal_blob()
Add functions to marshal and unmarshal our 'blob' object.
2023-09-29 10:14:28 -04:00
Frantisek Sumsal
d1e8485b4a test: use /run/ for test configuration 2023-09-29 16:07:05 +02:00
Frantisek Sumsal
6bbc1a2464 test: use "test-" prefix for units
So the coverage-related drop-in [0] can kick in to avoid errors with
DynamicUser=true. Also, to not make the test confusing with this change,
replace "nft-test" with "test-nft" everywhere.

[0] See test/README.testsuite, section "Code coverage"
2023-09-29 15:55:53 +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
4a9e03aa6b core: Make private /dev read-only after populating it 2023-09-29 11:02:06 +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