Commit graph

64199 commits

Author SHA1 Message Date
Lennart Poettering 1a3704dcc3 nspawn: port over to /supervisor/ subcgroup being delegated to nspawn
Let's make use of the new DelegateSubgroup= feature and delegate the
/supervisor/ subcgroup already to nspawn, so that moving the supervisor
process there is unnecessary.
2023-04-27 12:18:32 +02:00
Lennart Poettering f8371dbd56 udev: port to DelegateSubgroup= 2023-04-27 12:18:32 +02:00
Lennart Poettering 3975e3f8ae units: make system service manager create init.scope subcgroup for user service manager
This one is basically for free, since the service manager is already
prepared for being invoked in init.scope. Hence let's start it in the
right cgroup right-away.
2023-04-27 12:18:32 +02:00
Lennart Poettering bcd9b98159 core: change ownership of subcgroup we create recursively, it shall be owned by the user delegated to
If we create a subcroup (regardless if the '.control' subgroup we
always created or one configured via DelegateSubgroup=) it's inside of
the delegated territory of the cgroup tree, hence it should be owned
fully by the unit's users. Hence do so.
2023-04-27 12:18:32 +02:00
Lennart Poettering 18c1e481b6 execute: don't apply journal + oomd xattrs to subcgroup
We don't need to apply the journal/oomd xattrs to the subcgroups we add,
since those daemons already look for the xattrs up the tree anyway.
Hence remove this.

This is in particular relevant as it means later changes to the xattr
don#t need to be replicated on the subcgroup either.
2023-04-27 12:18:32 +02:00
Lennart Poettering a8b993dc11 core: add DelegateSubgroup= setting
This implements a minimal subset of #24961, but in a lot more
restrictive way: we only allow one level of subcgroup (as that's enough
to address the no-processes in inner cgroups rule), and does not change
anything about threaded cgroup logic or similar, or make any of this new
behaviour mandatory.

All this does is this: all non-control processes we invoke for a unit
we'll invoke in a subgroup by the specified name.

We'll later port all our current services that use cgroup delegation
over to this, i.e. user@.service, systemd-nspawn@.service and
systemd-udevd.service.
2023-04-27 12:18:32 +02:00
Lennart Poettering 1a56b0c05d cgroup: rework how we validate/escape cgroups
Let's clean up validation/escaping of cgroup names. i.e. split out code
that tests if name needs escaping. Return proper error codes, and extend
test a bit.
2023-04-27 12:17:58 +02:00
Yu Watanabe 49c778e6bf
Merge pull request #27413 from yuwata/core-job-cleanups
core/job: cleanups for job ID
2023-04-27 12:29:29 +09:00
Lennart Poettering e76b3d4ed2 units: restrict hugepages fs a bit
suid binaries and device nodes should not be placed there, hence forbid
it.

Of all the API VFS we mount from PID 1 or via a unit file this one is
the only one where we didn't add MS_NODEV/MS_NOSUID. Let's address that,
since there's really no reason why device nodes or suid binaries would
be placed in hugetlbfs.
2023-04-27 12:28:50 +09:00
Yu Watanabe a02287eab3 core/service: make service_add_fd_store() always consume provided fd
No functional change, just refactoring.
2023-04-27 01:36:58 +01:00
Lennart Poettering 637d57ddfd image-policy: split out code that "extends" underspecified partition policy flags
When encoding partition policy flags we allow parts of the flags to be
"unspecified" (i.e. entirely zeros), which when actually checking the
policy we'll automatically consider equivalent to "any" (i.e. entirely
ones). This "extension" of the flags was so far done as part of
partition_policy_normalized_flags(). Let's split this logic out into a
new function partition_policy_flags_extend() that simply sets all bits
in a specific part of the flags field if they were entirely zeroes so
far.

When comparing policy objects for equivalence we so far used
partition_policy_normalized_flags() to compare the per-designator flags,
which thus meant that "underspecified" flags, and fully specified ones
that are set to "any" were considered equivalent. Which is great.
However, we forgot to do that for the fallback policy flags, the flags
that apply to all partitions for which no explicit policy flags are
specified.

Let's use the new partition_policy_flags_extend() call to compare them
in extended form, so that there two we can hide the difference between
"underspecified" and "any" flags.
2023-04-27 01:35:06 +01:00
Zbigniew Jędrzejewski-Szmek 048bcb9d1f man: use ukify more in systemd-measure examples
ukify supports signing with multiple keys, so show an example of this, and just
let ukify print the calls to systemd-measure that will be done.

