Commit Graph
58409 Commits
Author SHA1 Message Date
Lennart Poettering ac8266c7c2 tpm2-setup: make NV index space exhaustion issues more discoverable
Let's log about this explicitly, and include a message catalog entry for
it.
2026-02-26 11:34:59 +01:00
Lennart Poettering a01912ef29 tpm2-util: fix log level of one log call 2026-02-26 11:34:59 +01:00
Zbigniew Jędrzejewski-Szmek 13167bfc2f core/socket: fix reversed symlink direction in error message
After the update to 260-rc1 in Fedora Rawhide, we get a lot of messages like
this:
  systemd[1]: systemd-resolved-monitor.socket:
  Failed to create symlink /run/systemd/resolve/io.systemd.Resolve.Monitor →
  /run/varlink/registry/io.systemd.Resolve.Monitor, ignoring: Permission denied

The actual issue will need to be fixed too, but let's fix the message first.
While at it, let's rename the variables to be meaningful.
2026-02-26 11:34:22 +01:00
Zbigniew Jędrzejewski-Szmek 8a2b2828cc test-qr-code: allow specifying the text to encode 2026-02-26 09:20:59 +01:00
Yu Watanabe 2900f04c82 network: do not create state file for removed interface
Fixes #40817.
2026-02-26 08:50:50 +01:00
Zbigniew Jędrzejewski-Szmek e9abcd9b26 rpm/systemd-update-helper: use 'enqueue-marked-jobs'
Without this, a warning is emitted on upgrades.
Follow-up for c008f88ded.
2026-02-25 23:03:14 +00:00
Luca Boccassi eaac6fb1e0 boot: import Snapdragon device hwid json files, install them and use them from ukify (#40541)
The json files were originally generated for Ubuntu stubble and are kown
to work since they ship in all Ubuntu arm64 ISOs by default.

Some of the devices might not be supported in mainline Linux yet and use
preliminary compatible strings.
2026-02-25 15:46:30 +00:00
Zbigniew Jędrzejewski-Szmek 35c404de9b Upgrade /tmp when PrivateTmp=yes/DefaultDeps=no to disconnected (#39790) 2026-02-25 16:14:13 +01:00
Zbigniew Jędrzejewski-Szmek 04897fbbee bootctl: override is_efi_boot() check by --variables= option (#40413)
Fixes #40392.
2026-02-25 15:42:53 +01:00
Luca Boccassi 117ec9db7e ukify: default --hwids to /usr/lib/systemd/boot/hwids/<EFI_ARCH>/
If the option is not manually specified, and the hwids directory exists
for the target EFI architecture, default to it. Allow passing '' to skip.

Fixes https://github.com/systemd/systemd/issues/40542
2026-02-25 13:51:31 +00:00
Luca Boccassi 68aef1be15 Install hwids in /usr/lib/systemd/boot/hwids/<EFI_ARCH>/
These are meant to ship with ukify, in the same package,
so install them when ukify is enabled. Given they are
hardware-specific, use a per-arch subdirectory to make it
easier to enable them by default in ukify.
2026-02-25 13:51:31 +00:00
Tobias Heider d6332fa367 boot: import Snapdragon device hwid json files
Add hwids json files for Snapdragon devices that use of this
feature since they don't ship with devie trees embedded in firmware.
The json files were originally generated for Ubuntu stubble and
are kown to work since they ship in all Ubuntu arm64 ISOs by default.

Some of the devices might not be supported in mainline Linux yet
and use preliminary compatible strings.
2026-02-25 13:51:31 +00:00
Luca Boccassi 6d20cac84c test: move test hwids to separate subdirectory
Will allow installing the actual hwids as a single subdir
2026-02-25 13:51:31 +00:00
Daan De Meyer 101f03bedb Additions to nsresourced and vmspawn required for making use of the foreign UID range in mkosi (#40415) 2026-02-25 13:49:19 +01:00
Mike Yuan 2b67122cdf core/namespace: clean up append_private_tmp() a bit
With the previous changes the modes for /tmp/ and /var/tmp/
may come in arbitrary directions, i.e. we may downgrade one
and upgrade another. Hence let's refactor the setup logic
a bit so they're truly independent.
2026-02-25 12:38:12 +01:00
Zbigniew Jędrzejewski-Szmek 0a17bb5c34 core: simplify requirements in unit_get_private_var_tmp() to just After=
As in the previous commit, checking for both requirements and ordering seems
unnecessary. In practical cases, the mount will be pulled in by the rest
of the transaction, so ordering is the part that matters. (The setup is
racy without the ordering.)  If we drop the second check, the admin can
just use After=tmp.mount to achieve the desired behaviour, without needing
to explicitly pull in the unit. This is easier to configure and more robust.

This changes the implementation introduced in
6156bec7a4.

Also actually describe the implemented behaviour in the man page.
2026-02-25 12:38:11 +01:00
Zbigniew Jędrzejewski-Szmek fa33eef344 core: upgrade /tmp when PrivateTmp=yes/DefaultDeps=no to disconnected
In https://github.com/systemd/systemd/issues/28515, multiple people report that
services that have PrivateTmp=yes and DefaultDependencies=no fail to create the
temporary directories under /tmp, when /tmp is e.g. a bind mount or some other
kind of mount that takes more time.

Before PrivateTmp=disconnected was added, we didn't have a nice solution:
DefaultDependencies=no is used to start services very early, so we wouldn't
want to add a dependency on /tmp automatically. With PrivateTmp=disconnected we
have a fairly nice solution. Let's "upgrade" to this mode automatically.
Strictly speaking, it is a small compat break, but in practice it's unlikely to
matter for early-boot services whether their /tmp is private or disconnected.

The dependency on /tmp that is checked is After. I think this is enough,
since any tmp.mount would be pulled in by local-fs.target and the rest of
the transaction anyway, so we don't need to check more than After.

The asserts are relaxed, because now the two settings can now diverge
in either way.

Resolves https://github.com/systemd/systemd/issues/28515.

[yhndnzj: fix unit_add_exec_dependencies() to handle the new
          combination; add a comment in exec_needs_sys_admin()]
2026-02-25 12:38:11 +01:00
Mike Yuan 9984a35d65 core/execute: stop looking at ExecSharedRuntime to determine PrivateTmp= state
The only reason why ExecSharedRuntime.(var_)tmp_dir might
be suppressed is when (/var)/tmp/ is listed in InaccessiblePaths=,
in which case mount namespace is needed anyways. Moreover,
the current logic imposes a chicken-and-egg problem:
at various places in pid1 we'd need to check whether
the unit runs in a mountns, but the ExecSharedRuntime
may not be allocated for it just yet.
2026-02-25 12:38:11 +01:00
Mike Yuan 0d10a125f6 core/execute: make exec_shared_runtime_make() handle distinct PrivateTmp= modes properly 2026-02-25 12:38:11 +01:00
Mike Yuan e438e5923d core/namespace: two fixes for namespace_cleanup_tmpdir()
* Make sure we're not passing NULL to rmdir()
* Remove the inner "tmp" subdir as well, so that callers
  can handle this transparently (e.g. exec_shared_runtime_make()
  is not aware of the nested rmdir() requirements)

While at it, remove unneeded PROTECT_ERRNO.
2026-02-25 12:38:11 +01:00
Mike Yuan a45fb074fe core/namespace: rename() might return ENOTEMPTY if target dir exists 2026-02-25 12:36:45 +01:00
Mike Yuan 2e71d0a2bd core/unit: refuse UserNamespacePath= + PrivateUsers=
Such setup makes zero sense, as if we unshare userns ourselves
we'd immediately lose CAP_SYS_ADMIN over the userns specified.
2026-02-25 12:36:44 +01:00
Mike Yuan 457bd2345c core/execute: do not suppress ExecSharedRuntime if userns path is specified
Follow-up for 79dd24cf14
2026-02-25 12:36:44 +01:00
Zbigniew Jędrzejewski-Szmek 92a0761d55 core/exec-invoke: add missing char in comment 2026-02-25 12:36:44 +01:00
Nick Rosbrook 7a1888954c seccomp-util: add lsm_get_self_attr and lsm_list_modules to @default
These syscalls are part of a newer kernel API to replace interaction
with /proc/self/attr, with the goal of allowing LSM stacking. These are
being used now by e.g. libapparmor, so should be more easily available
to services using seccomp filtering.
2026-02-25 11:35:54 +01:00
Daan De Meyer 3363693935 nspawn: Add support for delegated UID ranges
We expose this via --private-users-delegate= which takes the number of
ranges to delegate. On top of delegating the ranges, we also mount in
the nsresourced socket and the mountfsd socket so that nested containers
can use nsresourced to allocate from the delegated ranges and mountfsd to
mount images.

Finally, we also create /run/systemd/dissect-root with systemd-tmpfiles to
make sure it is always available as unpriv users won't be able to create it
themselves.
2026-02-25 11:31:06 +01:00
Daan De Meyer fd05c6c759 vmspawn: Add support for foreign UID range owned directories 2026-02-25 11:31:04 +01:00
Luca Boccassi 1012c6ce76 userdbd: avoid sending gshadow hash to unprivileged callers via varlink
Reported on yeswehack as YWH-PGM9780-59

Follow-up for d093b62c94
2026-02-25 02:52:37 +01:00
Mike Yuan 3c47dc76be systemctl-start-unit: drop redundant check for enqueue-marked-jobs --wait
Follow-up for c008f88ded

The check at the beginning of the function already covers this.
2026-02-25 05:09:38 +09:00
Luca Boccassi a851c5118b test: avoid hanging forever waiting for udev if not a booted system
test_sd_device_enumerator_filter_subsystem hangs forever in OBS builds,
as it waits for the udev queue to be drained. But this is not a booted
system, with systemd and udev, so nothing will do that.
Skip the test in that case.
2026-02-25 04:53:20 +09:00
Daan De Meyer e4f72956b6 network: several follow-ups for new varlink methods (#40808) 2026-02-24 19:59:01 +01:00
Luca Boccassi 882cf2d943 core: check selinux/polkit access on varlink SetProperty
Reported on yeswehack.com as:
YWH-PGM9780-92

Follow-up for 0e1c4de235
2026-02-24 18:54:44 +00:00
Luca Boccassi c556a2ad15 tree-wide: a small number of small fixlets all over the place (#40797) 2026-02-24 18:53:17 +00:00
Daan De Meyer 104579e401 dissect: Go via service on ENOENT from loop_device_make() as well
ENOENT means /dev/loop-control isn't there which means we're in a
container and should go via mountfsd.

At the same time, reverse the check for fatal actions as almost all
actions can be done via mountfsd, only --attach needs the loop device.
2026-02-24 18:29:37 +01:00
Daan De Meyer 4bc0d8a9a1 mountfsd: Relax user namespace checks
- Allow foreign UID range
- Allow delegated UID ranges

Both of these can now be mapped by nsresourced into user namespaces
and hence should be accepted by mountfsd.
2026-02-24 18:29:37 +01:00
Daan De Meyer 838528104b nsresourced: Optionally map foreign UID range
Whenever delegating UID ranges to a user namespace, it can also be
useful to map the foreign UID range, so that the container running in
the user namespace with delegated UID ranges can download container
images and unpack them to the foreign UID range.

Let's add an option mapForeign to make this possible. Note that this option
gives unprivileged users full access to the any foreign UID range owned directory
that they can access. Hence it is recommended (and already was recommended) to
store foreign UID range owned directories in a 0700 directory owned by the
owner of the tree to avoid access and modifications by other users.

This is already the case for the main users of the foreign UID range,
namely /var/lib/machines, /var/lib/portables and /home/<user> which all
use 0700 as their mode.

Users will also be able to create foreign UID range owned inodes in any
directories their own user can write to (on most systems this means /tmp,
/var/tmp and /home/<user>).
2026-02-24 18:29:37 +01:00
Daan De Meyer 95d05079bf nsresourced: Add support for self mappings with delegations
mkosi does all of its environment setup in an unprivileged user
namespace with an identity mapping. When it invokes nspawn and nspawn
tries to get a transient userns from nsresourced, this fails as no
transient ranges are mapped into mkosi's unprivileged userns (as doing
so would require privileges).

To fix this problem, let's allow allocating unprivileged self user
namespaces in nsresourced, similar to what the kernel allows, except that
we also support delegations for these. This means that mkosi can get its
unprivileged userns as before from nsresourced, but it can also request a
delegated 64K range inside that userns as well, which nsresourced can then
allocate to nspawn later when it asks for one.

Similar to the kernel, we disallow setgroups for self mappings. However,
instead of doing this via /proc/self/setgroups, which applies to the current
user namespace and all its child user namespaces, we use the BPF LSM to deny
setgroups instead, so that it can still be allowed for child user namespaces.
We need this because as soon as a container launches in a child user namespace
using one of the delegated mappings, it has to be able to do setgroups() to be
able to function properly.

To allow mapping the root user, we need to add the CAP_SETFCAP capability to
nsresourced.
2026-02-24 18:29:37 +01:00
Daan De Meyer 025439faaa nsresourced: Add support for delegated ranges
We want to support the scenario where we bind mount the nsresourced
varlink socket into a container to allow nested containers where the
outer container runs in its own transient range from nsresourced but
can still allocate transient ranges for its own nested containers.

To support this use case let's add support for delegation. Delegated
ranges are allocated when allocating the primary range and are propagated
1:1 to the user namespace. We track delegated ranges in ".delegate" files
in the userns registry so that they can't be used for other range allocations.

We make one exception for delegated ranges though, if we get a request from
a user namespace that is a child of the user namespace that owns the delegated
ranges, we allow allocating from the delegated range. The parent userns already
has full ownership over the child userns, so it doesn't matter that the parent
userns and the child userns share the same range. This allows making use of
delegated ranges without having to run another copy of nsresourced inside the
parent userns to hand out from the delegated range.

To support recursive delegations, we keep track of the previous owners of the
delegated range and restore ownership to the last previous owner when the current
owner is freed.
2026-02-24 18:29:37 +01:00
Daan De Meyer 6c2d437585 nsresourced: Allow operations outside transient UID/GID ranges
The purpose of the userns-restrict BPF-LSM program is to prevent the
transient ranges leaking to disk, so let's allow operations outside the
transient UID ranges, even if the mount is not allowlisted.

This is preparation for the next commits where we'll add support for mapping
the current user and the foreign UID range into the user namespaces provisioned
by nsresourced. Operations creating files/directories as these UIDs/GIDs should
not need the corresponding mount to be allowlisted with nsresourced.
2026-02-24 18:29:37 +01:00
Mike Yuan 21fd534ae8 systemctl: introduce enqueue-marked-jobs verb (#40810) 2026-02-24 18:08:22 +01:00
Antonio Alvarez Feijoo 8ea1ae25ab import/pull-oci: fix several OOM checks
Follow-up for a9f6ba0496
2026-02-24 17:34:09 +01:00
Lennart Poettering 3601697b2d analyzer: remove spurious empty line 2026-02-24 17:11:54 +01:00
Lennart Poettering a69dffbf4f sd-varlink: add a bit of debug logging indicating when exit-on-idle triggers 2026-02-24 17:11:54 +01:00
Lennart Poettering a0276f6e12 sd-varlink: use correct error variable 2026-02-24 17:09:33 +01:00
Lennart Poettering 332ecf40f2 sd-netlink: pin reply slot while we execute callback
The callback might drop the last ref to the slot object, and we still
want to access it. Hence do what we usually do in these cases: keep an
extra reference while processing the callback.
2026-02-24 17:09:33 +01:00
Mike Yuan c008f88ded systemctl: introduce enqueue-marked-jobs verb, stop lumping it with distinct verbs 2026-02-24 16:00:05 +01:00
Yu Watanabe da7374b2ae varlink-idl: allow to pass polkit arguments to io.systemd.service.Reload()
Then, varlink interfaces with unprivileged access can be implement the
method.
2026-02-24 23:59:08 +09:00
Yu Watanabe 27f1bf5cde network: rename dispatch_interface() and make it take flags
No functional change. Just refactoring and preparation for later change.
2026-02-24 23:57:15 +09:00
Yu Watanabe b6919c737a network: rename io.systemd.Network.LinkUp()/LinkDown()
Then, this also moves their implementations to networkd-link-varlink.c.
2026-02-24 23:56:20 +09:00
Mike Yuan a8ceed0000 Revert "systemctl: allow --marker with start/stop too"
This reverts commit 351b4dd123.

I'm pretty sure we should not create more of these multiplexer
interfaces, which in this specific also leads to a fair bit of
confusion: start/stop/reload-or-restart --marked all enqueue
all job types.

Instead, a dedicated verb will be introduced in later commits.
2026-02-24 15:48:53 +01:00