Commit Graph
100 Commits
Author SHA1 Message Date
Luca Boccassi 4276d3721e semaphore: stop deleting all apt sources
The image configuration was changed and the main sources are
now in a drop-in apt sources files too, so deleting the whole
drop-in directory breaks installing packages. Just delete the
disabled ones and chrome.
2026-05-04 16:50:05 +01:00
Luca Boccassi 7e6507c43f test: fix flaky TEST-04-JOURNAL.reload.sh due to service name collision
write_to_journal() was called via $(...) command substitution, so
SERVICE_COUNTER++ ran in a subshell and never incremented in the
parent:

[ 1492.668302] TEST-04-JOURNAL.sh[15064]: + local service=test-0-18493.service
[ 1492.725882] TEST-04-JOURNAL.sh[15064]: + local service=test-0-18009.service
[ 1492.739643] TEST-04-JOURNAL.sh[15064]: + local service=test-0-18493.service
[ 1492.774586] TEST-04-JOURNAL.sh[15064]: + local service=test-0-25540.service
[ 1492.815664] TEST-04-JOURNAL.sh[15064]: + local service=test-0-15916.service
[ 1492.867067] TEST-04-JOURNAL.sh[15064]: + local service=test-0-20327.service
[ 1492.899077] TEST-04-JOURNAL.sh[15064]: + local service=test-0-86.service
[ 1497.289715] TEST-04-JOURNAL.sh[15064]: + local service=test-0-10849.service
[ 1497.335791] TEST-04-JOURNAL.sh[15064]: + local service=test-0-18009.service

With 99999 possible unit names collisions are rare but not impossible,
so every now and then a CI run fails.

Have write_to_journal() set a global SERVICE_NAME variable instead and
call it directly so SERVICE_COUNTER actually goes up through the test.
2026-05-04 14:30:03 +01:00
Luca Boccassi 3ec1a8ab22 test: make TEST-86-MULTI-PROFILE-UKI robust against reruns
When qemu reboots instead of shutting down after the last iteration,
the profile is already set to profile2 but the /root/encrypted.raw is
gone so the test fails. Reset the default boot entry at the end of the
test to make it robust against reruns.

Fixes https://github.com/systemd/systemd/issues/39553
2026-05-03 18:08:33 +01:00
Luca Boccassi 2fc008b9e4 test: make TEST-70-TPM2 robust against reruns
The test leaves a lot of state around, and when the test is re-run,
for example due to the qemu bug that makes a VM reboot instead of
shutting down, it fails.

Do more cleanups in the traps.

[  162.642175] TEST-70-TPM2.sh[2815]: Calculated public key name: 000b2b66edc3a466e81059286aaf38d09ea42a7a9dcdf6ba3b664c62f0cae4ce4f66
[  162.642628] TEST-70-TPM2.sh[2815]: PolicyAuthorize calculated digest: 2caa740101f65734d50395d6abc64fa46015d40d1f5de239434578544e592a92
[  162.643681] TEST-70-TPM2.sh[2815]: Calculated NV index name: 000b439cfa1534815bbe8d33b80c56f5a8d17d36fe94a7782b23a37b50def5fc5eaa
[  162.645111] TEST-70-TPM2.sh[2815]: PolicyAuthorizeNV calculated digest: 69ee0e89fafe6b9df2cd6a5defbf74aa46cf6d92703e645d463549da4ba5e1a4
[  162.645407] TEST-70-TPM2.sh[2815]: Combined signed PCR policies and pcrlock policies cannot be calculated offline, currently.
[  162.649576] TEST-70-TPM2.sh[2815]: Releasing crypt device /dev/loop0 context.
[  162.652433] TEST-70-TPM2.sh[2815]: Releasing device-mapper backend.
[  162.653518] TEST-70-TPM2.sh[2815]: Closing read only fd for /dev/loop0.
[  162.654359] TEST-70-TPM2.sh[2815]: Closing read write fd for /dev/loop0.
[  162.654786] TEST-70-TPM2.sh[2815]: Failed to encrypt device: Operation not supported

Fixes https://github.com/systemd/systemd/issues/38241
2026-05-03 18:08:33 +01:00
Luca Boccassi 8fbc93345e test: bump device timeout to 300s for TPM2 tests
Booting with TPM2 has become slower recently so tests are randomly
failing, try to bump the default device timeout in those test VMs
2026-05-03 15:06:51 +01:00
Luca Boccassi 378d6bd9c6 test: fix json encoding issue due to backslashes
TEST-74-AUX-UTILS.sh[3782]: + varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"name": "proc-sysrq\x2dtrigger.mount"}'
TEST-74-AUX-UTILS.sh[3783]: + jq -e .context.Mount
TEST-74-AUX-UTILS.sh[3782]: Failed to parse parameters at <argv[4]>:1:10: Invalid argument