This also does other small cleanups:
- Use more realistic names in examples
- Use $ as the prompt for commands that don't require root (most don't).
  Once we switch to operations that don't require a TPM, we should be able to get
  rid of the remaining calls that require root.
- Ellipsize or linebreak various parts
- Use --uname. We warn if it is not specified and we have to do autodetection, so
  let's nudge people towards including it rather than not.

Follow-up for e069c57f06.
2023-04-27 00:25:09 +01:00
Luca Boccassi 2df327f6f6
Merge pull request #26877 from yuwata/fuzz-journal-remote
fuzz-journal-remote: several cleanups
2023-04-27 00:05:01 +01:00
Luca Boccassi 66a0ee55d8
Merge pull request #27355 from fbuihuu/kbd-improve-vc2x11-conversion
locale: improve vc -> x11 keyboard conversion
2023-04-26 23:37:53 +01:00
Luca Boccassi 68b12e2d56
Merge pull request #27421 from bluca/coredump_filter
CoredumpFilter: fix stack overflow and invalid assignment with 'all'
2023-04-26 23:22:59 +01:00
Lennart Poettering 8c9f0d83c2 image-policy: correct two comments 2023-04-26 22:24:58 +02:00
Lennart Poettering f351e951d3 update TODO 2023-04-26 22:21:19 +02:00
Daan De Meyer fec81dedfd
Merge pull request #27415 from DaanDeMeyer/verity-minimize
repart: Add Minimize= support for verity hash partitions
2023-04-26 18:55:51 +02:00
Daan De Meyer c00f0634ad
Merge pull request #27419 from yuwata/sd-journal-entry-item
sd-journal: skip invalid entry item
2023-04-26 18:35:26 +02:00
Yu Watanabe aafb96d514 core/job: use new job ID when we failed to deserialize job ID
This is for the case when we fail to deserialize job ID.
In job_install_deserialized(), we also check the job type, and that is
for the case when we failed to deserialize the job.
Let's gracefully handle the failure in deserializing the job ID.
This is paranoia, and just for safety. Should not change any behavior.
2023-04-27 00:36:41 +09:00
Yu Watanabe 3e1aec3036 core/job: handle job ID overflow or conflict more sanely
This is paranoia, and just for safety. Should not change any behavior.
2023-04-27 00:36:24 +09:00
Yu Watanabe ace15701c1 core/job: fix indentation 2023-04-27 00:36:24 +09:00
Yu Watanabe 6ff134004d core/job: add one more assertion
In this stage, the unit should not have installed job of the type.
2023-04-27 00:36:24 +09:00
Yu Watanabe c49dfd8911 core/transaction: use hashmap_remove_value() to make not remove job with same ID
When we fail to deserialize job ID, or the current_job_id is overflowed,
we may have jobs with the same ID.
This is paranoia, and just for safety.
Note, we already use hashmap_remove_value() in job_uninstall().
2023-04-27 00:35:54 +09:00
Luca Boccassi cf636aa59e test: add coverage for CoredumpFilter=all 2023-04-26 16:12:00 +01:00
Luca Boccassi 7f3bb8f20d coredump filter: add mask for 'all' using UINT32_MAX, not UINT64_MAX
The kernel returns ERANGE when UINT64_MAX is passed. Create a mask
and use UINT32_max, which is accepted, so that future bits will also
be set.
2023-04-26 16:12:00 +01:00
Luca Boccassi 00e5933f57 ukify: allow building PE addon
Make the kernel optional too, so that we can easily build and sign a PE addon,
that can be used to carry extra command line options.
2023-04-26 16:55:26 +02:00
Zbigniew Jędrzejewski-Szmek 1db4acbe5d
Merge pull request #27398 from yuwata/udev-rule-negative-match
udev-rule: fix negative match
2023-04-26 16:40:01 +02:00
Zbigniew Jędrzejewski-Szmek 0f56698079
Merge pull request #27411 from yuwata/udev-iocost-follow-ups
udev/iocost: several follow ups
2023-04-26 16:37:59 +02:00
Luca Boccassi 37232d55a7 coredump filter: fix stack overflow with =all
We translate 'all' to UNIT64_MAX, which has a lot more 'f's. Use the
helper macro, since a decimal uint64_t will always be >> than a hex
representation.

