Commit Graph
87788 Commits
Author SHA1 Message Date
Daan De Meyer 40d0fb2eb2 Macroize option parsing in nspawn, vmspawn, journal-remote (#41542) 2026-04-08 15:33:51 +02:00
noxiouz b5a1ecb8fc networkd-wwan: handle link_get_by_name() errors in modem_simple_connect()
modem_simple_connect() ignored the return value of link_get_by_name()
and then checked link for NULL. Since the helper only sets the output
pointer on success, that could read an indeterminate value.

Check and log the return code directly with log_debug_errno().

Co-developed-by: Codex (GPT-5) <noreply@openai.com>
2026-04-08 13:59:32 +02:00
noxiouz 34649c6f55 networkd: keep static lease section valid on MACAddress= reset
config_parse_dhcp_static_lease_hwaddr() uses a cleanup helper that marks
a lease section invalid unless ownership is taken.

Add TAKE_PTR(lease) on the empty-rvalue reset path so subsequent valid
MACAddress= assignments in the same section are not dropped.

Co-developed-by: Codex (GPT-5) <noreply@openai.com>
2026-04-08 13:57:39 +02:00
Zbigniew Jędrzejewski-Szmek df45055942 tmpfiles: do not require STATX_ATIME (#41232)
Timestamps are not guaranteed to be set by `statx()`, and their presence
should not be asserted as a proxy to judge the kernel version. In
particular, `STATX_ATIME` is omitted from the return when querying a
file on a `noatime` superblock, causing spurious errors from tmpfiles:

```console
# SYSTEMD_LOG_LEVEL=debug systemd-tmpfiles --clean
<...>
Running clean action for entry X /var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-*/tmp
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-prometheus-smartctl-exporter.service-GKguQK/tmp) failed: Protocol driver not attached
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-systemd-logind.service-k8j52T/tmp) failed: Protocol driver not attached
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-irqbalance.service-7RJkev/tmp) failed: Protocol driver not attached
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-chronyd.service-8hkO5G/tmp) failed: Protocol driver not attached
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-dbus-broker.service-6P6LVl/tmp) failed: Protocol driver not attached
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-nginx.service-B5HX8B/tmp) failed: Protocol driver not attached
Running clean action for entry x /var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-*
Running clean action for entry q /var/tmp
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp) failed: Protocol driver not attached
<...>
```

Additionally, refactor `dir_cleanup()` slightly for self-consistency to
make
it evident that the `NSEC_INFINITY` transformation is correct.

Fixes #41227.
2026-04-08 13:56:13 +02:00
Zbigniew Jędrzejewski-Szmek e02f66d36f nspawn: make handling of compat --user=… less elaborate
Follow-up for e7fb7296f5.
2026-04-08 13:47:03 +02:00
Frantisek Sumsal 3d5bd67a22 fstab-generator: support swap on network block devices
Teach swap units to support the _netdev option as well, which should
make swaps on iSCSI possible. This mirrors the logic we already have for
regular mounts in both the fstab-generator and the core
(mount.c/swap.c).

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 11:51:09 +01:00
Luca Boccassi 5332cf31fc More assorted coverity fixes (#41548)
One more round, this time with the help of the claudebot, especially for
spelunking in git blame to find the original commit and writing commit
messages from the list of warnings exported from coverity

Co-developed-by: Claude
[claude@anthropic.com](mailto:claude@anthropic.com)
2026-04-08 11:26:27 +01:00
Lennart Poettering a50e6e0a1e sysext: provide systemd-{sysext,confext}-sysroot.service services (#41161)
This should pretty much close #38985

The new services are used to activate system and configuration
extensions for the main system from the initrd, this allows to overcome
the limitation that sysext/confext cannot be used to update the
resources which are required in the earliest boot of the system (before
systemd-sysext/systemd-confext start).

To make it possible to disable sysext/confext merging logic,
`systemd.sysext=0`, `systemd.confext=0`, `rd.systemd.sysext=0`,
`rd.systemd.confext=0` kernel cmdline options are introduced.

Closes #38985
2026-04-08 11:30:20 +02:00
Luca Boccassi 40eef914f3 limits-util: use MUL_SAFE for physical memory calculation
Coverity flags (uint64_t)sc * (uint64_t)ps as a potential overflow.
Use MUL_SAFE which Coverity understands via __builtin_mul_overflow.
Physical page count times page size cannot realistically overflow
uint64_t, but this makes it provable to static analyzers.

CID#1548042

Follow-up for 09bb6448ae
2026-04-08 01:28:51 +01:00
Luca Boccassi fda487ef30 sd-event: validate ssi_signo fits in signed int
Coverity flags si.ssi_signo as tainted data from read(), and warns
that casting it to signed could produce a negative value. Add an
explicit range check against INT_MAX before the SIGNAL_VALID check
to prove the cast is safe.

CID#1548033

Follow-up for c8b53fcfd3
2026-04-08 01:28:51 +01:00
Luca Boccassi 79a9a99728 sd-bus: assert ALIGN result in sd_bus_message_new
Coverity flags ALIGN(sizeof(sd_bus_message)) as potentially
returning SIZE_MAX, making the subsequent + sizeof(BusMessageHeader)
overflow. Store the ALIGN result in a local and assert it is not
SIZE_MAX.

CID#1548031

Follow-up for 4f5b28b72c
2026-04-08 01:28:50 +01:00
Luca Boccassi f0bb176ee1 sd-bus: use INC_SAFE and assert for message_from_header allocation
Coverity flags ALIGN() as potentially returning SIZE_MAX and the
subsequent a += label_sz + 1 as overflowing. Assert ALIGN result
is not SIZE_MAX and use INC_SAFE for the addition.

CID#1548030

Follow-up for 55354d5930
2026-04-08 00:34:56 +01:00
Luca Boccassi aaab31d7a0 nss-myhostname: use INC_SAFE for buffer index accumulation
Use overflow-safe INC_SAFE() instead of raw addition for idx
accumulation, so that Coverity can see the addition is checked.

CID#1548028

Follow-up for a05483a921
2026-04-08 00:26:33 +01:00
Luca Boccassi 0aaf7e697f test-path: use usec_add() for timeout calculation
Coverity flags now() + 30 * USEC_PER_SEC as overflowing because
now() can return USEC_INFINITY. Use usec_add() which saturates
on overflow instead of wrapping.

CID#1548025

Follow-up for 331461a5a2
2026-04-08 00:15:18 +01:00
Luca Boccassi e60937b585 sd-bus: assert ALIGN8 result is not SIZE_MAX
Coverity flags sizeof(BusMessageHeader) + ALIGN8(m->fields_size)
as overflowing because ALIGN_TO can return SIZE_MAX as an overflow
sentinel. Assert that the aligned value is not SIZE_MAX to prove
the addition is safe.

CID#1548023
CID#1548046

Follow-up for 2ac7c17f9d
2026-04-08 00:11:01 +01:00
Luca Boccassi 8fa088b886 recurse-dir: add assert for MALLOC_SIZEOF_SAFE lower bound
Coverity flags MALLOC_SIZEOF_SAFE(de) - offsetof(DirectoryEntries,
buffer) as a potential underflow when MALLOC_SIZEOF_SAFE returns 0.
After a successful malloc the return value is at least as large as
the requested size, but Coverity cannot trace this. Add an assert
to establish the lower bound.

CID#1548020

Follow-up for 6393b847f4
2026-04-07 23:59:16 +01:00
Luca Boccassi 1934c65108 uid-range: add assert to silence coverity
Coverity flags range->n_entries - j - 1 and j-- as potential
underflows. Add an assert that j > 0 before decrementing, since
j starts at i + 1 >= 1 and is never decremented below its
initial value.

CID#1548015

Follow-up for 8dcc66cefc
2026-04-07 23:45:39 +01:00
Luca Boccassi c9da918805 scsi_id: null-terminate serial after append_vendor_model
append_vendor_model() uses memcpy() to write VENDOR_LENGTH +
MODEL_LENGTH bytes without null-terminating. While the caller
zeroes the buffer beforehand, Coverity cannot trace this. Add
explicit null termination so the subsequent strlen() is provably
safe.

CID#1469706

Follow-up for 86fd0337c6
2026-04-07 23:08:29 +01:00
Zbigniew Jędrzejewski-Szmek f293418a50 shared/options: add helper function to peek at or consume the next arg
The test was partially written with Claude Opus 4.6. It's a bit on the
verbose side, but does the job.
2026-04-07 23:56:22 +02:00
Zbigniew Jędrzejewski-Szmek bf5bc9a7b2 nspawn: convert to the new option parser
Uses stop_at_first_nonoption for POSIX-style option parsing.

Includes a fixup for b4df0a9ee6, where
global optarg was used instead of the function param. This made no
difference previously because they were always equal.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 23:56:22 +02:00
Zbigniew Jędrzejewski-Szmek 4c778c51c0 vmspawn: convert to the new option parser
Uses stop_at_first_nonoption for POSIX-style option parsing.

--help output is the same, apart from whitespace differences
and common strings.

The error message for --ssh-key-type= is fixed.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 23:55:51 +02:00
noxiouz 874fbb870c coredumpctl: use loop_write() for dumping inline journal coredumps
Replace the bare write() call with loop_write(), which handles short
writes and EINTR retries. This also drops the now-unnecessary ssize_t
variable and the redundant r = log_error_errno(r, ...) self-assignment,
since loop_write() already stores its result in r.

Co-developed-by: Codex (GPT-5) <noreply@openai.com>
2026-04-07 17:56:36 +01:00
Zbigniew Jędrzejewski-Szmek 388428f9d8 Another batch of option/verb conversions (#41532)
Partially generated with Claude but then edited to fix conversions
errors.
2026-04-07 16:13:31 +02:00
Zbigniew Jędrzejewski-Szmek ee8483775e shared/options: add equivalent of "+…" for nested commandline parsing 2026-04-07 15:56:50 +02:00
LevitatingBusinessMan (Rein Fernhout) 0c510671f8 oci-registry: use overrideRegistry in fedora default
In registry.fedora.oci-registry use overrideRegistry instead of defaultRegistry.

fixes #41518
2026-04-07 13:52:47 +01:00
Daan De Meyer e4f535fdca vmspawn: Always enable CXL on supported architectures
Drop the --cxl= option and unconditionally enable cxl=on the QEMU
machine type whenever the host architecture supports it (x86_64 and
aarch64). The flag was only added for testing parity with mkosi's CXL=
setting and there is no reason to leave it as an opt-in toggle: with no
pxb-cxl device or cxl-fmw window attached, enabling it on the machine
only reserves a small MMIO region and emits an empty CEDT, so the cost
is negligible while removing one knob users would otherwise have to
flip explicitly to exercise the CXL code paths in QEMU.
2026-04-07 12:47:31 +02:00
Zbigniew Jędrzejewski-Szmek 54a0317f97 repart: fix option spelling and file path in comments and manpage (#41534)
Two minor fixes in comments and documentation:

 - Update comment that mentions file renamed in 211d2f972d
 - Do not reference `SizeMin=` where `SizeMinBytes=` is meant

No functional changes.
2026-04-07 11:42:25 +02:00
noxiouz 6e76281b2f journald-native: fix field-count limit off-by-one
Reject entries once the configured maximum field count is reached.

The previous check used n > ENTRY_FIELD_COUNT_MAX before appending a new field,
which let one extra field through in boundary cases. Switch the check to
n >= ENTRY_FIELD_COUNT_MAX so an entry at the limit is rejected before adding
another property.

Co-developed-by: Codex (GPT-5) <noreply@openai.com>
2026-04-07 11:22:45 +02:00
Jonas Rebmann 07745c222c repart: Do not refer to SizeMinBytes= as SizeMin=
No SizeMin= option exists for repart.d; it seems that SizeMinBytes= was
intended.

Update all references accordingly.

Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
2026-04-07 11:15:54 +02:00
Jonas Rebmann 3d67b5a084 test-specifier: update comment to moved file
src/partition/repart.c was renamed to src/repart/repart.c in commit
211d2f972d ("Rename src/partition to src/repart"), update the comment
accordingly.

Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
2026-04-07 11:03:48 +02:00
Zbigniew Jędrzejewski-Szmek 88aa9672b9 boot-check-no-failures: convert to the new option parser
--help is identical except for whitespace changes.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:53 +02:00
Zbigniew Jędrzejewski-Szmek c074adda05 battery-check: convert to the new option parser
--help is identical except for whitespace changes.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:53 +02:00
Zbigniew Jędrzejewski-Szmek 3ec64fa2ba updatectl: convert to the new option and verb parsers
Cosmetic differences in --help only.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:53 +02:00
Zbigniew Jędrzejewski-Szmek 358827d09e tpm2-setup: convert to the new option parser
--help is identical except for whitespace changes.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:53 +02:00
Zbigniew Jędrzejewski-Szmek 3ed2abf287 tpm2-clear: convert to the new option parser
--help is identical except for whitespace changes.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:53 +02:00
Zbigniew Jędrzejewski-Szmek 35d7a0f047 test-offline-passwd: convert to the new option parser
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:53 +02:00
Zbigniew Jędrzejewski-Szmek e106ebbcab sysusers: convert to the new option parser
Cosmetic differences in --help only.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:53 +02:00
Zbigniew Jędrzejewski-Szmek 386dc2175d tmpfiles: convert to the new option parser
The --image fallthrough into -E is replaced by duplicating the
exclude_default_prefixes() call inline.

Cosmetic differences in --help only.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:53 +02:00
Zbigniew Jędrzejewski-Szmek fd5c19e8d0 varlinkctl: convert to the new verb macros
The description of --exec is moved to a separate footer. It requires
special formatting and doesn't fit in the autogenerated table of
verbs.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:52 +02:00
Zbigniew Jędrzejewski-Szmek e1eae0cf78 varlinkctl: convert to the new option parser
The -E short option previously used fallthrough into the --more case;
since macro-generated case labels don't support fallthrough (with some
older compilers), the --more logic is now duplicated inline in the -E
handler.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:52 +02:00
Zbigniew Jędrzejewski-Szmek e3d25c82ab imdsd: convert to the new option parser
Previously -w was ambiguously described in --help as taking an argument,
but it is in fact an argumentless alias for --wait=yes.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:52 +02:00
Zbigniew Jędrzejewski-Szmek e59fea0088 shared/options: quote the metavar in --help output
imdsd uses --extra-header='NAME: VALUE'. We could include the quotes
in the metavar string, but I think it's nicer to only do that in the
printed output, so that later, when we add introspection, the value
there will not include the quotes.
2026-04-07 10:55:52 +02:00
Zbigniew Jędrzejewski-Szmek 6adc9abc4a imds: convert to the new option parser
Cosmetic changes in --help output only.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:55:52 +02:00
Vitaly Kuznetsov 2299a37e28 sysext: provide a cmdline kill switch for the sysext/confext merging logic
While it is possible to disable sysext/confext merging in the main system
with 'systemctl disable', sysext/confext are always merged in the initrd,
both by systemd-{sys,conf}ext-initrd.service and by
systemd-{sys,conf}ext-sysroot.service and especially the latter can be
unexpected. Provide kernel cmdline options systemd.{sys,conf}ext=0 and
rd.systemd.{sys,conf}ext=0 covering all options.
2026-04-07 09:51:03 +02:00
Vitaly Kuznetsov c70b17daad sysext: provide systemd-{sysext,confext}-sysroot.service services
The new services are used to activate system and configuration extensions
for the main system from the initrd, this allows to overcome the limitation
that sysext/confext cannot be used to update the resources which are required
in the earliest boot of the system (before systemd-sysext/systemd-confext
start).
2026-04-07 09:50:59 +02:00
Vitaly Kuznetsov f778f08fae NEWS: fix sysext/confext configuration file names in v259
/etc/systemd/systemd-{confext,sysext}.conf are likely just leftovers
from an older in-development version of the feature.
2026-04-07 09:22:29 +02:00
Christian Brauner ea8439e1cf Two small fixes (#41506) 2026-04-07 09:11:07 +02:00
Christian Brauner 1025ca530b sd-json, ssh-proxy: two bugfixes (#41529)
- Fix sd_json_variant_unsigned() dispatching to the wrong accessor
    for json variant references.
  - Fix a use-after-free of a borrowed varlink reply reference in
    ssh-proxy.
2026-04-07 08:53:36 +02:00
Christian Brauner 7ed34c0498 vmspawn: use machine name in runtime directory path (#41530)
Replace the random hex suffix in the runtime directory with the machine
name, changing the layout from /run/systemd/vmspawn.<random> to
/run/systemd/vmspawn/<machine-name>/.

This makes runtime directories machine-discoverable from the filesystem
and groups all vmspawn instances under a shared parent directory,
similar to how nspawn uses /run/systemd/nspawn/.

Use runtime_directory_generic() instead of runtime_directory() since
vmspawn is not a service with RuntimeDirectory= set and the
$RUNTIME_DIRECTORY check in the latter never succeeds. The directory is
always created by vmspawn itself and cleaned up via
rm_rf_physical_and_freep on exit. The parent vmspawn/ directory is
intentionally left behind as a shared namespace.
2026-04-07 00:23:19 +02:00
Ivan Shapovalov 122de8d93d tmpfiles: do not mandate STATX_ATIME and STATX_MTIME
Timestamps are not guaranteed to be set by `statx()`, and their presence
should not be asserted as a proxy to judge the kernel version. In
particular, `STATX_ATIME` is omitted from the return when querying a
file on a `noatime` superblock, causing spurious errors from tmpfiles.

Correctness analysis
====================

The timestamps produced by the `statx()` call in `opendir_and_stat()`
are only ever used once, in `clean_item_instance()` (lines 3148-3149)
as inputs to `dir_cleanup()`. Convert absent timestamps into
`NSEC_INFINITY` as per the previous commit.

Fixes #41227.
2026-04-06 22:53:00 +02:00