Use jq to encode the input
2026-05-03 16:03:33 +02:00
Luca Boccassi afa4a559e1 test: avoid getting stuck on /dev/fuse
On Fedora Rawhide checking /dev/fuse in the test is getting stuck and timing out:

[   47.930104] TEST-13-NSPAWN.sh[2588]: + testcase_fuse
[   47.930424] TEST-13-NSPAWN.sh[2589]: ++ cat
[   58.772538] audit: type=1131 audit(1777728357.726:778): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-importd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
[  901.882562] audit: type=1131 audit(1777729200.830:782): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-tmpfiles-clean comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Finishing after writing 176921 entries
qemu-system-x86_64: terminating on signal 15 from pid 70717 (/usr/bin/python3)

Wrap it with a timeout to avoid getting stuck forever

Follow-up for dc3223919f
2026-05-03 16:00:44 +02:00
Luca Boccassi 26cba7ffee test: make varlink StartTransient checks compatible with jq 1.6
The new "varlinkctl --more StartTransient" subtest pipes a JSON-SEQ
stream of multiple records into "jq --seq -e ...". CentOS 9
ships jq 1.6, where -e only inspects the last input record's output:
when the trailing record (the final reply) doesn't match the
"select()" filter, jq exits non-zero even though earlier records
match, so the test fails.

Use --slurp which collapses the records into an array first and
returns a single bool.

