Commit Graph
85440 Commits
Author SHA1 Message Date
Matt Fleming 4dcbfbb1ad process-util: Add support SCHED_EXT scheduling policy
Allow CPUSchedulingPolicy to be set to "ext". SCHED_EXT is a new
scheduling policy in Linux v6.12 that allows processes to be scheduled
using custom BPF schedulers instead of the default in-kernel ones.

Selectively setting the SCHED_EXT policy is useful for systems running
in "partial mode" where not all processes are run using a custom
scheduler.

Fallback to SCHED_OTHER and print an error message for systems where
SCHED_EXT isn't available.
2025-12-20 18:31:55 +01:00
Daan De Meyer 84dcbc3fd2 meson: Deduplicate sources before clang-tidy
Let's make sure we don't define the same clang-tidy
test multiple times by deduplicating sources beforehand.
We end up with the same sources in a few cases because
e.g. we reuse the same fuzz-main.c for each fuzz target.
2025-12-20 17:58:19 +01:00
Daan De Meyer 27de9c391d sd-event: Don't require blocking SIGCHLD for WEXITED (#39806)
We watch for WEXITED via pidfd instead of signalfd, so no need to insist
on blocking SIGCHLD anymore if we're only watching for WEXITED.

This also removes SIGCHLD blocking tree-wide where it's not required
anymore.
2025-12-20 17:35:47 +01:00
Daan De Meyer 29d1df4b03 tree-wide: Remove unnecessary SIGCHLD blocking
Now that sd-event doesn't insist on blocking
SIGCHLD anymore when watching for process exit,
let's stop blocking SIGCHLD tree-wide where not
required anymore.
2025-12-20 15:50:47 +01:00
Daan De Meyer fbd276cb86 tree-wide: Use pidref_wait_for_terminate_and_check()
Let's use the pidref variants for waiting and
checking a process everywhere and get rid of the
non pidref variants.
2025-12-20 15:50:47 +01:00
Daan De Meyer e74b571004 pidref: Add pidref_wait_for_terminate_full()
We can use this to replace wait_for_terminate_with_timeout(). Because
we poll a pidfd, we don't need to block SIGCHLD anymore in umount.c.
2025-12-20 15:49:26 +01:00
Daan De Meyer 9bd833ee6e test-pidref: Migrate to new assertion macros 2025-12-20 15:44:36 +01:00
Daan De Meyer 8c367868ee process-util: Use pidref_wait_for_terminate_and_check in pidref_safe_fork()
Note that we still have to block SIGCHLD so that
we can be certain the process is not reaped before
we get the pidfd to it. safe_fork() and friends are
used in libsystemd where we don't control how the
SIGCHLD signal is configured. Specifically, kernel
autoreaping could be enabled which is why we have
to block SIGCHLD until we get the pidfd so that the
kernel cannot autoreap the process before we get
the pidfd.
2025-12-20 15:44:20 +01:00
Daan De Meyer a1e5d7f865 sd-event: Clean up SIGCHLD conditions for sd_event_add_child()
First, don't require blocking SIGCHLD for WEXITED. We watch for WEXITED
via pidfd instead of signalfd, so no need to insist on blocking SIGCHLD
anymore if we're only watching for WEXITED.