root@image:~# systemd-run -t --property CoredumpFilter=all ls /tmp
Running as unit: run-u13.service
Press ^] three times within 1s to disconnect TTY.
*** stack smashing detected ***: terminated
[137256.320511] systemd[1]: run-u13.service: Main process exited, code=dumped, status=6/ABRT
[137256.320850] systemd[1]: run-u13.service: Failed with result 'core-dump'.
2023-04-26 15:04:06 +01:00
Zbigniew Jędrzejewski-Szmek 947579e5e2
Merge pull request #27408 from keszybz/creds-missing-message
Adjust messages when credentials are missing
2023-04-26 14:57:13 +02:00
Zbigniew Jędrzejewski-Szmek d21d71fb28
Merge pull request #26944 from aafeijoo-suse/systemd-network-generator-initrd-fix
network-generator: do not parse kernel command line more than once
2023-04-26 14:55:41 +02:00
Frantisek Sumsal 914f280d0c test: tell dfuzzer to skip Reexecute()
As described in systemd/systemd#27204 reexecuting the daemon while
running in a systemd-run "session" causes the session end prematurely.
Let's skip the Reexecute() method in dfuzzer and trigger it manually
until the issue is resolved.
2023-04-26 14:41:05 +02:00
Daan De Meyer 5eef704734 repart: Add Minimize= support for verity hash partitions
Fixes #27414
2023-04-26 14:15:16 +02:00
Daan De Meyer cf18d96f62 repart: Extend error logging for format_verity_hash/sig() 2023-04-26 14:15:14 +02:00
Yu Watanabe 85e38da2ec sd-journal: make journal_file_copy_entry() return earlier 2023-04-26 20:54:08 +09:00
Yu Watanabe bf9b7728e6 sd-journal: copy boot ID
The pointer to boot ID may be invalidate by journal_file_move_to_object()
calls in the later loop.
2023-04-26 20:51:12 +09:00
Yu Watanabe 265b1dc048 sd-journal: tighten variable scope 2023-04-26 20:50:53 +09:00
Daan De Meyer f81409f844 journal: Don't try to write garbage if journal entry is corrupted
If journal_file_data_payload() returns -EBADMSG or -EADDRNOTAVAIL,
we skip the entry and go to the next entry, but we never modify
the number of items that we pass to journal_file_append_entry_internal()
if that happens, which means we could try to append garbage to the
journal file.

Let's keep track of the number of fields we've appended to avoid this
problem.
2023-04-26 20:46:25 +09:00
Daan De Meyer 13bde177e4 repart: Allow passing target to format_verity_hash()
Let's allow specifying where the verity hash data should be written
as preparation for adding verity hash partition minimize support.
2023-04-26 10:16:21 +02:00
Daan De Meyer e463e257c7 repart: Move partition_defer() out of format_verity_hash/sig()
To allow re-using format_verity_hash() for minimizing verity hash
partitions.
2023-04-26 10:09:10 +02:00
Daan De Meyer deeae10e26 repart: Turn condition into assert
format_verity_hash() should only be called with VERITY_HASH type
partitions, so assert() if that's not the case.
2023-04-26 10:04:08 +02:00
Franck Bui b35f71ac1a locale: when no xvariant match select the entry with an empty xvariant
When doing a conversion and the specified 'xc->xvariant' has no match, select
the x11 layout entry with a matching layout and an empty xvariant if such entry
exists. It's still better than no conversion at all.
2023-04-26 08:15:17 +02:00
Yu Watanabe fc73d97182 udev/iocost: invert DEVTYPE match
No functional change, just refactoring.
Addresses https://github.com/systemd/systemd/pull/23325#discussion_r1171006967.
2023-04-26 14:50:25 +09:00
Yu Watanabe c413ae18b5 udev/iocost: use ID_MODEL_FROM_DATABASE if exists
To make the rule consistent with 'iocost query'.
2023-04-26 14:50:25 +09:00
Yu Watanabe ede5e271b1 udev/iocost: fix log message 2023-04-26 14:50:25 +09:00
Yu Watanabe b2fccd0729 udev/iocost: query_named_solution() provides non-NULL model and qos on success 2023-04-26 14:50:25 +09:00
Yu Watanabe 934613bb88 udev/iocost: call get_known_solutions() in apply_solution_for_path()
Then, the solution name can be logged.
2023-04-26 14:50:09 +09:00
Yu Watanabe 22148897cf udev: use version()
Fixes #27382.
2023-04-26 07:44:39 +02:00
Yu Watanabe 9c271f4509 udev/iocost: merge get_known_solutions() and choose_solution()
As these are always called sequentially.
No functional change, just refactoring.
2023-04-26 11:49:58 +09:00