Follow-up for 1cde1cc3ba
2026-05-03 15:57:25 +02:00
Luca Boccassi 630f5a1fc4 mkosi: update debian commit reference to 1302f123d9ab65bbaff5d95935eabfd659456550
* 1302f123d9 Restrict wildcard for new files
* a6d0098d10 Install new files for upstream build
* ce07fd7616 d/t/boot-and-services: use coreutils tunable in apparmor test (LP: #2125614)
2026-04-30 20:30:22 +01:00
Luca Boccassi 33ac56f462 man: add section about systemd-boot Type#1 sidecars
Follow-up for 6b1324fb86

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 17:57:26 +01:00
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
Luca Boccassi b76e18ce9a various trivial tweaks (#41828) 2026-04-26 22:40:01 +01:00
Luca Boccassi d41555dd2c nss-myhostname: fix maybe-uninitialized warning
In resolute with gcc 15.2.0:

472s ../src/nss-myhostname/nss-myhostname.c: In function ‘_nss_myhostname_gethostbyname4_r’:
472s ../src/nss-myhostname/nss-myhostname.c:132:44: error: ‘local_address_ipv4’ may be used uninitialized [-Werror=maybe-uninitialized]
472s   132 |                 *(uint32_t*) r_tuple->addr = local_address_ipv4;
472s       |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
472s ../src/nss-myhostname/nss-myhostname.c:42:18: note: ‘local_address_ipv4’ was declared here
472s    42 |         uint32_t local_address_ipv4;
472s       |                  ^~~~~~~~~~~~~~~~~~
2026-04-24 16:45:19 +01:00
Luca Boccassi b54ef83414 repart: trim NUL bytes from verity sig split artifact
The verity signature partition content is a bare JSON object. Repart
pads it with zeros to fill the GPT partition. But when splitting out
the content as an individual file, the padding remains, so it's not
a valid text file.

jq started rejecting files with NUL bytes to fix a security issue:
https://github.com/jqlang/jq/commit/6374ae0bcdfe33a18eb0ae6db28493b1f34a0a5b

Trim the output when writing these files out.
2026-04-23 12:16:10 +02:00
Luca Boccassi 6958d4c79d oomctl: add missing assert flagged by coccinelle
FAIL: check-pointer-deref.cocci found issues in /home/runner/work/systemd/systemd/src/oom/:
diff -u -p /home/runner/work/systemd/systemd/src/oom/oomctl.c /tmp/nothing/oomctl.c
--- /home/runner/work/systemd/systemd/src/oom/oomctl.c
+++ /tmp/nothing/oomctl.c
@@ -107,7 +107,6 @@ static int parse_argv(int argc, char *ar
                         break;
                 }

-        *ret_args = option_parser_get_args(&state);
         return 1;
 }

Coccinelle check(s) failed. For each flagged dereference, either:
  - Add assert(param)/ASSERT_PTR(param) at the top of the function (if the parameter must not be NULL)
  - Add an if (param) guard before the dereference (if NULL is valid)
  - Add POINTER_MAY_BE_NULL(param) if NULL is okay for param

Follow-up for 143af68ee1
2026-04-22 16:50:18 +02:00
Luca Boccassi b4053a6c4d mkosi: update debian commit reference to 94af257c72ac3e9bf20e324ff31c3bd5d8197f0e
* 94af257c72 d/t/control: pull libmicrohttpd-dev for unit-tests suite
* 08263f18a4 d/t/control: pull libfdisk-dev for test suites
* e54175a0a4 Install new files for upstream build
2026-04-22 13:56:13 +01:00
Luca Boccassi 6dccf54cd6 mkosi: trim verity.sig json files to remove NUL padding before passing to jq
jq started rejecting input that has NUL bytes to fix some security issues,
so we need to trim the verity.sig json files, which are spat out with
the NUL bytes padding from the GPT partition content.

‣  Running postinstall script /home/runner/work/systemd/systemd/mkosi/mkosi.postinst.chroot…
jq: parse error: Invalid numeric literal at EOF at line 1, column 16384
‣ "/work/postinst final" returned non-zero exit code 5.

https://github.com/jqlang/jq/commit/6374ae0bcdfe33a18eb0ae6db28493b1f34a0a5b
2026-04-22 13:56:13 +01:00
Luca Boccassi da8a8b5de8 Translations update from Fedora Weblate (#41765)
Translations update from [Fedora
Weblate](https://translate.fedoraproject.org) for
[systemd/main](https://translate.fedoraproject.org/projects/systemd/main/).



Current translation status:

![Weblate translation
status](https://translate.fedoraproject.org/widget/systemd/main/horizontal-auto.svg)
2026-04-22 12:16:33 +01:00
Luca Boccassi 2a6e40c2f5 bootspec: two smaller tweaks to bootspec.c (#41690)
The first commit is prep work for #41543 but I think it makes a ton of
sense on its own as it cleans up logging a bit.
2026-04-18 11:02:35 +01:00
Luca Boccassi e6fbf51fd6 Revert "ci: Switch PR review workflow to Opus 4.7 via Mantle endpoint"
This reverts commit 0112338585.
2026-04-17 15:35:45 +02:00
Luca Boccassi 2e79f8aa41 systemctl: add --kernel-cmdline= argument
Allows appending kernel command line arguments, like
kexec-tool does. This is especially needed for the integration
tests, as mkosi adds a bunch of options that are needed for the
test suite to work, and it breaks without them.
2026-04-17 13:58:05 +01:00
Luca Boccassi 73aeb1b538 Followups for recent changes to basic/iovec-wrapper (#41676) 2026-04-17 13:55:51 +01:00
Luca Boccassi 3e716178cc machined: gate metadata querying behind inspect-machines/images action
Ensure only privileged users can call the system scope machined's
APIs that get data out of a machine

Follow-up for 1bd979dddb
Follow-up for 9153b02bb5
2026-04-16 13:29:33 +02:00
Luca Boccassi 5cee6c6a92 mkosi: update fedora commit reference to 207e2d004468bf79a8bd78182d9b10956edf45c7
* 207e2d0044 Stop building support for openssl engines
* 36a234147f Upload sources
* 3681163f81 Version 260.1
* 8f4f0f58e3 Version 260
* e3fab23aa0 Version 260~rc4
* e4c1c2100b Version 260~rc3
* 453696813e Fix typo in unit name in %post scriptlet
* 154edb7cdb Silence false positive "HWID match failed, no DT blob" error (rhbz#2444759)
* 03b6637c35 riscv64 port has LTO disabled
* ce1dec6a40 Version 260~rc2
* 809049777c Add patch for symlink creation error
* 6ff27708f7 Enable getty@.service through presets
* ba7807fbce Drop scriptlet for upgrades from versions <253
* 455f277188 Move support for tpm2 to systemd-udev subpackage
* 0183bc784e Version 260~rc1
2026-04-14 23:26:16 +01:00
Luca Boccassi b1d9127c39 resolved: check for reset-statistics polkit action via D-Bus too
The varlink method checks for polkit authorization, so also
update the D-Bus method to match it.

Follow-up for cf01bbb7a4
2026-04-15 00:07:47 +02:00
Luca Boccassi 275ec1160b importd: harden curl file protocol handling
With old libcurl versions file:// can get redirects which can be messy, while
the new version rejects them. Set an option to explicit block them.
2026-04-14 10:45:38 +02:00
Luca Boccassi f125fc6a22 journal-upload: also disable VERIFYHOST when --trust=all is used
When --trust=all disables CURLOPT_SSL_VERIFYPEER, the residual
CURLOPT_SSL_VERIFYHOST check is ineffective since an attacker can
present a self-signed certificate with the expected hostname. Disable
both for consistency and log that server certificate verification is
disabled.

Follow-up for 8847551bcb
2026-04-13 22:11:50 +01:00
Luca Boccassi a9e9288288 machined: pass user as positional argument in machine_default_shell_args()
Instead of interpolating the user name directly into the sh -c script
body via asprintf %s, pass it as a positional parameter ($1) in a
separate argv entry. This avoids the user string being parsed as part
of the shell script syntax.

Also validate the user name in bus_machine_method_open_shell() with
valid_user_group_name(), matching the validation already done on the
Varlink path via json_dispatch_const_user_group_name().

Follow-up for 49af9e1368
2026-04-13 22:11:50 +01:00
Luca Boccassi 4bf9db7314 logind: reject wall messages containing control characters
method_set_wall_message() and the property setter only checked the
message length but not its content. Since wall messages are broadcast
to all TTYs, control characters in the message could interfere with
terminal state. Reject messages containing control characters other
than newline and tab.

Follow-up for 9ef15026c0
Follow-up for e2fa5721c3
2026-04-13 22:11:50 +01:00
Luca Boccassi 04f32dddd7 core: check selinux access on each unit when listing
Units might have different access rules, so check the access on each
unit when querying the full list.
2026-04-13 22:11:50 +01:00
Luca Boccassi 26fd286210 core: add missing SELinux access checks when listing units
Add mac_selinux_unit_access_check_varlink() to the unit enumeration
loop in vl_method_list_units(), silently skipping units the caller
is not permitted to see, matching the D-Bus ListUnits behavior.
Add mac_selinux_access_check_varlink() to vl_method_describe_manager().

Follow-up for 472abf7bec
Follow-up for 736349958e
2026-04-13 22:11:43 +01:00
Luca Boccassi 7fbdc6a8eb udev/scsi-id: various typing refactorings 2026-04-12 21:32:16 +01:00
Luca Boccassi 06d3f37336 udev/scsi-id: check for invalid header from kernel buffer 2026-04-12 21:28:48 +01:00
Luca Boccassi 5f700d148c udev/scsi-id: check for invalid chars in various fields received from the kernel
Follow-up for 16325b35fa
2026-04-12 21:28:48 +01:00
Luca Boccassi 03fa2f8982 More assorted coverity fixes (#41601)
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-12 21:19:12 +01:00
Luca Boccassi 44296e41db test-json: add iszero_safe guards for float division at index 0 and 1
The existing iszero_safe guards at index 9 and 10 were added to
silence Coverity, but the same division-by-float-zero warning also
applies to the divisions at index 0 (DBL_MIN) and 1 (DBL_MAX).

CID#1587762

Follow-up for 7f133c996c
2026-04-12 13:25:28 +01:00
Luca Boccassi efccc0dc23 debug-generator: assert breakpoint type is valid before bit shift
The BreakpointType enum includes _BREAKPOINT_TYPE_INVALID (-EINVAL),
so Coverity flags the bit shift as potentially using a negative shift
amount. Add an assert to verify the type is in valid range, since the
static table only contains valid entries.

CID#1568482

Follow-up for 1929226e7e
2026-04-12 13:25:28 +01:00
Luca Boccassi 1afc0c6c60 nss-myhostname: add more 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-12 13:24:50 +01:00
Luca Boccassi ff102359b7 uid-range: add assert to prevent underflow in coalesce loop
Coverity flags range->n_entries - j as a potential underflow
in the memmove size calculation. Add assert(range->n_entries > 0)
before decrementing n_entries, which holds since the loop condition
guarantees j < n_entries.

CID#1548015

Follow-up for 8dcc66cefc
2026-04-12 13:24:50 +01:00
Luca Boccassi 53c87c096c json-stream: fix NULL pointer passed to memcpy on first read with INPUT_SENSITIVE
When JSON_STREAM_INPUT_SENSITIVE is set before the first read,
input_buffer is NULL, input_buffer_size is 0, and input_buffer_index
is 0. The old condition '!INPUT_SENSITIVE && index == 0' would route
this case into the else branch which calls memcpy() with a NULL source
pointer, which is undefined behavior even when the length is zero, and
is caught by UBSan.

Fix by checking input_buffer_index == 0 first, then allowing the
GREEDY_REALLOC fast path also when input_buffer_size == 0, since
there is no sensitive data to protect from realloc() copying in that
case. The else branch is now only entered when there is actual data
to copy (input_buffer_size > 0), guaranteeing input_buffer is
non-NULL.

Follow-up for 6b1a59d594
2026-04-11 06:42:28 +02:00
Luca Boccassi a1813a40ec docs: beef up SECURITY.md rules for reporting
With yeswehack.com suspended due to funding issues for triagers being
worked out, reports on GH are starting to pile up. Explicitly define
some ground rules to avoid noise and time wasting.
2026-04-10 17:34:03 +02:00
Luca Boccassi c0b3b855b7 coredumpctll: avoid unnecessary heap copy and decompression for field existence checks (#41520)
`print_list()` and `print_info()` used `RETRIEVE()` to `strndup()` the
entire
`COREDUMP` field into a heap-allocated string, only to check whether it
exists.
With `sd_journal_set_data_threshold(j, 0)` in `print_info()`, this
copies the
full coredump binary (potentially hundreds of MB) to heap just to print
"Storage: journal".

This PR:

1. Makes `sd_journal_get_data()` output parameters optional
(`NULL`-safe), so
   callers can do pure existence checks without receiving the data.
2. Short-circuits `maybe_decompress_payload()` after
`decompress_startswith()`
   succeeds when neither output pointer is requested, skipping full blob
   decompression for compressed journal entries.
3. Switches coredumpctl to pass `NULL, NULL` for the existence checks
instead
   of heap-copying via `RETRIEVE()`.
2026-04-08 21:34:47 +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
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
Luca Boccassi ba74a144c4 Translations update from Fedora Weblate (#41499)
Translations update from [Fedora
Weblate](https://translate.fedoraproject.org) for
[systemd/main](https://translate.fedoraproject.org/projects/systemd/main/).



Current translation status:

![Weblate translation
status](https://translate.fedoraproject.org/widget/systemd/main/horizontal-auto.svg)
2026-04-03 21:17:13 +01:00
Luca Boccassi 4725767730 Fix build with -fno-semantic-interposition
Fixes https://github.com/systemd/systemd/issues/41494

Follow-up for 44cc82bfbf
2026-04-03 19:10:05 +02:00
Luca Boccassi 34ff7243e1 networkd: fix assert with IPFamily=both in MobileNetwork conf and add minimal mock for test coverage (#41402) 2026-04-02 12:28:04 +01:00
Luca Boccassi 55327a1fd8 core: do not GC units that have FDs stored
If a unit has FileDescriptorStorePreserve=yes we'll keep its FDs
around in case it starts again. But if there are no reverse
dependencies referencing it, we'll also GC it and lose all the FDs,
which defeats the point of the setting (which is opt-in).

Do not GC units that have FDs stored to avoid this.

Follow-up for b9c1883a9c
2026-04-02 12:22:43 +01:00
Luca Boccassi 5a20987bef service: add macro to check if FD store is empty
Follow-up for b9c1883a9c
2026-04-02 12:22:43 +01:00
Luca Boccassi 501ece433b service: transition unit from SERVICE_DEAD_RESOURCES_PINNED to SERVICE_DEAD when fd store is emptied
Follow-up for b9c1883a9c
2026-04-02 12:22:43 +01:00
Luca Boccassi 7918e02fc7 Two followups for recent commits (#41457) 2026-04-01 18:20:58 +01:00
Luca Boccassi 07167cefd6 cryptenroll: harden some variables with erasure on cleanup
This doesn't really matter as it runs in user contexts, but
follow good practice and mark all variables containing secrets
for erasure on cleanup

Reported on yeswehack.com as YWH-PGM9780-170
2026-03-30 23:35:05 +02:00
Luca Boccassi ea1e81e117 journald: add assert for allocated buffer size
Coverity flags allocated - 1 as a potential underflow when
allocated is 0. After GREEDY_REALLOC succeeds the buffer is
guaranteed non-empty, but Coverity cannot trace through the
conditional. Add an assert to document this.

CID#1548053

Follow-up for ec20fe5ffb
2026-03-30 13:11:25 +01:00
Luca Boccassi 7f133c996c test-json: avoid divide-by-zero coverity warning for index 9
Same fix as d0a066a1a4 did for
index 10: add iszero_safe() check before dividing by the
json variant real value.

CID#1587762

Follow-up for d0a066a1a4
2026-03-30 13:11:25 +01:00
Luca Boccassi 569c849be4 nspawn-oci: add asserts for UID/GID validity after dispatch
Coverity flags UINT32_MAX - data.container_id as an underflow
when container_id could be UID_INVALID (UINT32_MAX). After
successful sd_json_dispatch_uid_gid(), the values are guaranteed
valid, but Coverity cannot trace through the callback. Add
asserts to document this invariant.

CID#1548072

Follow-up for 91c4d1affd
2026-03-30 10:55:33 +01:00
Luca Boccassi a770fb3e14 boot: clamp setup header copy size to sizeof(SetupHeader)
The setup_size field from the kernel image header is used as part
of the memcpy size. Clamp it to sizeof(SetupHeader) to ensure the
copy does not read beyond the struct bounds even if the kernel
image header contains an unexpected value.

CID#1549197

Follow-up for d62c177756
2026-03-30 10:55:33 +01:00
Luca Boccassi 24bdc49c23 creds-util: add assert for output buffer size overflow safety
Coverity flags the multi-term output.iov_len accumulation as a
potential overflow. Add an assert after the calculation to verify
the result is at least as large as the input, catching wraparound.

CID#1548068

Follow-up for 21bc0b6fa1
2026-03-30 10:55:33 +01:00
Luca Boccassi de2a7614f1 calendarspec: use ADD_SAFE for repeat offset calculation
Use overflow-safe ADD_SAFE() instead of raw addition when
computing the next matching calendar component with repeat.
On overflow, skip the component instead of using a bogus value.

CID#1548052

Follow-up for a2eb5ea79c
2026-03-30 10:55:33 +01:00
Luca Boccassi 1eb2bd5aaf repart: use INC_SAFE for partition min size accumulation
Use overflow-safe INC_SAFE() instead of raw addition when
accumulating partition minimum size components.

CID#1548041

Follow-up for 170c982345
2026-03-30 09:37:32 +01:00
Luca Boccassi ded2e6e976 test-strv: avoid unsigned wraparound in backwards iteration
Use pre-decrement starting from 3 instead of post-decrement
starting from 2, so that the unsigned counter does not wrap
past zero on the final iteration.

CID#1548035

Follow-up for 02f19706a9
2026-03-30 09:37:32 +01:00
Luca Boccassi 4f5b28b72c sd-bus: add assert_cc for message allocation size
Use CONST_ALIGN_TO to express the compile-time overflow check for
the ALIGN(sizeof(sd_bus_message)) + sizeof(BusMessageHeader)
allocation, since ALIGN() is not constexpr.

CID#1548031

Follow-up for de1c301ed1
2026-03-30 09:37:32 +01:00
Luca Boccassi aa2cc18c76 sd-bus: use usec_add() for auth timeout calculation
Use the overflow-safe usec_add() instead of raw addition for
computing the authentication timeout.

CID#1548036

Follow-up for e3017af973
2026-03-30 09:37:32 +01:00
Luca Boccassi a05483a921 nss-myhostname: add asserts for buffer index accumulation
Coverity flags idx += 2*sizeof(char*) and idx += sizeof(char*)
as potential overflows. The idx is bounded by the ms buffer size
calculation, add asserts to document this.

CID#1548028

Follow-up for e8a7a31539
2026-03-30 09:37:32 +01:00
Luca Boccassi 331461a5a2 tree-wide: add assert_cc for time constant multiplications
Coverity flags compile-time constant multiplications of
USEC_PER_SEC, USEC_PER_MSEC, and USEC_PER_HOUR as potential
overflows. Add assert_cc() to prove they fit at build time.

CID#1548025
CID#1548048
CID#1548055
CID#1548059

Follow-up for 500727c220
Follow-up for 27d340c772
Follow-up for e537352b9b
Follow-up for 1007ec60e6
2026-03-30 09:37:32 +01:00
Luca Boccassi 96b085c4be repart: add assert for offset + current_size overflow safety
Coverity flags a->after->offset + a->after->current_size as a
potential overflow. Both values are validated as not UINT64_MAX
by existing asserts, add an explicit overflow check to document
the invariant for static analyzers.

CID#1548063

Follow-up for e594a3b154
2026-03-30 09:37:31 +01:00
Luca Boccassi 3fd6774633 networkd-ndisc: add assert for DNSSL allocation overflow safety
Coverity flags ALIGN(sizeof(NDiscDNSSL)) + strlen(*j) + 1 as a
potential overflow. Domain names are protocol-bounded but add an
assert to make this explicit for static analyzers.

CID#1548066

Follow-up for 1e7a0e21c9
2026-03-30 09:37:31 +01:00
Luca Boccassi 21cc3216a7 dns-packet: add asserts for allocation overflow safety
Coverity flags ALIGN(sizeof(DnsPacket)) + size calculations in
dns_packet_new() and dns_packet_dup() as potential overflows. The
sizes are bounded by DNS_PACKET_SIZE_MAX but add asserts to make
this explicit for static analyzers.

CID#1548058
CID#1548076

Follow-up for c73ce96b56
2026-03-30 09:37:31 +01:00
Luca Boccassi 09bb6448ae limits-util: add assert for physical memory calculation overflow
Coverity flags (uint64_t) sc * (uint64_t) ps as a potential
overflow. Add an assert to make the bounds explicit for static
analyzers.

CID#1548042

Follow-up for eefc66aa8f
2026-03-30 09:37:31 +01:00
Luca Boccassi 02f848b375 user-util: add asserts for buffer allocation overflow safety
Coverity flags ALIGN(sizeof(struct passwd/group)) + bufsize as
potential overflows in the getpw/getgr helpers. Add asserts to
make the bounds explicit for static analyzers.

CID#1548047
CID#1548049
CID#1548069
CID#1548070

Follow-up for 75673cd8ae
2026-03-30 09:37:31 +01:00
Luca Boccassi 55354d5930 sd-bus: add asserts for message size overflow safety
Coverity flags arithmetic in BUS_MESSAGE_SIZE(),
BUS_MESSAGE_BODY_BEGIN() and message_from_header() as potential
overflows. The values are validated at message creation time, but
add asserts to make the invariants explicit for static analyzers.

CID#1548023
CID#1548030
CID#1548046

Follow-up for 6629161f82
2026-03-30 09:37:31 +01:00
Luca Boccassi 56df6e5669 sd-daemon: add assert before CMSG_SPACE subtraction
Coverity flags the subtraction from msg_controllen as a potential
underflow. The CMSG_SPACE was added when send_ucred was set, and
the subtraction only runs when send_ucred was true, so it is safe.
Add an assert to document this invariant.

CID#1548074

Follow-up for 64144440a5
2026-03-30 09:37:31 +01:00
Luca Boccassi a702b9b6ea sd-json: silence false positive in sd_json_variant_filter
Same pattern as the fix for sd_json_variant_unset_field in
9b3715d529: cache the element
count in a local variable and assert it is at least 2 before
subtracting.

CID#1548029

Follow-up for f2ff34ff2a
2026-03-30 09:37:31 +01:00
Luca Boccassi 4ff8fb899b journal: add assert for max_size overflow safety
Coverity flags max_size*2 as a potential overflow. The value is
bounded by MAX_SIZE_UPPER (128 MiB) or JOURNAL_COMPACT_SIZE_MAX
(4 GiB), so doubling is safe within uint64_t. Add an assert to
document this.

CID#1548019

Follow-up for 8580d1f73d
2026-03-30 09:37:31 +01:00
Luca Boccassi 34c82cbe2f systemd-repart man page fixes (#41410)
Found two small issues in the man page.
2026-03-29 13:58:04 +01:00
Luca Boccassi 4b25c74c20 recurse-dir: add assert_cc for DIRENT_SIZE_MAX allocation
Coverity flags offsetof(DirectoryEntries, buffer) + DIRENT_SIZE_MAX * 8
as a potential overflow. All operands are compile-time constants, so add
an assert_cc() to prove this at build time.

CID#1548020

Follow-up for 6393b847f4
2026-03-28 20:24:22 +00:00
Luca Boccassi 3e38052f1d exec-util: use unsigned shift for ExecCommandFlags
Using signed int literal '1' in left shift operations can
theoretically lead to undefined behavior. Use 1U to be explicit
about unsigned arithmetic.

CID#1548018

Follow-up for b3d593673c
2026-03-28 20:13:40 +00:00
Luca Boccassi cda2962daf compress: add assert for space doubling overflow safety
Coverity flags 2 * space as a potential overflow. The space value
is bounded by prior allocation success, but add an explicit assert
to document this for static analyzers.

CID#1548056

Follow-up for 5e592c66bd
2026-03-28 20:13:03 +00:00
Luca Boccassi 2bd6930efe importd: add assert for log_message_size accumulation bounds
Coverity flags log_message_size += l as a potential overflow, but l
is bounded by the read() count parameter which is
sizeof(log_message) - log_message_size. Add an assert to make this
invariant explicit.

CID#1548062

Follow-up for 3d7415f43f
2026-03-28 20:10:14 +00:00
Luca Boccassi c34169e9d3 sd-bus: add asserts for rbuffer_size accumulation bounds
Coverity flags rbuffer_size += k as a potential overflow, but k is
always bounded by the iov size (which is the difference between the
allocated buffer and current rbuffer_size). Add asserts to make this
invariant explicit.

CID#1548044
CID#1548071

Follow-up for a7e3212d89
2026-03-28 20:09:40 +00:00
Luca Boccassi 1b7d2fa978 uid-range: add asserts to document overflow safety in coalesce
Coverity flags the x->start + x->nr and y->start + y->nr additions
as potential overflows. These are safe because uid_range_add_internal()
validates start + nr <= UINT32_MAX before inserting entries. Add asserts
to document this invariant for static analyzers.

CID#1548015

Follow-up for 8530dc4467
2026-03-28 19:56:31 +00:00
Luca Boccassi c8b53fcfd3 sd-event: add assert to help static analysis trace signal bounds
Coverity flags the signal_sources array access as a potential
out-of-bounds read because it cannot trace through the SIGNAL_VALID()
macro to know that ssi_signo < _NSIG. Add an explicit assert after
the runtime check to make the constraint visible to static analyzers.

CID#1548033

Follow-up for 7a64c5f23e
2026-03-28 19:56:31 +00:00
Luca Boccassi be85048e28 cpu-set-util: add asserts to guide static analysis after realloc
Coverity flags CPU_SET_S() calls as potential out-of-bounds writes
because it cannot trace that cpu_set_realloc() guarantees the
allocated buffer is large enough for the given index. Add asserts
to make the size invariant explicit.

CID#1611787
CID#1611788

Follow-up for 0985c7c4e2
2026-03-28 19:56:31 +00:00
Luca Boccassi 1929226e7e debug-generator: use unsigned bit shift for breakpoint flags
Using signed int literal '1' in left shift can lead to undefined
behavior if the shift amount causes overflow of a signed int. Use
UINT32_C(1) since the result is stored in a uint32_t variable.

CID#1568482

Follow-up for e9f781a5a4
2026-03-28 19:56:31 +00:00
Luca Boccassi 86fd0337c6 scsi_id: use strscpy instead of strncpy for wwn fields
strncpy does not null-terminate the destination buffer if the source
string is longer than the count parameter. Since wwn and
wwn_vendor_extension are char[17] and we copy up to 16 bytes, there's
a risk of missing null termination. Use strscpy which always
null-terminates.

CID#1469706

Follow-up for 4e9fdfccbd
2026-03-28 19:56:31 +00:00
Luca Boccassi 3e889473c9 resolved: fix TOCTOU in hook discovery
Coverity complains that the directory is not pinned by FD
so it might changed between the stat and the open

CID#1643236

Follow-up for 8209f4adcd
2026-03-28 19:56:31 +00:00
Luca Boccassi bf37ed0a65 stat-util: add assert to silence coverity
Coverity thinks _mntidb can be used uninitialized, but this
is not the case when r == 0. Add a bool variable to make it
clearer instead of reusing 'r' later, and an assert to guide
static analyzers.

CID#1644850

Follow-up for 5817c73391
2026-03-28 19:56:31 +00:00
Luca Boccassi 8fe512a02e stat-util: fix return type of mode_verify_socket()
It returns an error code, not a mode

Follow-up for 97fe03e12f
2026-03-28 19:56:31 +00:00
Luca Boccassi 74a9ed911d pe-binary: add explicit cast to silence coverity
Otherwise it gets confused about underflows (which are already checked)

CID#1645068

Follow-up for a434270139
2026-03-28 19:56:31 +00:00
Luca Boccassi 1a0fe20bc2 pe-binary: fix error reporting
This is a local calculation, errno is not set

Follow-up for a434270139
2026-03-28 19:56:31 +00:00
Luca Boccassi 85b20f5fa7 boot: add overflow check in GPT parser
ALIGN_TO() can overflow and return SIZE_MAX

CID#1644887

Follow-up for ccbd324a3a
2026-03-28 19:56:31 +00:00
Luca Boccassi 9bdc8c8138 imdsd: voidify unchecked call
CID#1646046

Follow-up for eb6e5b07f1
2026-03-28 19:56:30 +00:00