Second, do a proper check to see if the kernel autoreaping logic is
enabled. That has nothing to do with SIGCHLD being blocked for the current
thread or not. Instead, the kernel autoreaping logic is enabled either if
the disposition is set to SIG_IGN or if the SA_NOCLDWAIT flag is enabled.
2025-12-20 15:27:22 +01:00
Daan De Meyer 20367ade71 process-util: beef up namespace_fork() drastically (#40157)
Split out from #40093 and #39806
2025-12-20 15:27:08 +01:00
Mike Yuan 73c40aa1f6 process-util: synchronously wait for namespace_enter() before returning
Additionally, report actual errors using errno pipe too.
2025-12-20 14:27:46 +01:00
Mike Yuan ed0f6758c8 process-util: revamp flags handling in namespace_fork()
* Specifying all 3 of FORK_DEATHSIG_SIG{KILL,TERM,INT} for
  the middle man makes zero sense. Use SIGKILL only.
* Make sure operations on except_fds work sensibly - close/pack/
  de-ocloexecify fds only in the second level, so that the namespace
  fds remain usable across first safe_fork().
* Fire FORK_NEW_*NS after attaching to the desired namespaces,
  not already in the outer process.
* Insist on PDEATHSIG being enabled to ensure propagation of killing.
* Suppress more redundant flags.
2025-12-20 14:14:24 +01:00
Daan De MeyerandMike Yuan 8c007f68ff process-util: Migrate namespace_fork() to PidRef
Co-authored-by: Mike Yuan <me@yhndnzj.com>
2025-12-20 13:45:22 +01:00
Mike Yuan 3532691d72 process-util: trivial cleanup for read_errno() 2025-12-20 13:45:22 +01:00
Mike Yuan e48e098db1 process-util: dedup restore_sigsetp() with block_signals_reset() 2025-12-20 13:45:21 +01:00
Lennart Poettering f42ac24772 userdbctl: add missing --uuid= to --help text
Follow-up for: 466562c69b
2025-12-20 08:09:05 +00:00
Daan De Meyer ba037640bf Make .standalone programs same as normal and avoid double compilation (#40148) 2025-12-19 14:58:34 +01:00
Luca Boccassi 059b3b466d core: reuse existing dm-verity device for single filesystem images pinned by policy (#40007)
Loading images is, generally speaking, the slowest part of sd-executor
when spawning a service. This is due to multiple factors. dm-verity is
obviously a big part of the cost, but dissecting in general via libblkid
also can take a lot of time, due to probing the images and their
filesystems.

A performance test doing service restarts in a row shows these
results, ran on a production system (low power and slow ARM64 SOC) with
a real production service, show the following service interruption
intervals:

```
Count | P50 (ms)  | P90 (ms) | P95 (ms) | P99 (ms) | P99.9 (ms)
507   | 1,532     | 1,726    | 2,548    | 4,112    | 4,592
```

One iteration is 507 restarts in this case, but this has ran hundreds
of times and the results are always in line within margin of error.
This also holds true for metrics from live systems, same numbers.
Between 1.0s and 1.2s can be attributed by profiling to the time needed
for the service code itself to start up and sd_notify, the rest is spent
inside systemd's code.

This means there is currently a tradeoff for services - either use
secure
images, or make restarting fast. Downtime of services is a very
important
metric, as for many cases this directly translates to outages, total or
partial (blackouot or greyout).

In order to facilitate using secure images without downsides, skip the
slow dissect steps (probing, loop devices, etc) when the configured
image is a single filesystem dm-verity image with a policy that pins it
to a single filesystem, and an already existing and open dm-verity
device
can be found and reused.

This allows orchestrators to pre-open images on download, before
restarting
services, to minimize downtimes.
2025-12-19 13:19:16 +00:00
Luca Boccassi 6ceb76bfcf mkosi: update fedora commit (#40146) 2025-12-19 12:49:27 +00:00
Zbigniew Jędrzejewski-Szmek 736fc4b479 meson: avoid double compilation for standalone progs
So far we compiled the normal and standalone versions completely
independently. Let's use the 'extract' template pattern to avoid any
additional compilation and only require an single link to produce the
.standalone variants.

Unfortunately, as designed, the 'extract' framework only allows one set of
object files to be extracted. Since we need all the files for the
.standalone version, we cannot use 'extract' for other purposes. Thus, in
the two cases where 'extract' was used for the test binaries, this is now
changed to compile the files a second time. But the number of files in that
list is small, so this seems like a better option.

(If we weren't using the template system, we could easily extract just the
objects we need. But with the current system, at the point of the
definition, the binaries are not defined yet. We'd need to handle all of
this through sets of dictionaries, and that just seems like too much
trouble to avoid double compilation of a few small files.)
2025-12-19 13:15:49 +01:00
Zbigniew Jędrzejewski-Szmek b6c86e145a meson: drop now-unused -DSTANDALONE
If we ever want to add it back, it should be with -DSTANDALONE=0|1, so
that #if instead of #ifdef can be used. We generally converted our internal
defines to that form.
2025-12-19 13:15:49 +01:00
Zbigniew Jędrzejewski-Szmek 795e066d22 sysusers,tmpfiles: make standalone versions full-featured
This effectively reverts 3537577c37. Originally,
the #ifdefs were added because we didn't want to pull in the whole tree of
libmount and other dependencies in standalone versions. But dependencies are
now loaded through dlopen(), so this is not needed anymore. (And doesn't even
make much of a difference.)
2025-12-19 13:15:49 +01:00
Zbigniew Jędrzejewski-Szmek 54492552a1 meson: allow .standalone version to be always built
Allow .standalone version to be built on-demand, even if -Dstandalone=false
is configured. In other words, this changes the meson option from a hard
disablement to a soft "build is on/off by default".

The meson config was originally written in this way but we lost this feature
after the transition to templates. It is nice to build additional targets on
demand during development, so add this back.
2025-12-19 13:14:19 +01:00
Zbigniew Jędrzejewski-Szmek 9e104bd3aa meson: put src/import source lists directly in templates
The indirection through variables doesn't seem that useful here:
OTOH, the lists are short, and OTOH, there is a bunch of different
programs with similar names. Overall, it's all easier to follow if
the lists are inline.
2025-12-19 13:12:35 +01:00
Luca Boccassi 56a53a5974 mkosi: update fedora commit reference to cac8dde28a1298bbc2bee40e9ab3b9308392f691
* cac8dde28a test: Allow passing in extra tests to skip via TEST_SKIP
* 56377438ba Disable sysinit-path for upstream builds
* 0c8ea706f9 Fix links to patches
* 4f5b5a9615 Version 259
* bf8019c840 Version 259~rc3
* ef777d6572 Check if --max-lines is supported by meson
* b562e38e22 Fix use of removed $LOCAL_CONF variable
* 0289127dae Patch machined to continue after selinux denial
* 7e409130ee Version 259~rc2
* 33b38cdbc7 Suppress errors from tar
* ddb6474e94 Drop provides for removed sysvinit tools
* 9ac8c36307 Set meson auto features to auto when building for upstream
2025-12-19 11:35:21 +00:00
Luca Boccassi 2791af18e4 tools: use -f in mkosi summary in fetch-distro.py
$ ./tools/fetch-distro.py -u fedora
+ mkosi --json -d fedora summary
‣ Ignoring --distribution from the CLI. Run with -f to rebuild the image with this setting

Follow-up for 35f6e5c327
2025-12-19 11:35:21 +00:00
Luca Boccassi 0bd766553c core: reuse existing dm-verity device for single filesystem images pinned by policy
Loading images is, generally speaking, the slowest part of sd-executor
when spawning a service. This is due to multiple factors. dm-verity is
obviously a big part of the cost, but dissecting in general via libblkid
also can take a lot of time, due to probing the images and their filesystems.

A performance test doing service restarts in a row shows these
results, ran on a production system (low power and slow ARM64 SOC) with
a real production service, show the following service interruption intervals:

Count | P50 (ms)  | P90 (ms) | P95 (ms) | P99 (ms) | P99.9 (ms)
507   | 1,532     | 1,726    | 2,548    | 4,112    | 4,592

One iteration is 507 restarts in this case, but this has ran hundreds
of times and the results are always in line within margin of error.
This also holds true for metrics from live systems, same numbers.
Between 1.0s and 1.2s can be attributed by profiling to the time needed
for the service code itself to start up and sd_notify, the rest is spent
inside systemd's code.

This means there is currently a tradeoff for services - either use secure
images, or make restarting fast. Downtime of services is a very important
metric, as for many cases this directly translates to outages, total or
partial (blackouot or greyout).

In order to facilitate using secure images without downsides, skip the
slow dissect steps (probing, loop devices, etc) when the configured
image is a single filesystem dm-verity image with a policy that pins it
to a single filesystem, and an already existing and open dm-verity device
can be found and reused.

This allows orchestrators to pre-open images on download, before restarting
services, to minimize downtimes.
2025-12-19 11:20:48 +00:00
seidlerv bd6d8eec5e man/org.freedesktop.systemd1.xml: Fix wording 2025-12-19 11:28:46 +01:00
Daan De Meyer 9d10457a3e test-user-util: Migrate to new assertion macros 2025-12-19 11:11:39 +01:00
Luca Boccassi 4be5c2870f image-policy: add helper to determine fstype 2025-12-19 09:17:41 +00:00
Luca Boccassi d0cb79b8a9 image-policy: add support for restricting to specific filesystems 2025-12-19 09:17:41 +00:00
Daan De Meyer bc3f700a4a logs-show: match init.scope rather than _PID=1 for UNIT= (#40142) 2025-12-19 08:50:33 +01:00
Mike Yuan 7f9e3c5919 logs-show: match init.scope rather than _PID=1 for UNIT=
We should consider the whole init.scope trusted, and any
process trying to log on behalf of a unit there should be
attributed as so.

Follow-up for 4f25248b6e
Only with this commit is the change in effect.
2025-12-19 02:18:44 +01:00
Mike Yuan 79e6bfb1e6 core/manager: use UNIT_IS_ACTIVE_OR_RELOADING rather than hardcoding service states
except for SERVICE_EXITED which has to be checked manually.
2025-12-19 02:18:44 +01:00
Luca Boccassi 2f363b407f mkosi: update debian commit reference to d9f2aa1704bc98d1aec6519a863a07eaf12b76ad
* d9f2aa1704 Install systemd-tpm2-generator.8 only for UEFI builds
* ac1c7d8048 Drop dependencies on libcap-dev, no longer used since v259
* c36e5871ca Do not install systemd-sysv-generator.8 in upstream build
* bac0cca0e8 Install new files for upstream build
* 2855fb1302 Update changelog for 259-1 release
2025-12-18 22:15:14 +01:00
Daan De Meyer 4c1a2f7d95 Revert qemu debugs (#40138)
Captured some in https://github.com/systemd/systemd/issues/38240 and
they do not look too useful, and add noise, so remove them again
2025-12-18 22:14:21 +01:00
Lennart Poettering 2062b817d4 keyutil: Add extract-certificate (#39962)
Useful to extract a certificate from a hardware token to a file, for
example in mkosi to ship the certificate from a hardware token in
/usr/lib/verity.d in an image
2025-12-18 21:25:57 +01:00
Lennart Poettering b15cf11327 repart: add basic support for LUKS2 integrity verification (#39295)
Authenticated disk encryption is experimentally supported by cryptsetup
since v2.0.0 and allows for automatic dm-integrity setup for LUKS
devices. Add support for the mode to systemd-repart. The PR adds support
for `cryptsetup luksFormat --integrity` to systemd-repart and
"encryptedwithintegrity" dissection policy.

Limitations:
- No discard, online-only mode for repart.

Closes #39250
2025-12-18 21:19:39 +01:00
Miao Wang dc3e544104 ssh-proxy: expect OK PORT response from vsock-mux
The unix-domain socket to AF_VSOCK multiplexers in Firecracker and
vhost-device-vsock sends OK PORT response to the client, resulting
ssh clients to abort the connection with the additional response. This
patch addresses this issue by waiting and expecting the possible OK PORT
response from the multiplexer, if any, and then handover the socket fd
to the ssh client. It only checks if the response begins with OK and
consume the response till the first \n, for simplicity.

Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
2025-12-18 21:15:41 +01:00
Mike Yuan 71aaa744b8 Assorted minor cleanups (#40136) 2025-12-18 20:53:58 +01:00
Lennart Poettering 627e583c64 Use ANSI CSI 18 to query console size (#39833) 2025-12-18 20:49:26 +01:00
Luca Boccassi 84079cd158 Revert "tests: run qemu with cpu_reset,guest_errors debug messages"
This reverts commit b169c7512c.
2025-12-18 17:51:07 +00:00
Luca Boccassi d6514ebf33 Revert "tests: also add qemu shutdown trace debug logs to integration script"
This reverts commit 9b42cc3b12.
2025-12-18 17:51:07 +00:00
Luca Boccassi 293a925e9e Revert "integration-test: check tools distribution rather than image distribution"
This reverts commit fd2cdadc14.
2025-12-18 17:51:06 +00:00
Daan De Meyer 30465f789c test: introduce test-sleep and use it in several integration tests (#40086) 2025-12-18 17:47:57 +01:00
Franck Bui 25393c7c90 man: generate systemd-tpm2-generator man page only when ENABLE_BOOTLOADER is enabled 2025-12-18 17:39:25 +01:00
Mike Yuan 6dacabe534 journalctl-show: drop redundant condition
The combination of --follow and --reverse would have been
rejected in parse_argv() already.
2025-12-18 17:37:26 +01:00
Mike Yuan 58e9239fd7 core/dbus-manager: drop dangling verify_run_space_and_log() prototype
Follow-up for 65d9ef40f2
2025-12-18 17:37:26 +01:00
Mike Yuan f145fc8c7e core/manager: constify DEFAULT_TASKS_MAX 2025-12-18 17:37:25 +01:00
Mike Yuan c53b324ecf socket-label: mark socket_address_bind_ipv6_only_or_bool_from_string as _pure_ 2025-12-18 17:37:25 +01:00