Commit Graph
88410 Commits
Author SHA1 Message Date
Samuel Dainard 3f2189ca25 binfmt-util: handle ELOOP/EACCES from automount in read-only bind mounts
When /proc is bind-mounted read-only (common in mock/Koji buildroots,
containers, and other sandboxed environments), opening
/proc/sys/fs/binfmt_misc returns ELOOP if it is an automount point
that cannot be triggered in the read-only context.

Currently binfmt_mounted_and_writable() only handles ENOENT, so ELOOP
propagates as an error. This causes test-binfmt-util to fail with
SIGABRT and disable_binfmt() to log a spurious warning at shutdown.

Treat ELOOP and EACCES the same as ENOENT: binfmt_misc is not usably
available, return false.

Note: PR #37006 (merged April 2025) addressed ELOOP in the xstatfsat()
path, but the open() call in binfmt_mounted_and_writable() remained
unhandled.

Fixes #38070
2026-04-29 21:39:24 +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
Christian Brauner 994f016a7f blockdev-list: fix per-element leak in block_device_array_free() (#41869)
FOREACH_ARRAY declares 'i' as the iterator but the body passed 'd' (the
array base) to block_device_done(). Since mfree() leaves the field NULL
after the first call, element 0 is freed repeatedly while elements
1..N-1 leak their node, symlinks strv, model, vendor and subsystem.

The bug predates the sanitizer-instrumented callers. PR #41776's new
systemd-storage-block daemon runs blockdev_list() under ASan/LSan in
TEST-87-AUX-UTILS-VM and exposes it (15 allocs / 804 bytes leaked per
ListVolumes request). The fix also benefits repart and blockdev_list's
internal CLEANUP_ARRAY cleanup.

Follow-up for 9f6b2745ea
2026-04-29 17:28:16 +01:00
Zbigniew Jędrzejewski-Szmek a234840e3e Convert remaining udev progs to option macros (#41856) 2026-04-29 17:23:18 +02:00
Zbigniew Jędrzejewski-Szmek 61811433bb follow-up for recently merged PRs (#41870)
Just small stuff.
2026-04-29 16:41:35 +02:00
Frantisek Sumsal 82614a4c6f sd-json,user-record: store the strv size when extending it
So strv_push_with_size() doesn't have to recalculate the size every
time.
2026-04-29 16:33:46 +02:00
Lennart Poettering fd035af9bf update TODO
This is mostly stuff discussed in #41776.
2026-04-29 16:06:03 +02:00
Lennart Poettering 32a291abe9 sd-boot: minor tweaks as follow-up for #41863
This addresses some trivial points made by @keszybz in the PR review.
2026-04-29 15:53:21 +02:00
Lennart Poettering e4e3ec811a volume: add an "io.systemd.StorageProvider" IPC API that is supposed to be used by vmspawn/nspawn/pid1 to provide storage volumes in a generic fashion (#41776)
BindPath= in unit files, and --bind= in nspawn/vmspawn doesn't really
cut it to connect arbitrary storage infra to it. Let's do something
about it, and implement a simple, light-weight API for acquiring an fd
to a storage volume. Benefits:

1. the interface can be implemented by anyone, connecting anything to
vmspawn/nspawn/service management
2. very lose coupling: just bind a socket into a well-known dir, done
3. mounting can happen on-demand
2026-04-29 15:51:52 +02:00
Zbigniew Jędrzejewski-Szmek 13f6feda78 udevadm: convert verb dispatch to VERB macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 15:28:05 +02:00
Zbigniew Jędrzejewski-Szmek fcfd42a30c udev-builtin-hwdb: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 15:28:05 +02:00
Zbigniew Jędrzejewski-Szmek ab9acf8c8c shared/options: add new helper option_parser_get_arg
option_parser_next_arg() is renamed to option_parser_peek_next_arg()
to match option_parser_consume_next_arg().

A new helper is added option_parser_get_arg(…, n). It is a common pattern
to only need a single arg, and getting an array and extracting a single
item from it is too verbose.
2026-04-29 15:28:05 +02:00
Zbigniew Jędrzejewski-Szmek 53f7c1a8cc sd-boot related work from #41543 (add "extra" stanza to bls type 1) (#41863)
This implements the "extra" stanza for type 1 entries in systemd-boot,
see:


https://github.com/uapi-group/specifications/commit/bde167a46c866c44e1240120695f70f0bf70aadc

It comes with a really thorough test suite matching our currently level
of testing of systemd-boot (read: there is none, I ask you to trust me,
Claude, and your review on this one)...

Split out of #41543
2026-04-29 15:25:38 +02:00
Zbigniew Jędrzejewski-Szmek a79c4fdf93 Small cleanups in sd-varlink and sd-json (#41861) 2026-04-29 15:03:00 +02:00
Zbigniew Jędrzejewski-Szmek 6c7726193e sd-bus: store the strv size when extending it (#41864)
So strv_push_with_size() doesn't have to recalculate the size every
time.
2026-04-29 15:01:12 +02:00
Zbigniew Jędrzejewski-Szmek 408d18f4d2 udev-builtin-blkid: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek c86ba4e037 udevadm-info: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 222b417494 udevadm-trigger: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 5656636a41 udevadm-wait: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 0257deff36 udevadm-control: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek a00de0b648 udevadm-lock: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek ed2b92e205 udevadm-settle: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 5a2144f9bc udevadm-monitor: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek a517a6297e udevadm-test: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 12e5e0e903 udevadm-verify: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 5751647799 udevadm-test-builtin: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek ce4746f228 udevadm-hwdb: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 5893cf3dcf udev: convert udev-config.c to OPTION macros
--timeout-signal is now documented (fixup for
e209926778).

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek bfc07f83da udev: fix stale optarg use
Fixup for 8623980980. This didn't
cause any problems until the conversion away from getopt_long().
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 765fc4125b shared/options: add OPTION_COMMON_RESOLVE_NAMES 2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 07fc22cd03 udevadm-cat: convert to OPTION macros 2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek c2c9887852 udevadm: convert option parsing to the new option parser
Verb dispatch is left untouched for now.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek fb0143f1ce shared/options: add option_parser_get_help_table_ns() helper
It'll be used in the next commit.
2026-04-29 14:00:41 +02:00
Lennart Poettering 6b1324fb86 man: add a brief note about type 1 extra lines 2026-04-29 13:36:56 +02:00
Lennart Poettering a3d0e761d4 boot: downgrade log level for an error we ignore 2026-04-29 13:36:56 +02:00
Lennart Poettering d5572aca2c boot: load extra files for UKIs into memory and register as initrds
This generates on-the-fly cpio initrds from 'extra' resources declared
in Type #1 entries and installs them via the Linux initrd protocol so
that they get passed to the Linux kernel.

Replaces: #39286
2026-04-29 13:36:56 +02:00
Lennart Poettering feba5dcc5f boot: parse 'extra' type 1 stanza too
This loads the new 'extra' stanza, but doesn't actually do anything with
it yet. That's added in a later commit.

Replaces: #39286

Implements: https://github.com/uapi-group/specifications/pull/212
2026-04-29 13:36:56 +02:00
Lennart Poettering c3ace5621b cpio: move TPM PCR info into CpioTarget
The PR to measure into is closely associated with where we place a
resource in the initrd cpios. Hence, let's also track it in CpioTarget,
thus simplifying our function parameter lists that way.

No change in behaviour.
2026-04-29 13:36:47 +02:00
Frantisek Sumsal 51a88ac723 core: limit the number of units that can be requested over ListUnitsByNames 2026-04-29 12:58:58 +02:00
Frantisek Sumsal 0d71d58da0 sd-bus: store the strv size when extending it
So strv_push_with_size() doesn't have to recalculate the size every
time.
2026-04-29 12:58:22 +02:00
Lennart Poettering eccfd2c97b TODO: track StorageProvider follow-ups, sketch a NetworkProvider sibling
Records the still-missing StorageProvider integrations (nspawn,
vmspawn, service-manager BindVolume=) and replaces the now-obsolete
generic "storage API via varlink" entry with a NetworkProvider
proposal modelled on it.
2026-04-29 12:26:52 +02:00
Lennart Poettering 804bf405d9 test: add integration test for storagectl and storage providers
VM-only test that exercises both shipped providers through storagectl:
verifies the well-known sockets exist, lists providers/volumes/
templates, creates and acquires volumes from each template
(sparse-file, allocated-file, directory, subvolume), attaches a loop
device to cover the block provider, and exercises the mount.storage
helper.
2026-04-29 12:26:52 +02:00
Lennart Poettering 4002a7e8be storage: add 'storagectl' command-line tool
CLI for inspecting and using storage providers. Scans
/run/systemd/io.systemd.StorageProvider/ (or the user-mode equivalent)
for AF_UNIX sockets and talks to each one over Varlink. Verbs:
"volumes" lists volumes across all providers, "templates" lists
supported creation templates, "providers" lists the endpoints
themselves.

Also installed as a mount.storage helper, so
'mount -t storage PROVIDER:VOLUME /mnt' (or 'mount -t storage.<fstype>'
to put a fresh filesystem on a block volume) acquires the volume and
mounts it. Ships with bash/zsh completions and a man page.
2026-04-29 12:25:47 +02:00
Lennart Poettering 9825195c25 storage: add systemd-storage-fs@.service provider
Second StorageProvider implementation, exposing regular files and
directories from a backing filesystem. In system mode the backing
directory is /var/lib/storage/, in user mode $XDG_STATE_HOME/storage/;
entries with a .volume suffix are exposed, with the inode type
determining whether the volume is reported as reg, dir or (via
symlinked/bind-mounted device node) blk.

Unlike the block provider, this one supports creating volumes
on-demand from a small set of built-in templates: sparse-file,
allocated-file, directory and subvolume.
2026-04-29 12:25:47 +02:00
Lennart Poettering 4fd0df2a4b storage: add systemd-storage-block@.service provider
First implementation of io.systemd.StorageProvider, exposing all block
devices known to udev (disks, partitions, dm nodes, …) as volumes of
type "blk". Names are picked from stable /dev/mapper and /dev/disk/by-*
symlinks; content-derived identifiers (by-uuid, by-label, …) are
intentionally avoided for security. Volume creation is not supported by
this backend.

Socket-activated via /run/systemd/io.systemd.StorageProvider/block.
Also adds shared storage-util.[ch] (VolumeType / CreateMode helpers)
that subsequent providers reuse.
2026-04-29 12:25:47 +02:00
Lennart Poettering 087fa20166 shared: add io.systemd.StorageProvider Varlink interface
Generic Varlink API for services that hand out file descriptors to
storage volumes. Three methods: Acquire() returns an fd for a named
volume (optionally creating it from a template), ListVolumes()
enumerates available volumes, ListTemplates() enumerates supported
creation templates. Volume types follow kernel inode-type naming:
blk (block device), reg (regular file), dir (directory).

Intent is that multiple providers can sit behind AF_UNIX sockets in a
well-known directory and be consumed uniformly by nspawn, vmspawn,
the service manager (BindVolume=) and similar tools.
2026-04-29 12:25:46 +02:00
Daan De Meyer 5948ff5fe2 libsystemd: Clean up meson.build
Merge the two blocks adding tests, since there seems to be
no obvious reason to have two separate blocks, as they both
contain tests from the same libraries.
2026-04-29 12:03:21 +02:00
Zbigniew Jędrzejewski-Szmek d9e0883316 sd-json: stop printing debug messages about extension fields
The intent was good, but we now print two or three of those messages
for each report metrics received on the wire. If the json object is
extensible, then it's all good and we don't need to inundate the user
with this trivial information. (And the message also sounds like
something is wrong or unexpected, when it totally isn't.)

...
(string):1:73: Unrecognized object field 'object', assuming extension.
(string):1:89: Unrecognized object field 'value', assuming extension.
json-stream: Received message: {"parameters":{"name":"io.systemd.Network.CarrierState","object":"virbr0","value":"degraded-carrier"},"continues":true}
(string):1:66: Unrecognized object field 'object', assuming extension.
(string):1:83: Unrecognized object field 'value', assuming extension.
json-stream: Received message: {"parameters":{"name":"io.systemd.Network.CarrierState","object":"lo","value":"carrier"},"continues":true}
(string):1:66: Unrecognized object field 'object', assuming extension.
(string):1:79: Unrecognized object field 'value', assuming extension.
json-stream: Received message: {"parameters":{"name":"io.systemd.Network.CarrierState","object":"wlp0s20f3","value":"carrier"},"continues":true}
(string):1:66: Unrecognized object field 'object', assuming extension.
(string):1:86: Unrecognized object field 'value', assuming extension.
...
2026-04-29 11:24:03 +02:00
Zbigniew Jędrzejewski-Szmek 242fca7516 sd-varlink: reduce size of varlink structs
struct sd_varlink:
- /* size: 448, cachelines: 7, members: 21 */
+ /* size: 432, cachelines: 7, members: 21 */

struct sd_varlink_server:
- /* size: 160, cachelines: 3, members: 21 */
+ /* size: 152, cachelines: 3, members: 21 */
2026-04-29 11:23:02 +02:00
Zbigniew Jędrzejewski-Szmek 01bf2b9f52 sd-varlink: drop pointless bitfield
As is often the case, in this case because of alignment, we are actually
not saving any space. With the bitfield we are using one bit of the 8 bytes
allocated, and without the bitfield we are using 8 bits of that.

But we're paying a price in generated code, at every access site to the
field:

$ diff <(objdump -S build/libsystemd.so.old) <(objdump -S build/libsystemd.so.new)
...
       v->protocol_upgrade = false;
-   fa2d2:	48 8b 45 a8          	mov    -0x58(%rbp),%rax
-   fa2d6:	0f b6 90 90 01 00 00 	movzbl 0x190(%rax),%edx
-   fa2dd:	83 e2 fe             	and    $0xfffffffe,%edx
-   fa2e0:	88 90 90 01 00 00    	mov    %dl,0x190(%rax)
+   fa2a9:	48 8b 45 a8          	mov    -0x58(%rbp),%rax
+   fa2ad:	c6 80 90 01 00 00 00 	movb   $0x0,0x190(%rax)
2026-04-29 11:23:01 +02:00