Commit Graph
88337 Commits
Author SHA1 Message Date
Luca Boccassi 1cccb5362c A couple of sanitizer-related tweaks (#41808)
The sanitizer job was FUBAR on Fedora Rawhide (and RHEL 10 to some
extent) due to several changes:
- latest LLVM (v22) introduced a change that occasionally generates a
false-positive warning when running with sanitizers
  - several tools had to be "ASan-wrapped" because:
- util-linux started linking against libsystemd which propagated to
other tools depending on its shared libraries (like libmount)
- libssh started depending on libfido2, which depends on libudev; this
then translated to an interesting depedency chain where tpm2 utils got a
dependency on libudev through libcurl -> libssh -> libfido2
- polkit added MemoryMax= to its service file, which is incompatible
with ASan-runs (at least with the current limits)

See the commits for more detailed descriptions.

Also, one note: the santizer job is currently still FUBAR on Fedora
Rawhide (or, more specifically, the TEST-50-DISSECT and TEST-58-REPART),
because mkfs.erofs also gained a dependency on libudev (through libcurl,
see above), but the wrapping currently doesn't work as it also depends
on libqpl which is linked with libtsan (which is incompatible with other
sanitizers). This is currently tracked in
https://bugzilla.redhat.com/show_bug.cgi?id=2461146
2026-04-28 12:04:45 +01:00
Dark Cronyx a192a5cc4d po: Translated using Weblate (German)
Currently translated at 100.0% (266 of 266 strings)

Co-authored-by: Dark Cronyx <darkcronyx@protonmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/de/
Translation: systemd/main
2026-04-28 11:59:21 +01:00
Daan De Meyer ed1373f889 fork-notify: Use callback instead of argv NULL code path with return (#41813) 2026-04-28 10:15:31 +02:00
Daan De Meyer 181a9f65a7 udev: don't assert on worker cap after killing a broken idle worker
manager_can_process_event() considers an event processable if either
there is room below children_max to spawn, or an idle worker exists.
When only the latter holds, event_run() picks the idle worker and
tries device_monitor_send(). If that send fails, event_run() SIGKILLs
the worker, marks it WORKER_KILLED and continues the loop. With no
other idle worker available, it falls through to worker_spawn(),
guarded by:

    assert(hashmap_size(manager->workers) < manager->config.children_max);

The just-killed worker is still in manager->workers until its SIGCHLD
is reaped by on_worker_exit(), so at the cap this assertion trips and
udevd aborts:

    Assertion 'hashmap_size(manager->workers) < manager->config.children_max'
    failed at src/udev/udev-manager.c:635, function event_run(). Aborting.

Instead of asserting, bail out when we are already at the worker
limit. The event remains in EVENT_QUEUED; once the killed worker's
SIGCHLD arrives and frees it from the hashmap, on_post() re-runs
event_queue_start() and the event is retried.
2026-04-27 21:14:08 +02:00
Zbigniew Jędrzejewski-Szmek b2d72eabcd tree-wide: change option_parse() to return option and arg via internal state (#41833) 2026-04-27 19:42:52 +02:00
Kai Lüke 70d75c22d7 machine-register: don't unref borrowed varlink reply
ASAN showed a use-after-free error for systemd-vmspawn's
machine_register call because the reply got accessed and freed again
through _cleanup. The same problem exists in two
verb_machine_control_one/unregister_machine.
Fix these call sites to not set up _cleanup.
2026-04-27 22:14:05 +09:00
Kai Lüke 41cf689121 nsresource: fix buffer overrun reported by ASAN
This came up when running systemd-vmspawn with ASAN to fix another bug
and thus I had to fix this overrun here first: The dispatch tables were
missing the terminator, add it.
2026-04-27 22:14:05 +09:00
Kai Lüke 4dbcc319ca fork-notify: Use callback instead of argv NULL code path with return
In 012d87c1fc/cc8f398202 it was made possible for fork_notify() to
return in the child but at that point all FDs were closed and the
_cleanup path from the return causes assertion failures due to invalid
FDs in notify_event_source/event, leading to a vmspawn failing to start
with a SIGABRT logged in coredump.
Instead of TAKE_PTR on a bunch of things which is fragile, rather avoid
the return and instead add an explicit callback handler and guarantee
to exit directly after it. A userdata argument is also added but not
used yet I think it's quite normal to have for a callback.
2026-04-27 22:14:05 +09:00
Christian Brauner 0d6d2c9ebd vmspawn-varlink: treat QMP disconnect as success for Terminate
QMP "quit" tells QEMU to exit, which races the reply with the socket
EOF: sometimes the disconnect lands in qmp_client_fail_pending() with
-ECONNRESET before the reply has been parsed. The shared completion
callback then translates that into io.systemd.MachineInstance.NotConnected,
turning the desired outcome into a varlink error.

This is exactly what TEST-87-AUX-UTILS-VM exposes during its repeated
start/pause/resume/terminate stress loop: a successful Pause/Describe
followed milliseconds later by a Terminate that fails with NotConnected
when the disconnect path wins the race.

Give Terminate its own completion callback that treats disconnect-class
errors as success, since QEMU shutting down is the whole point of "quit".
The other simple commands (Pause, Resume, PowerOff, Reboot) keep the
existing semantics: they expect QMP to remain alive, so NotConnected is
the correct reply for them.

Link: https://github.com/systemd/systemd/actions/runs/24986080288/job/73159585425?pr=41835
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-04-27 15:07:26 +02:00
Zbigniew Jędrzejewski-Szmek a6e694025a shared/options: add whitespace to OPTION_COMMON definitions
Initially I thought that there'd be just a handful, but the list
has grown over time and all bunched up together they are hard to
read.
2026-04-27 11:33:38 +02:00
Zbigniew Jędrzejewski-Szmek dbe3602abe nspawn,vmspawn: fix state optarg uses 2026-04-27 11:33:13 +02:00
Zbigniew Jędrzejewski-Szmek 5ff0ccaf8b tree-wide: change option_parse() to return option and arg via internal state
It was requested to make the 'c', 'opt', and 'arg' params the same, i.e.
defined through the FOREACH_OPTION macro. But we can't do that easily,
because 'c' was defined in the for loop definition, and we can only
define variables of the same type in that way. Also, in some cases we
need only 'c', in other cases with need 'c' and 'arg, in some cases 'c'
and 'opt', and in other cases all three. We'd need to either
conditionalize or mark those variables with _unused_ to deal with
compiler warnings. But a different approach works quite nicely: add
state.opt and state.arg to show the current option and it's argument.
(The short names are picked on purpose to reduce verbosity since those
are used a lot.)
2026-04-27 11:33:10 +02:00
Zbigniew Jędrzejewski-Szmek d92b511e4a Convert udev helper programs to option macros (#41820) 2026-04-27 11:22:23 +02:00
Lennart Poettering 78208556b2 job: add a "finished" state for jobs
So far when a job completed we'd never transition into any new state,
we'd just do some final processing work (such as notifying clients) and
destroy it.

Let's change that, and briefly enter a final state: "finished". This is
useful so that code that notifies clients can generically send the
quadruplet of id, type, state, result for any change notification and
naturally can communicate job completion that way: by setting the state
field to "finished".

Prompted by the discussions in: #41583
2026-04-27 09:57:22 +02:00
Zbigniew Jędrzejewski-Szmek 33a37278aa iocost: convert to the new option parser
--help output only has changes expected in the new style.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 09:14:50 +02:00
Zbigniew Jędrzejewski-Szmek 05fea7df1b scsi_id: convert to the new option parser
Common page-code parsing extracted into a parse_page_code() helper.

While at it, return real error values (-EINVAL, etc.) rather than -1,
and rename retval to r throughout for consistency.

The body of main is moved to new run. The closing of logging file
descriptors is dropped. They will be closed automatically anyway. Not
sure what the original purpose of that code was. The code is also
modernized in various places… though more changes could be made. The
return convention of help() and similar functions is changed to usual
negative/0/1, where 0 means that the caller should quit.

set_inq_values would return positive error values too, which was
previously ignored. It's not entirely clear, but that doesn't seem
to have been on purpose.
2026-04-27 09:14:50 +02:00
Yu Watanabe f0483f308a format-table: fix potential segfault
In format-table.h, TABLE_IN_ADDR is commented as "Takes a union in_addr_union
(or a struct in_addr)". However, if we pass struct in_addr to table_add_many(),
the function reads more than the size of the struct.
2026-04-27 11:11:35 +09:00
Lennart Poettering bc42f7574c preparatory work for the storage provider work in #41776 (#41814)
nothing earth shattering, but generally useful. without #41776 it has no
immediate users though
2026-04-26 23:44:02 +02:00
Luca Boccassi b76e18ce9a various trivial tweaks (#41828) 2026-04-26 22:40:01 +01:00
Lennart Poettering 71d82cc638 blockdev-list: make BLOCKDEV_LIST_IGNORE_ROOT suppress all definitions of the root disk
There are various definitions of the root disk, let's suppress them all if
the flag is set. So far only the outermost is suppressed, which is a bit
weird, given it's "further away" from the rootfs.
2026-04-26 21:45:28 +02:00
Lennart Poettering 41a8cc281e blockdev-list: pick up read_only property 2026-04-26 21:21:49 +02:00
Lennart Poettering 5827ff2b9d fs-util: add XO_AUTO_RW_RO 2026-04-26 21:21:49 +02:00
Lennart Poettering f0abcd5e0f format-table: add tristate field 2026-04-26 21:21:49 +02:00
Lennart Poettering 45ceb97f6a path-lookup: add state_directory_generic() helper inspired by runtime_directory_generic() 2026-04-26 21:21:49 +02:00
Lennart Poettering cde589df88 help-util: reword comment a bit
Based on comments here:

https://github.com/systemd/systemd/pull/41805#discussion_r3141746275
2026-04-26 21:04:07 +02:00
Lennart Poettering 1851a76d6f notify: we typically say 'service manager' not 'init system', do so here too 2026-04-26 21:04:07 +02:00
Frantisek Sumsal bad594f79a ssh-proxy: add a missing dispatch table sentinel
Which was accidentally dropped in e6be5fb720.

Follow-up for e6be5fb720.
2026-04-26 20:59:37 +02:00
Lennart Poettering a9122433c9 varlink: address some trivial points Claude found
Just addressing Claude's last review from #41815
2026-04-26 20:50:09 +02:00
Christian Brauner 114ad136c0 varlink-util: add generic code that calls out to a 'hook' directory o… (#41815)
…f sockets
2026-04-26 17:31:52 +02:00
Zbigniew Jędrzejewski-Szmek 4339197f5d shared/options: split out helper to format -o/--option= 2026-04-26 12:34:14 +02:00
Zbigniew Jędrzejewski-Szmek beea13b9d1 ata_id: convert to the new option parser
The commandline check is tightened to reject extra arguments.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 12:34:13 +02:00
Zbigniew Jędrzejewski-Szmek 3ad76abc43 cdrom_id: convert to the new option parser
The commandline check is tightened to reject extra arguments.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 12:34:13 +02:00
Zbigniew Jędrzejewski-Szmek 9286f1f299 dmi_memory_id: convert to the new option parser
For some reason, the old code had duplicate {"version", 'v'} entry in
the options table and a matching case that could not be reached.

Commandline parsing is tightened to reject any positional arguments.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 12:34:08 +02:00
Zbigniew Jędrzejewski-Szmek e8e75a1c99 fido_id: convert to the new option parser
The commandline check is tightened. Previously the program would
crash if called without an argument.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 12:34:07 +02:00
Zbigniew Jędrzejewski-Szmek dad6381d45 mtd_probe: convert to the new option parser
The commandline check is tightened. Previously the program would
crash if called without an argument.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 12:34:06 +02:00
Lennart Poettering 0a8560eed8 varlink-util: add generic code that calls out to a 'hook' directory of sockets 2026-04-26 11:29:52 +02:00
Frantisek Sumsal ef3c07352b test: don't strip directives from test units
The original find was matching even our test units, which caused issues
when the check was extended with Memory*= directives, as we stripped
them off from test units for TEST-55-OOMD where we certainly need them.
Since the stripping was meant primarily for "production-grade" units,
let's limit it to units under /etc/systemd/system/ and
/usr/lib/systemd/system/.
2026-04-25 23:39:47 +02:00
Frantisek Sumsal 035ba3ea57 test: slightly reduce the performance/memory overhead for wrapped binaries
Let's drop the quarantine that ASan uses for use-after-free detection,
as it's pointless in wrapped binaries and can consume up to 256 MiB of
memory (with the default configuration). Also, don't keep any stack
traces for allocations & deallocations, which should (slightly) help
with both memory & performance overhead.
2026-04-25 18:55:47 +02:00
Frantisek Sumsal 445f980548 test: temporarily ignore sanitizer warning about blocked ptrace()
LLVM 22 introduced an additional check [0] for ptrace() syscall when
invoking sanitizers [0] which currently produces a false-positive
warning when running some of our units under sanitizers:

[   47.524680] systemd-timedated[740]: ==740==WARNING: ptrace appears to be blocked (is seccomp enabled?). LeakSanitizer may hang.
[   47.524680] systemd-timedated[740]: ==740==Child exited with signal 15.
...
[ 1555.734223] systemd-oomd[93]: ==93==WARNING: ptrace appears to be blocked (is seccomp enabled?). LeakSanitizer may hang.
[ 1555.734223] systemd-oomd[93]: ==93==Child exited with signal 15.
...

It is a false positive because we disable the seccomp filters
system-wide for our units in the sanitizer jobs.

Now, from what I've seen so far this happens only in
Type=notify(-reload) units that also utilize bus_event_loop_with_idle().
This, combined with the fact that the ptrace()-check child process from
[0] checks only if the child process was killed by _any_ signal, means
that if the systemd unit exits on its own after becoming idle and then
something sends it SIGTERM (either via explicit `systemctl stop` or
during system shutdown), this SIGTERM might hit the ptrace()-check child
process from the sanitizer handler (as we also send the signal to all
processes in the target cgroup), which the parent process then
mistakenly evaluates as a blocked ptrace() syscall, even though the
check process wasn't killed by SIGSYS.

I filed this as [1] to the LLVM project, but let's also temporarily
ignore the warning in the sanitizer report processing, as it currently
causes annoying test fails.

[0] https://github.com/llvm/llvm-project/commit/a708b4bf21d7c2298224cdacf7d424abc3c8fed4
[1] https://github.com/llvm/llvm-project/issues/193714
2026-04-25 18:49:40 +02:00
Frantisek Sumsal e3aaf3d76e test: drop any memory limits from units when running with sanitizers
As the memory usage under sanitizers is quite unpredictable.

This is currently relevant mainly for Polkit, as it introduced memory
limits for its polkitd.service unit in the latest version [0] which are
very easy to trigger when running under sanitizers (as polkitd depends
on libsystemd which brings ASan into polkitd's address space).

[0] https://github.com/polkit-org/polkit/commit/7d9c06c58a957ee3f2a4383ade6f207b05207e3e
2026-04-25 18:49:40 +02:00
Frantisek Sumsal a8400c8f1a test: wrap even more binaries when running with sanitizers
Turns out that the util-linux dep on libsystemd caused more fun than I
originally anticipated:

$ lddtree /usr/bin/dfuzzer
dfuzzer => /usr/bin/dfuzzer (interpreter => /lib64/ld-linux-x86-64.so.2)
    libgio-2.0.so.0 => /lib64/libgio-2.0.so.0
        libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0
        libz.so.1 => /lib64/libz.so.1
        libmount.so.1 => /lib64/libmount.so.1
            libblkid.so.1 => /lib64/libblkid.so.1
            libsystemd.so.0 => /lib64/libsystemd.so.0
                libm.so.6 => /lib64/libm.so.6
                    ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
        libselinux.so.1 => /lib64/libselinux.so.1
            libpcre2-8.so.0 => /lib64/libpcre2-8.so.0
...

Also, the tpm2 utils now depend on libudev through libcurl -> libssh ->
libfido2 dep chain:

$ lddtree /usr/bin/tpm2_pcrread
tpm2_pcrread => /usr/bin/tpm2_pcrread (interpreter => /lib64/ld-linux-x86-64.so.2)
    ...
    libcurl.so.4 => /lib64/libcurl.so.4
    ...
        libssh.so.4 => /lib64/libssh.so.4
            libfido2.so.1 => /lib64/libfido2.so.1
                libcbor.so.0.13 => /lib64/libcbor.so.0.13
                libudev.so.1 => /lib64/libudev.so.1
                    libgcc_s.so.1 => /lib64/libgcc_s.so.1
...

Follow-up for 8030e0b19e.
2026-04-25 17:42:20 +02:00
Zbigniew Jędrzejewski-Szmek 2f42b19c0f v4l_id: convert to the new option parser
The commandline check is tightened to reject extra arguments.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-25 14:50:46 +02:00
fecet 6897562ea0 hwdb: sensor: add accel mount matrix for GPD WIN 5
The WIN 5 (DMI product G1618-05) ships the same BMI0160
accelerometer with the same physical mounting as the Win Max 2
(G1619-04), so reuse its mount matrix. Verified on hardware:
without the matrix iio-sensor-proxy reports
AccelerometerOrientation=normal regardless of physical pose,
and applying the G1619-04 matrix makes orientation transitions
(normal / left-up / right-up / bottom-up) track the device
correctly.
2026-04-25 10:29:15 +01:00
Zbigniew Jędrzejewski-Szmek b045a2fa6f add helpers for unified --help formatting (#41805)
I see --help output formatting as contiuation of @keszybz's work on
options.[ch], hence let's start to add some really basic infrastructure
to unify the --help output more.
2026-04-25 11:23:18 +02:00
Yu Watanabe 15b20e19b1 ip-util: introduce several functions for IP packet handling (#41801) 2026-04-25 10:15:54 +09:00
Yu Watanabe 3b4e01637f ip-util: define IPV4_MIN_REASSEMBLY_SIZE
The number will be later used at several places.
2026-04-25 07:26:02 +09:00
Yu Watanabe 11def23206 ip-util: introduce udp_packet_verify()
This is mostly equivalent to dhcp_packet_verify_headers(), but
- it optionally returns the UDP payload as iovec, and
- supports IP header with options,
- check packet length more strictly.
2026-04-25 07:25:18 +09:00
Yu Watanabe e8497d6825 ip-util: introduce udp_packet_build()
Then make dhcp_packet_append_ip_headers() just a wrapper of the new
function. Currently, the wrapper is inefficient, but will be removed in
a later commit.
2026-04-25 07:22:28 +09:00
Yu Watanabe 7c87767d14 ip-util: introduce ip_checksum()
It is equivalent to dhcp_packet_checksum(). It is generic
and not specific to DHCP. Hence, renamed to ip_checksum().
2026-04-25 05:23:37 +09:00
Nick Rosbrook 37adb410a2 units: order networkd resolve hook After=network-pre.target
Without this, the socket is available well before systemd-networkd.service
is able to start, because of its own After=network-pre.target ordering.
Then, if resolved handles queries before network-pre.target, it will
hang waiting for networkd to reply to hook queries.

This is currently happening in the wild with cloud-init.
2026-04-24 17:59:54 +01:00