]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 months agobuild(deps): bump the actions group with 3 updates
dependabot[bot] [Wed, 1 Apr 2026 10:53:51 +0000 (10:53 +0000)] 
build(deps): bump the actions group with 3 updates

Bumps the actions group with 3 updates: [actions/upload-artifact](https://github.com/actions/upload-artifact), [redhat-plumbers-in-action/download-artifact](https://github.com/redhat-plumbers-in-action/download-artifact) and [softprops/action-gh-release](https://github.com/softprops/action-gh-release).

Updates `actions/upload-artifact` from 6 to 7
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

Updates `redhat-plumbers-in-action/download-artifact` from 1.1.5 to 1.1.6
- [Release notes](https://github.com/redhat-plumbers-in-action/download-artifact/releases)
- [Commits](https://github.com/redhat-plumbers-in-action/download-artifact/compare/103e5f882470b59e9d71c80ecb2d0a0b91a7c43b...03d5b806a9dca9928eb5628833fe81a0558f23bb)

Updates `softprops/action-gh-release` from 2.5.0 to 2.6.1
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/a06a81a03ee405af7f2048a818ed3f03bbf83c7b...153bb8e04406b158c6c84fc1615b65b24149a1fe)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: redhat-plumbers-in-action/download-artifact
  dependency-version: 1.1.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: softprops/action-gh-release
  dependency-version: 2.6.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2 months agohmac: add comments explaining why each buffer needs erasing
Michal Rybecky [Wed, 1 Apr 2026 11:16:42 +0000 (13:16 +0200)] 
hmac: add comments explaining why each buffer needs erasing

As requested in review: clarify that the padding arrays carry
key material (key XOR fixed constant, trivially reversible),
not just padding bytes.

2 months agohmac: erase key-derived stack buffers before returning
Michal Rybecky [Wed, 1 Apr 2026 08:00:14 +0000 (10:00 +0200)] 
hmac: erase key-derived stack buffers before returning

hmac_sha256() leaves four stack buffers containing key-derived material
(inner_padding, outer_padding, replacement_key, hash state) on the stack
after returning. The inner_padding and outer_padding arrays contain
key XOR 0x36 and key XOR 0x5c respectively, which are trivially
reversible to recover the original HMAC key.

This function is called with security-sensitive keys including the LUKS
volume key (cryptsetup-util.c), TPM2 PIN (tpm2-util.c), and boot secret
(tpm2-swtpm.c). The key material persists on the stack until overwritten
by later unrelated function calls.

Add CLEANUP_ERASE() to all four local buffers, following the same
pattern applied to tpm2-util.c in commit 6c80ce6 (PR #41394).

2 months agoloop-util: work around kernel loop driver partition scan race
Daan De Meyer [Mon, 30 Mar 2026 08:43:38 +0000 (08:43 +0000)] 
loop-util: work around kernel loop driver partition scan race

The kernel loop driver has a race condition in LOOP_CONFIGURE when
LO_FLAGS_PARTSCAN is set: it sends a KOBJ_CHANGE uevent (with
GD_NEED_PART_SCAN set) before calling loop_reread_partitions(). If
udev opens the device in response to the uevent before
loop_reread_partitions() runs, the kernel's blkdev_get_whole() sees
GD_NEED_PART_SCAN and triggers a first partition scan. Then
loop_reread_partitions() runs a second scan that drops all partitions
from the first scan (via blk_drop_partitions()) before re-adding them.
This causes partition devices to briefly disappear (plugged -> dead ->
plugged), which breaks systemd units with BindsTo= on the partition
device: systemd observes the dead transition, fails the dependent
units with 'dependency', and does not retry when the device reappears.

Work around this in loop_device_make_internal() by splitting the loop
device setup into two steps: first LOOP_CONFIGURE without
LO_FLAGS_PARTSCAN, then LOOP_SET_STATUS64 to enable partscan. This
avoids the race because:

1. LOOP_CONFIGURE without partscan: disk_force_media_change() sets
   GD_NEED_PART_SCAN, but GD_SUPPRESS_PART_SCAN remains set. If udev
   opens the device, blkdev_get_whole() calls bdev_disk_changed()
   which clears GD_NEED_PART_SCAN, but blk_add_partitions() returns
   early because disk_has_partscan() is false — no partitions appear,
   the flag is drained harmlessly.

2. Between the two ioctls, we open and close the device to ensure
   GD_NEED_PART_SCAN is drained regardless of whether udev processed
   the uevent yet.

3. LOOP_SET_STATUS64 with LO_FLAGS_PARTSCAN: clears
   GD_SUPPRESS_PART_SCAN and calls loop_reread_partitions() for a
   single clean scan. Crucially, loop_set_status() does not call
   disk_force_media_change(), so GD_NEED_PART_SCAN is never set again.

A proper kernel fix has been submitted:
https://lore.kernel.org/linux-block/20260330081819.652890-1-daan@amutable.com/T/#u

This workaround should be dropped once the fix is widely available.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agonspawn: keep backing files for boot_id and kmsg bind mounts alive
Daan De Meyer [Tue, 10 Mar 2026 13:10:05 +0000 (14:10 +0100)] 
nspawn: keep backing files for boot_id and kmsg bind mounts alive

Both setup_boot_id() and setup_kmsg() previously created temporary files
in /run, bind mounted them over their respective /proc targets, and then
immediately unlinked the backing files. While the bind mount keeps the
inode alive, the kernel marks the dentry as deleted.

This is a problem because bind mounts backed by unlinked files cannot be
replicated: both the old mount API (mount(MS_BIND)) and the new mount
API (open_tree(OPEN_TREE_CLONE) + move_mount()) fail with ENOENT when
the source mount references a deleted dentry. This affects
mount_private_apivfs() in namespace.c, which needs to replicate these
submounts when setting up a fresh /proc instance for services with
ProtectProc= or similar sandboxing options — with an unlinked backing
file, the boot_id submount simply gets lost.

Fix this by using fixed paths (/run/proc-sys-kernel-random-boot-id and
/run/proc-kmsg) instead of randomized tempfiles, and not unlinking them
after the bind mount. The files live in /run which is cleaned up on
shutdown anyway.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 months agovarlinkctl: add protocol upgrade support using new SocketFoward (#41283)
Daan De Meyer [Wed, 1 Apr 2026 10:33:00 +0000 (12:33 +0200)] 
varlinkctl: add protocol upgrade support using new SocketFoward (#41283)

2 months agohwdb: Silence spurrious F23 key-press from Fn key on Thinkpad T14s
Tobias Heider [Wed, 1 Apr 2026 09:17:16 +0000 (11:17 +0200)] 
hwdb: Silence spurrious F23 key-press from Fn key on Thinkpad T14s

The Thinkpad T14s Gen 6 (Snapdragon) emits a F23 key press when
pressing the Fn key. Silence them since the keyboard doesn't
actually have a F23 key.

2 months agoci: Rework Claude review workflow to use CLI directly
Daan De Meyer [Tue, 31 Mar 2026 19:18:12 +0000 (21:18 +0200)] 
ci: Rework Claude review workflow to use CLI directly

Replace claude-code-action with a direct claude CLI invocation. This
gives us explicit control over settings, permissions, and output
handling.

Other changes:
- Prepare per-commit git worktrees with pre-generated commit.patch and
  commit-message.txt files, replacing the pr-review branch approach.
- Use structured JSON output (--output-format stream-json --json-schema)
  instead of having Claude write review-result.json directly.
- Use jq instead of python3 for JSON prettification.
- Add timeout-minutes: 60 to the review job.
- List tool permissions explicitly instead of using a wildcard.
- Fix sandbox filesystem paths to use regular paths instead of the "//"
  prefix.

2 months agoloop-util: use auto-detect open mode for loop device setup
Daan De Meyer [Mon, 30 Mar 2026 13:51:48 +0000 (13:51 +0000)] 
loop-util: use auto-detect open mode for loop device setup

When callers do not explicitly request read-only mode, pass open_flags
as -1 (auto-detect) instead of hardcoding O_RDWR. This enables the
existing O_RDWR-to-O_RDONLY retry logic in loop_device_make_by_path_at()
which falls back to O_RDONLY when opening the backing device with O_RDWR
fails with EROFS or similar errors.

Previously, callers passed O_RDWR explicitly when read-only mode was not
requested, which bypassed the retry logic entirely. This meant that
inherently read-only block devices (such as CD-ROMs) would fail to open
instead of gracefully falling back to read-only mode.

Also propagate the unresolved open_flags through
loop_device_make_by_path_at() into loop_device_make_internal() instead
of resolving it to O_RDWR early. For loop_device_make_by_path_memory(),
resolve to O_RDWR immediately since memfds are always writable.

In mstack, switch from loop_device_make() to
loop_device_make_by_path_at() with a NULL path, which reopens the
O_PATH file descriptor with the appropriate access mode. This is
necessary because the backing file descriptor is opened with O_PATH,
which prevents loop_device_make_internal() from auto-detecting the
access mode via fcntl(F_GETFL).

2 months agoshared: make dns_packet_read_uint{8,32} accept NULL ret 41426/head
Michael Vogt [Tue, 31 Mar 2026 15:40:03 +0000 (17:40 +0200)] 
shared: make dns_packet_read_uint{8,32} accept NULL ret

The shared/ dns_packet_read_uint*() functions used to be a bit
inconsistent when it comes to the handling of NULL in *ret. The
helpers dns_packet_read_{uint16,name} accepted NULL but the
dns_packet_read_uint{8,32} did not.

This commit makes them all symmetric in accepting NULL.

2 months agomany: use POINTER_MAY_BE_NULL in inner sort _cmp funcs
Michael Vogt [Sun, 29 Mar 2026 10:46:28 +0000 (12:46 +0200)] 
many: use POINTER_MAY_BE_NULL in inner sort _cmp funcs

Some functions are in the hot path of a sort. While it is more
correct to also use assert() here for the passed pointers it is
also a runtime cost that should never be needed when e.g. qsort()
is used as it will always pass non-NULL pointers.

So for these critical functions use POINTER_MAY_BE_NULL() which
is compiled out and add a comment to them. Not all _compare()
functions are changed, it was a bit of a judgement call because
some (like ether_addr_compare) are not called with that much data.

But happy to get advise here and tweak accordingly.

2 months agobasic: make check-pointer-deref clean
Michael Vogt [Sun, 29 Mar 2026 09:52:01 +0000 (11:52 +0200)] 
basic: make check-pointer-deref clean

Add the needed assert changes to make the code clean
for the new check-pointer-deref script.

Note that for `_cmp()` functions its a bit of a question
if we want `assert()` or `POINTER_MAY_BE_NULL()` here. The
former is more correct but it adds a (small) runtime hit. If
we use POINTER_MAY_BE_NULL() it is compiled out but strictly
speaking it is wrong (so at least we would need a comment).

2 months agoshared,sysext,analyze: remove unneeded if() for vars already guarded
Michael Vogt [Sat, 28 Mar 2026 21:39:03 +0000 (22:39 +0100)] 
shared,sysext,analyze: remove unneeded if() for vars already guarded

There are some unnecessary() if() checks for variables
that are already guarded by assert()s. Drop those.

Thanks to keszybz for clarifying the direction of this commit.

2 months agoshared: make check-pointer-deref clean
Michael Vogt [Sat, 28 Mar 2026 21:18:32 +0000 (22:18 +0100)] 
shared: make check-pointer-deref clean

Add the needed assert changes to make the code clean
for the new check-pointer-deref script.

2 months agolibsystemd: make check-pointer-deref clean
Michael Vogt [Sat, 28 Mar 2026 20:45:01 +0000 (21:45 +0100)] 
libsystemd: make check-pointer-deref clean

Add the needed assert changes to make the code clean
for the new check-pointer-deref script.

2 months agovarlink: tweak exec_with_listen_fds() log generation 41283/head
Michael Vogt [Thu, 26 Mar 2026 15:32:48 +0000 (16:32 +0100)] 
varlink: tweak exec_with_listen_fds() log generation

The previous code used strv_join() when it generated the log
message for `varlinkctl --exec`. However this can lead to
inaccurate logging so use `quote_command_line()` instead.

Thanks to Lennart for suggesting this.

2 months agovarlinkctl: add support for `--exec` with `--upgrade`
Michael Vogt [Tue, 24 Mar 2026 08:48:39 +0000 (09:48 +0100)] 
varlinkctl: add support for `--exec` with `--upgrade`

Having support for `--exec` when using `--upgrade` is nice so this
commit adds it. It does it by extracting a shared helper called
`exec_with_listen_fds()` and then use that in the `verb_call()`
and `varlink_call_and_upgrade()` calls.

2 months agovarlinkctl: add protocol upgrade support
Michael Vogt [Tue, 24 Mar 2026 08:48:33 +0000 (09:48 +0100)] 
varlinkctl: add protocol upgrade support

The varlink spec supports protocol upgrades and they are very
useful to e.g. transfer binary data directly via varlink. So
far varlinkctl/sd-varlink was not supporting this. This commit
adds support for it in varlinkctl by using the new code in
sd-varlink and the generalized socket-forward code.

2 months agoshared: rename internal variables in SimplexForwarder
Michael Vogt [Thu, 26 Mar 2026 15:51:39 +0000 (16:51 +0100)] 
shared: rename internal variables in SimplexForwarder

The SimplexForwader was using the naming of the SocketForwarder
for bi-directional sockets. This was to keep the diff small and
to make it easier to follow what changed and what was reused.

However the name "client/server" for the SimplexForwader does
no longer make much sense. The SimplexForwader is no longer
about client/server but really just read/write. So this commit
adjusts the naming.

2 months agoshared: extend socket-forward to support fd-pairs too
Michael Vogt [Tue, 24 Mar 2026 08:48:26 +0000 (09:48 +0100)] 
shared: extend socket-forward to support fd-pairs too

Now that the socket forward code is extracted we can
extend it to not just support bidirectional sockets
but also input/output fd-pairs. This will be needed
for e.g. the varlinkctl protocol upgrade support where
one side of the connection is a fd-pair (stdin/stdout).

This is done by creating two half-duplex forwarders
that operate independantly. This also allows to simplify
some state tracking, e.g. because each fd serves only one
direction we don't need to dynamically create the event mask
with EPOLLIN etc, its enough to set it once. It also handles
non-pollable FDs transparently.

Thanks to Lennart for his excellent suggestions here.

2 months agosd-varlink: add sd_varlink_call_and_upgrade() for protocol upgrades
Michael Vogt [Tue, 24 Mar 2026 08:48:20 +0000 (09:48 +0100)] 
sd-varlink: add sd_varlink_call_and_upgrade() for protocol upgrades

The varlink spec supports protocol upgrades and they are very
useful to e.g. transfer binary data directly via varlink. So
far sd-varlink was not supporting this.

This commit adds a new public sd_varlink_call_and_upgrade()
that sends a method call, waits for the reply, then steals
the connection fds for raw I/O. It returns separate input_fd
and output_fd to support both bidirectional sockets and pipe
pairs.

A helper is extracted and shared between sd_varlink_call_full()
and sd_varlink_call_and_upgrade(). A new `protocol_upgrade`
bool in `struct sd_varlink` ensures that on a protocol upgrade
request we only exactly read the varlink protocol bytes and
leave anything beyond that to the caller that speaks the upgraded
protocol.

Note that this is the client side of the library implementation
only for now. The server side needs work but this is already
useful as it allows to talk to varlink servers that speak protocol
upgrades (like the rust implemenations of varlink).

2 months agoterminal-util: fix boot hang from ANSI terminal size queries
Daan De Meyer [Sat, 28 Mar 2026 14:10:54 +0000 (14:10 +0000)] 
terminal-util: fix boot hang from ANSI terminal size queries

Since v257, terminal_fix_size() is called during early boot via
console_setup() → reset_dev_console_fd() to query terminal dimensions
via ANSI escape sequences. This has caused intermittent boot hangs
where the system gets stuck with a blinking cursor and requires a
keypress to continue (see systemd/systemd#35499).

The function tries CSI 18 first, then falls back to DSR if that fails.
Previously, each method independently opened a non-blocking fd, disabled
echo/icanon, ran its query, restored termios, and closed its fd. This
created two problems:

1. Echo window between CSI 18 and DSR fallback: After CSI 18 times out
   and restores termios (re-enabling ECHO and ICANON), there is a brief
   window before DSR disables them again. If the terminal's CSI 18
   response arrives during this window, it is echoed back to the
   terminal — where the terminal interprets \e[8;rows;cols t as a
   "resize text area" command — and the response bytes land in the
   canonical line buffer as stale input that can confuse the DSR
   response parser.

2. Cursor left at bottom-right on DSR timeout: The DSR method worked by
   sending two DSR queries — one to save the cursor position, then
   moving the cursor to (32766,32766) and sending another to read the
   clamped position. If neither response was received (timeout), the
   cursor restore was skipped (conditional on saved_row > 0), leaving
   the cursor at the bottom-right corner of the terminal. The
   subsequent terminal_reset_ansi_seq() then moved it to the beginning
   of the last line via \e[1G, making boot output appear at the bottom
   of the screen — giving the appearance of a hang even when the system
   was still booting.

This commit fixes both issues:

- terminal_fix_size() now opens the non-blocking fd and configures
  termios once for both query methods, so echo stays disabled for the
  entire CSI 18 → DSR fallback sequence with no gap. tcflush(TCIFLUSH)
  is called before each query to drain any stale input from the tty
  input queue.

- The DSR method now uses DECSC (\e7) / DECRC (\e8) to save and restore
  the cursor position via hardware, instead of querying it with a
  separate DSR round-trip. All four sequences (DECSC, CUP to
  bottom-right, DSR query, DECRC) are sent in a single write, so the
  terminal processes DECRC and restores the cursor regardless of whether
  userspace ever reads the DSR response. This eliminates the
  cursor-at-bottom-right artifact on timeout and simplifies the read
  loop to only need a single DSR response instead of two.

- The repeated setup boilerplate (dumb check, verify_same, fd_reopen,
  termios save/disable) is extracted into terminal_prepare_query(),
  shared by terminal_get_size_by_csi18(), terminal_get_size_by_dsr(),
  and terminal_fix_size().

Fixes: systemd/systemd#35499
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agoterminal-util: add CLEANUP_TERMIOS_RESET() for automatic termios restore
Daan De Meyer [Tue, 31 Mar 2026 07:55:18 +0000 (07:55 +0000)] 
terminal-util: add CLEANUP_TERMIOS_RESET() for automatic termios restore

Add TERMIOS_NULL sentinel, TermiosResetContext, and CLEANUP_TERMIOS_RESET()
macro (modeled after CLEANUP_ARRAY()) to automatically restore terminal
settings when leaving scope, replacing manual goto+tcsetattr patterns.

Migrate ask_string_full(), terminal_get_cursor_position(),
get_default_background_color(), terminal_get_terminfo_by_dcs(),
terminal_get_size_by_dsr() and terminal_get_size_by_csi18() to use the new
cleanup macro, removing the goto-based cleanup labels and replacing them
with direct returns.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agotest-terminal-util: migrate to new assertion macros
Daan De Meyer [Tue, 31 Mar 2026 09:39:21 +0000 (09:39 +0000)] 
test-terminal-util: migrate to new assertion macros

Replace assert_se() calls with the more descriptive ASSERT_OK(),
ASSERT_OK_ZERO(), ASSERT_OK_ERRNO(), ASSERT_OK_POSITIVE(),
ASSERT_OK_EQ_ERRNO(), ASSERT_FAIL(), ASSERT_TRUE(), ASSERT_FALSE(),
ASSERT_EQ(), ASSERT_LE(), and ASSERT_NOT_NULL() macros throughout the
test file.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agoman: fix typos in some binary names
Antonio Alvarez Feijoo [Tue, 31 Mar 2026 07:41:29 +0000 (09:41 +0200)] 
man: fix typos in some binary names

2 months agoRefactor the option & verb table handling and convert a few more programs (#41335)
Zbigniew Jędrzejewski-Szmek [Tue, 31 Mar 2026 08:17:26 +0000 (10:17 +0200)] 
Refactor the option & verb table handling and convert a few more programs (#41335)

After having some more experience with how this works, I think some
changes are in order. So there are a handful of preparatory patches and
then conversion of a few progs that make use of the new functionality.

2 months agoOnly enable `NoAuto=true` for supported partitions
Michael Ferrari [Fri, 27 Mar 2026 23:32:03 +0000 (00:32 +0100)] 
Only enable `NoAuto=true` for supported partitions

When `Format=empty` is set we need to check for `NoAuto` support for
the partition type, else we print a warning later in the build.

Followup for 381304a

2 months agocryptenroll: harden some variables with erasure on cleanup
Luca Boccassi [Fri, 27 Mar 2026 23:45:20 +0000 (23:45 +0000)] 
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

2 months agoMore assorted coverity fixes (#41413)
Daan De Meyer [Mon, 30 Mar 2026 21:34:44 +0000 (23:34 +0200)] 
More assorted coverity fixes (#41413)

2 months agosysupdate: Ignore resources that are not pending
Valentin David [Mon, 30 Mar 2026 07:49:13 +0000 (09:49 +0200)] 
sysupdate: Ignore resources that are not pending

`updatectl enable --now` systematically fails because the update phase find
resources that are not pending. So instead we should ignore them.

Fixes #41254

2 months agodiscover-image: Ignore sysupdate temporary files
Valentin David [Mon, 30 Mar 2026 07:54:38 +0000 (09:54 +0200)] 
discover-image: Ignore sysupdate temporary files

Sysupdate temporary file names do not match their extension-release names. So
they will always fail. That makes enabling any other sysexts/confexts fail
which has catastrophic consequences. Unfortunately since 260, sysupdate
leaves temporary files for long time instead just while downloading. So
this kind of failure now happens much more often.

2 months agosysupdated: Accept "current+pending" key
Valentin David [Mon, 30 Mar 2026 08:07:04 +0000 (10:07 +0200)] 
sysupdated: Accept "current+pending" key

Since 594d0345fa997446b4c2dcfbccf3f83257bb55a3 the key for
current version might be "current+pending". So in order not to fail
we need to accept it.

Fixes #41409

2 months agomany: another set of checks for pointer access without NULL check (#41400)
Zbigniew Jędrzejewski-Szmek [Mon, 30 Mar 2026 17:52:08 +0000 (19:52 +0200)] 
many: another set of checks for pointer access without NULL check (#41400)

Followup for https://github.com/systemd/systemd/pull/41370

Next set of pointer-deref coccinelle tweaks for:
''src/core/'
 'src/journal/'
 'src/network/'
''src/nspawn/'

2 months agonetwork-generator: support BOOTIF= and rd.bootif=0 options 41028/head
Nick Rosbrook [Tue, 24 Feb 2026 19:05:05 +0000 (14:05 -0500)] 
network-generator: support BOOTIF= and rd.bootif=0 options

The network generator currently supports many of the options described
by dracut.cmdline(7), but not everything.

This commit adds support for the BOOTIF= option (and the related
rd.bootif= option) used in PXE setups.

This is implemented by treating BOOTIF as a special name/placeholder
when used as an interface name, and expecting a MAC address to be set in
the BOOTIF= parameter. The resulting .network file then uses MACAddress=
in the [Match] section, instead of Name=.

2 months agoether-addr-util: introduce hw_addr_is_valid()
Nick Rosbrook [Thu, 19 Mar 2026 15:12:06 +0000 (11:12 -0400)] 
ether-addr-util: introduce hw_addr_is_valid()

Take this from udev, and adapt it to make it re-usable elsewhere.

2 months agocore: make check-pointer-deref clean 41400/head
Michael Vogt [Sat, 28 Mar 2026 11:35:54 +0000 (12:35 +0100)] 
core: make check-pointer-deref clean

Add the needed assert changes to make the code clean
for the new check-pointer-deref script.

2 months agojournald: add assert for allocated buffer size 41413/head
Luca Boccassi [Sat, 28 Mar 2026 22:46:35 +0000 (22:46 +0000)] 
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 ec20fe5ffb8a00469bab209fff6c069bb93c6db2

2 months agotest-json: avoid divide-by-zero coverity warning for index 9
Luca Boccassi [Sat, 28 Mar 2026 22:32:06 +0000 (22:32 +0000)] 
test-json: avoid divide-by-zero coverity warning for index 9

Same fix as d0a066a1a4a391f629f7f52b5005103f8daf411f did for
index 10: add iszero_safe() check before dividing by the
json variant real value.

CID#1587762

Follow-up for d0a066a1a4a391f629f7f52b5005103f8daf411f

2 months agoTODO: fix typos and restore dropped item 41375/head
Christian Brauner [Mon, 30 Mar 2026 11:51:07 +0000 (13:51 +0200)] 
TODO: fix typos and restore dropped item

- Fix "d-nspawn" → "systemd-nspawn" (prefix was incorrectly stripped
  when merging into the nspawn grouped section)
- Fix "LSFMMBPF" → "LSM BPF" (the original informal abbreviations
  "lsmbpf"/"lsmpbf" were incorrectly "corrected")
- Restore the dropped "portabled: similar" reference by folding it
  into the ConcurrencyHardMax=/ConcurrencySoftMax= item

Signed-off-by: Christian Brauner <brauner@kernel.org>
2 months agonetwork: make check-pointer-deref clean
Michael Vogt [Sat, 28 Mar 2026 11:02:32 +0000 (12:02 +0100)] 
network: make check-pointer-deref clean

Add the needed assert changes to make the code clean
for the new check-pointer-deref script.

2 months agojournal: make check-pointer-deref clean
Michael Vogt [Sat, 28 Mar 2026 09:48:27 +0000 (10:48 +0100)] 
journal: make check-pointer-deref clean

Add the needed assert changes to make the code clean
for the new check-pointer-deref script.

2 months agonspawn: make check-pointer-deref clean
Michael Vogt [Sat, 28 Mar 2026 09:24:18 +0000 (10:24 +0100)] 
nspawn: make check-pointer-deref clean

Add the needed assert changes to make the code clean
for the new check-pointer-deref script.

2 months agocleanup: address review feedback from claude
Michael Vogt [Sat, 28 Mar 2026 08:46:33 +0000 (09:46 +0100)] 
cleanup: address review feedback from claude

Trivial ordering/modernizing change that got highlighted by
claude and refined by keszybz to move to the modern systemd
style.

Thanks to keszybz for suggesting this.

2 months agomkosi: add coccinelle to the debian tools tree too
Michael Vogt [Sat, 28 Mar 2026 08:36:32 +0000 (09:36 +0100)] 
mkosi: add coccinelle to the debian tools tree too

It is already part of the fedora/opensues tools tree. It must
have slipped through for Debian so lets add it.

2 months agonspawn-oci: add asserts for UID/GID validity after dispatch
Luca Boccassi [Sat, 28 Mar 2026 22:15:56 +0000 (22:15 +0000)] 
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 91c4d1affdba02a323dc2c7caccabe240ccb8302

2 months agoboot: clamp setup header copy size to sizeof(SetupHeader)
Luca Boccassi [Sat, 28 Mar 2026 22:06:51 +0000 (22:06 +0000)] 
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 d62c1777568ff69034fd5b5d582a2889229f7e20

2 months agocreds-util: add assert for output buffer size overflow safety
Luca Boccassi [Sat, 28 Mar 2026 22:00:25 +0000 (22:00 +0000)] 
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 21bc0b6fa1de44b520353b935bf14160f9f70591

2 months agocalendarspec: use ADD_SAFE for repeat offset calculation
Luca Boccassi [Sat, 28 Mar 2026 21:56:41 +0000 (21:56 +0000)] 
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 a2eb5ea79c53620cfcf616e83bfac0c431247f86

2 months agorepart: use INC_SAFE for partition min size accumulation
Luca Boccassi [Sat, 28 Mar 2026 21:52:57 +0000 (21:52 +0000)] 
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 170c98234530af6af487d37057b6e687569f8f91

2 months agotest-strv: avoid unsigned wraparound in backwards iteration
Luca Boccassi [Sat, 28 Mar 2026 21:47:08 +0000 (21:47 +0000)] 
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 02f19706a9fd96e05c9ed16aa55ba3d03d008167

2 months agosd-bus: add assert_cc for message allocation size
Luca Boccassi [Sat, 28 Mar 2026 21:41:02 +0000 (21:41 +0000)] 
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 de1c301ed165eb4d04a0c9d4babe97912b5233bb

2 months agosd-bus: use usec_add() for auth timeout calculation
Luca Boccassi [Sat, 28 Mar 2026 21:37:47 +0000 (21:37 +0000)] 
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 e3017af97310da024ffb378ed155bc1676922ce7

2 months agonss-myhostname: add asserts for buffer index accumulation
Luca Boccassi [Sat, 28 Mar 2026 21:29:58 +0000 (21:29 +0000)] 
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 e8a7a315391a6a07897122725cd707f4e9ce63d7

2 months agotree-wide: add assert_cc for time constant multiplications
Luca Boccassi [Sat, 28 Mar 2026 21:28:56 +0000 (21:28 +0000)] 
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 500727c220354b81b68ed6667d9a6f0fafe3ba19
Follow-up for 27d340c772fb1b251085dba7bd5420484f7c5892
Follow-up for e537352b9bfffe6f6286483bff2c7601c78407e3
Follow-up for 1007ec60e664da03b7aea4803c643d991fcf6530

2 months agorepart: add assert for offset + current_size overflow safety
Luca Boccassi [Sat, 28 Mar 2026 21:20:39 +0000 (21:20 +0000)] 
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 e594a3b154bd06c535a934a1cc7231b1ef76df73

2 months agonetworkd-ndisc: add assert for DNSSL allocation overflow safety
Luca Boccassi [Sat, 28 Mar 2026 21:19:14 +0000 (21:19 +0000)] 
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 1e7a0e21c97ac1bbc743009e5ec8c12bc6200e19

2 months agodns-packet: add asserts for allocation overflow safety
Luca Boccassi [Sat, 28 Mar 2026 21:14:35 +0000 (21:14 +0000)] 
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 c73ce96b569e2f10dff64b7dc0bd271972674c2a

2 months agolimits-util: add assert for physical memory calculation overflow
Luca Boccassi [Sat, 28 Mar 2026 21:14:07 +0000 (21:14 +0000)] 
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 eefc66aa8f77c96a13a78d6c40c79ed7f3d6dc9d

2 months agouser-util: add asserts for buffer allocation overflow safety
Luca Boccassi [Sat, 28 Mar 2026 21:12:31 +0000 (21:12 +0000)] 
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 75673cd8aee5c6174538e71dd36c7a353c836973

2 months agosd-bus: add asserts for message size overflow safety
Luca Boccassi [Sat, 28 Mar 2026 21:11:48 +0000 (21:11 +0000)] 
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 6629161f827c82889cf45cfcdce62dcb543eda23

2 months agosd-daemon: add assert before CMSG_SPACE subtraction
Luca Boccassi [Sat, 28 Mar 2026 21:03:14 +0000 (21:03 +0000)] 
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 64144440a5d2d94482f882b992fd2a4e0dca7a05

2 months agosd-json: silence false positive in sd_json_variant_filter
Luca Boccassi [Sat, 28 Mar 2026 21:01:34 +0000 (21:01 +0000)] 
sd-json: silence false positive in sd_json_variant_filter

Same pattern as the fix for sd_json_variant_unset_field in
9b3715d529e4eba79e19c87e85583f7be5ee2c95: cache the element
count in a local variable and assert it is at least 2 before
subtracting.

CID#1548029

Follow-up for f2ff34ff2aaafd313a5c62b4b9f13ba6777731e5

2 months agojournal: add assert for max_size overflow safety
Luca Boccassi [Sat, 28 Mar 2026 20:59:35 +0000 (20:59 +0000)] 
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 8580d1f73db36e9383e674e388b4fb55828c0c66

2 months agoTODO: add frontmatter and improve formatting
Christian Brauner [Fri, 27 Mar 2026 12:51:53 +0000 (13:51 +0100)] 
TODO: add frontmatter and improve formatting

Add YAML frontmatter matching the style of other docs in the tree.
Bold grouped section topic names to make them visually distinct
from standalone items. Escape angle-bracket placeholders so GitHub
does not swallow them as HTML.

Signed-off-by: Christian Brauner <brauner@kernel.org>
2 months agoTODO: add symlink to TODO.md
Christian Brauner [Fri, 27 Mar 2026 12:46:59 +0000 (13:46 +0100)] 
TODO: add symlink to TODO.md

Signed-off-by: Christian Brauner <brauner@kernel.org>
2 months agoTODO: convert to markdown
Christian Brauner [Fri, 27 Mar 2026 12:46:38 +0000 (13:46 +0100)] 
TODO: convert to markdown

Rename TODO to TODO.md and convert to proper markdown format:
section headers become ## headings and bullet items use - instead
of *.

Signed-off-by: Christian Brauner <brauner@kernel.org>
2 months agoTODO: sort Features entries alphabetically
Christian Brauner [Fri, 27 Mar 2026 12:41:43 +0000 (13:41 +0100)] 
TODO: sort Features entries alphabetically

Signed-off-by: Christian Brauner <brauner@kernel.org>
2 months agoTODO: merge scattered items into their grouped sections
Christian Brauner [Fri, 27 Mar 2026 12:33:44 +0000 (13:33 +0100)] 
TODO: merge scattered items into their grouped sections

Items about the same topic were spread across the file as separate
bullet points instead of being collected under a single heading.
Consolidate them so each topic appears in one place. Compound
items that span multiple topics (e.g. cryptsetup/homed) are left
as standalone entries.

Signed-off-by: Christian Brauner <brauner@kernel.org>
2 months agoTODO: fix formatting inconsistencies
Christian Brauner [Fri, 27 Mar 2026 12:13:18 +0000 (13:13 +0100)] 
TODO: fix formatting inconsistencies

Normalize section header capitalization, add missing colons to
sub-topic headers, replace bullet character variants with dashes,
and fix sub-item indentation to use two spaces consistently.

Signed-off-by: Christian Brauner <brauner@kernel.org>
2 months agoman: fix caps in example path
Adam Dinwoodie [Wed, 11 Mar 2026 23:04:44 +0000 (23:04 +0000)] 
man: fix caps in example path

2 months agonetworkd: Add docs and tests for IPv4SrcValidMark= 41364/head
ssahani [Fri, 27 Mar 2026 03:49:49 +0000 (09:19 +0530)] 
networkd: Add docs and tests for IPv4SrcValidMark=
Document the new setting in systemd.network(5) man page
and add coverage in the networkd integration tests.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agorepart: allow --el-torito= with any --empty= value
Daan De Meyer [Sun, 29 Mar 2026 21:11:52 +0000 (21:11 +0000)] 
repart: allow --el-torito= with any --empty= value

The restriction requiring --empty= to be require, force, or create
when using --el-torito= is unnecessary.
context_verify_eltorito_overlap() already validates that the ISO 9660
blocks don't collide with GPT partition entries or the first usable
LBA, which is sufficient to guarantee safety regardless of the empty
mode.

This is needed for two-stage image builds where the first stage creates
the usr and verity partitions, and the second stage adds --el-torito=
to produce a bootable ISO with a UKI containing usrhash= derived from
the verity hash of the first stage. In the second stage, repart runs
with --empty=allow since the image already exists.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2 months agorepart: Optionally write minimal an El Torito boot catalog for EFI
Valentin David [Sat, 21 Mar 2026 14:42:13 +0000 (15:42 +0100)] 
repart: Optionally write minimal an El Torito boot catalog for EFI

This only points the firmware to the ESP. The ISO9660 is empty.
The initramfs should create a loop device to change block size
and enable GPT partitions.

This was tested using OVMF on qemu, with:
`-drive if=pflash,file=OVMF_CODE.fd,readonly=on,format=raw -drive if=pflash,file=OVMF_VARS.fd,format=raw -drive if=none,id=live-disk,file=dick.iso,media=cdrom,format=raw,readonly=on -device virtio-scsi-pci,id=scsi -device scsi-cd,drive=live-disk`

And a simple definition:
```
[Partition]
Type=esp
Format=vfat
CopyFiles=/usr/lib/systemd/boot/efi/systemd-bootx64.efi:/EFI/BOOT/BOOTX64.EFI
```

2 months agoAssorted coverity fixes (#41406)
Daan De Meyer [Sun, 29 Mar 2026 19:02:55 +0000 (21:02 +0200)] 
Assorted coverity fixes (#41406)

2 months agosd-varlink: export sd_varlink_set_sentinel
Zbigniew Jędrzejewski-Szmek [Sat, 28 Mar 2026 15:54:21 +0000 (16:54 +0100)] 
sd-varlink: export sd_varlink_set_sentinel

I tried to implement a varlink service using sd-varlink, and
not being able to use the approach with sentinel is exteremely
painful. This is useful internally and likewise externally.

2 months ago`systemd-repart` man page fixes (#41410)
Luca Boccassi [Sun, 29 Mar 2026 12:58:04 +0000 (13:58 +0100)] 
`systemd-repart` man page fixes (#41410)

Found two small issues in the man page.

2 months agoman/systemd-repart: quote jq expression 41410/head
Morten Linderud [Sun, 29 Mar 2026 12:20:28 +0000 (14:20 +0200)] 
man/systemd-repart: quote jq expression

Some shells will try to parse this, or expand it, causing an error. Lets
quote it so it's simpler for people.

Signed-off-by: Morten Linderud <morten@linderud.pw>
2 months agoman/systemd-repart: remove extra pipe character in manpage
Morten Linderud [Sun, 29 Mar 2026 12:15:05 +0000 (14:15 +0200)] 
man/systemd-repart: remove extra pipe character in manpage

Signed-off-by: Morten Linderud <morten@linderud.pw>
2 months agorepart: Make it possible to set persistent allow-discards activation flag
Valentin David [Mon, 16 Mar 2026 21:21:55 +0000 (22:21 +0100)] 
repart: Make it possible to set persistent allow-discards activation flag

AllowDiscards= will set allow-discards in the persistent flags which will make
activating the device automatically activate with that option. This is
useful for devices discovered through gpt-auto-generator without
needing to use some kernel command line to set the option.

2 months agofix list of inhibitor lock types
Adrian Wannenmacher [Sat, 28 Mar 2026 19:55:19 +0000 (20:55 +0100)] 
fix list of inhibitor lock types

Markdown and HTML don't support mixing ordered and unordered items
within a single list. This means the previous syntax actually produced
three separate lists.

Also, markdown converters don't necesarrily respect the first number in
an ordered list, and may just overwrite it to one. This is the case for
the one that generates the systemd.io page. And even if that wasn't the
case, the numbering of the second ordered list would be off by one.

2 months agorecurse-dir: add assert_cc for DIRENT_SIZE_MAX allocation 41406/head
Luca Boccassi [Sat, 28 Mar 2026 20:24:22 +0000 (20:24 +0000)] 
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 6393b847f459dba14d2b615ee93babb143168b57

2 months agoexec-util: use unsigned shift for ExecCommandFlags
Luca Boccassi [Sat, 28 Mar 2026 20:13:40 +0000 (20:13 +0000)] 
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 b3d593673c5b8b0b7d781fd26ab2062ca6e7dbdb

2 months agocompress: add assert for space doubling overflow safety
Luca Boccassi [Sat, 28 Mar 2026 20:13:03 +0000 (20:13 +0000)] 
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 5e592c66bdf76dfc8445b332f7a5088ca504ee90

2 months agoimportd: add assert for log_message_size accumulation bounds
Luca Boccassi [Sat, 28 Mar 2026 20:10:14 +0000 (20:10 +0000)] 
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 3d7415f43f0fe6a821d7bc4a341ba371e8a30ef3

2 months agosd-bus: add asserts for rbuffer_size accumulation bounds
Luca Boccassi [Sat, 28 Mar 2026 20:08:55 +0000 (20:08 +0000)] 
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 a7e3212d89d5aefee67de79c1e7eaccf2f5645ac

2 months agouid-range: add asserts to document overflow safety in coalesce
Luca Boccassi [Sat, 28 Mar 2026 19:55:35 +0000 (19:55 +0000)] 
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 8530dc4467691a893aa2e07319b18a84fec96cad

2 months agosd-event: add assert to help static analysis trace signal bounds
Luca Boccassi [Sat, 28 Mar 2026 19:52:09 +0000 (19:52 +0000)] 
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 7a64c5f23efbb51fe4f1229c1a8aed6dd858a0a9

2 months agocpu-set-util: add asserts to guide static analysis after realloc
Luca Boccassi [Sat, 28 Mar 2026 19:49:20 +0000 (19:49 +0000)] 
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 0985c7c4e22c8dbbea4398cf3453da45ebf63800

2 months agodebug-generator: use unsigned bit shift for breakpoint flags
Luca Boccassi [Sat, 28 Mar 2026 19:47:27 +0000 (19:47 +0000)] 
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 e9f781a5a4721d3e58798b37e30bb4dcdbe54c02

2 months agoscsi_id: use strscpy instead of strncpy for wwn fields
Luca Boccassi [Sat, 28 Mar 2026 19:35:36 +0000 (19:35 +0000)] 
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 4e9fdfccbdd16f0cfdb5c8fa8484a8ba0f2e69d3

2 months agoresolved: fix TOCTOU in hook discovery
Luca Boccassi [Sat, 28 Mar 2026 19:05:19 +0000 (19:05 +0000)] 
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 8209f4adcde08d225f56269e608ccd5f6704cd70

2 months agostat-util: add assert to silence coverity
Luca Boccassi [Sat, 28 Mar 2026 18:55:37 +0000 (18:55 +0000)] 
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 5817c73391b5f3599c50df2c0873b26ea426f848

2 months agostat-util: fix return type of mode_verify_socket()
Luca Boccassi [Sat, 28 Mar 2026 18:50:49 +0000 (18:50 +0000)] 
stat-util: fix return type of mode_verify_socket()

It returns an error code, not a mode

Follow-up for 97fe03e12faa4e50d25a3ca8999967801c7e2da9

2 months agope-binary: add explicit cast to silence coverity
Luca Boccassi [Sat, 28 Mar 2026 18:45:52 +0000 (18:45 +0000)] 
pe-binary: add explicit cast to silence coverity

Otherwise it gets confused about underflows (which are already checked)

CID#1645068

Follow-up for a43427013949c6593629f551cf46e9cf9c167100

2 months agope-binary: fix error reporting
Luca Boccassi [Sat, 28 Mar 2026 18:35:09 +0000 (18:35 +0000)] 
pe-binary: fix error reporting

This is a local calculation, errno is not set

Follow-up for a43427013949c6593629f551cf46e9cf9c167100

2 months agoboot: add overflow check in GPT parser
Luca Boccassi [Sat, 28 Mar 2026 18:29:28 +0000 (18:29 +0000)] 
boot: add overflow check in GPT parser

ALIGN_TO() can overflow and return SIZE_MAX

CID#1644887

Follow-up for ccbd324a3a522362de0863e8d06cdd06a58d2fca

2 months agoimdsd: voidify unchecked call
Luca Boccassi [Sat, 28 Mar 2026 17:56:51 +0000 (17:56 +0000)] 
imdsd: voidify unchecked call

CID#1646046

Follow-up for eb6e5b07f13cefddf1f49e1f7bda4af22f5aba17

2 months agodissect: add asserts to appease coverity
Luca Boccassi [Sat, 28 Mar 2026 15:37:53 +0000 (15:37 +0000)] 
dissect: add asserts to appease coverity

CID#1645844
CID#1645845

Follow-up for 91578e529395a0299a1e5eaa6da08e73db6eeacd

2 months agotest: add a mock ModemManager for basic coverage of sd-networkd's integration 41402/head
Luca Boccassi [Sat, 28 Mar 2026 14:40:11 +0000 (14:40 +0000)] 
test: add a mock ModemManager for basic coverage of sd-networkd's integration

Just the minimal setup and test case required to cover
https://github.com/systemd/systemd/issues/41389 for now, can be
expanded in the future

Boring boilerplate is bot-made, don't @ me

Co-developed-by: Claude Opus 4.6 noreply@anthropic.com
2 months agonetworkd: fix assert with IPFamily=both in MobileNetwork conf
Luca Boccassi [Sat, 28 Mar 2026 14:47:25 +0000 (14:47 +0000)] 
networkd: fix assert with IPFamily=both in MobileNetwork conf

Fixes https://github.com/systemd/systemd/issues/41389

Follow-up for f8a4c3d375b83f3ee249ca3f4b7f407b618a9491