Commit Graph
50070 Commits
Author SHA1 Message Date
msizanoen 09928421ea core/cgroup: Properly handle aborting a pending freeze operation
We must thaw the cgroup even if cgroup.events/frozen=0 if a freeze
operation is in flight as it means the cgroup is already partially
frozen.

Fixes #37590.
Fixes #38337.

(cherry picked from commit 85d00912c0)
(cherry picked from commit 4bf37df99c)
2025-07-29 13:08:03 +02:00
Mike Yuan 71e09b0a4f core/unit: introduce unit_set_freezer_state, make logging consistent
Also, emit PropertiesChanged signal for FreezerState too.

Fixes #31115

(cherry picked from commit 0064290a54)
2025-07-29 13:08:03 +02:00
Mike Yuan 63703510d9 core/cgroup: skip freezer action wholly if current == objective
(cherry picked from commit a9dc196179)
2025-07-29 13:08:03 +02:00
Mike Yuan 90753f7fb0 core/cgroup: replace hardcoded state set with freezer_state_finish()
This makes code simpler and more readable.

(cherry picked from commit 27344f9acf)
2025-07-29 13:08:03 +02:00
Mike Yuan 29d2e9c8fa core/unit: rename freezer "target" to "objective"
(cherry picked from commit f27f461b01)
2025-07-29 13:08:03 +02:00
Mike Yuan ee9d32dfcb core/cgroup: check CGroupRuntime.cgroup_path rather than _realized for freezer
The same check is used everywhere else.

(cherry picked from commit c97c79aded)
2025-07-29 13:08:03 +02:00
Yu Watanabe d7a119080e network/dhcp6: consider the DHCPv6 protocol as finished when conflict addresses exist
Replaces #37891.

(cherry picked from commit 4c4fe8cd71)
(cherry picked from commit b53f734a65)
2025-06-25 18:17:42 +01:00
Yu Watanabe 644e40e5a7 network/dhcp6: refactoring for verify_dhcp6_address()
No functional change. Preparation for later changes.

(cherry picked from commit 03f0658460)
(cherry picked from commit 97d34af160)
2025-06-25 18:17:42 +01:00
Lennart Poettering c2d343b920 bootctl: be more careful when opening arbitrary files from ESP
Let's refuse all kind of weird stuff early.

As suggested here: https://github.com/systemd/systemd/pull/30418#pullrequestreview-2128220792

(cherry picked from commit 95df8288c7)
(cherry picked from commit 5b68d2a003)
2025-06-25 18:17:42 +01:00
Lennart Poettering af6273bc34 core: escape UTF-8 in mount unit Where field before sending to clients
Followup for: 4804da5853 #27541

Fixes: #36206
(cherry picked from commit 222b0b05ce)
(cherry picked from commit 72db7dfd27)
2025-06-25 18:17:42 +01:00
Yu Watanabe 01f34bf5df core: introduce Unit.dependency_generation counter and restart loop when dependency is updated in the loop
When starting unit A, a dependent unit B may be loaded if it is not
loaded yet, and the dependencies in unit A may be updated.
As Hashmap does not allow a new entry to be added in a loop, we need to
restart loop in such case.

Fixes a bug introduced by cda667722c.
Fixes #36031.

(cherry picked from commit b7777d0884)
(cherry picked from commit 4dc4fdcfe0)
2025-06-25 18:17:42 +01:00
Yu Watanabe 7dfa163cec core/transaction: do not override unit load state when unit_load() failed
When unit_load() failed for some reasons, previously we overrided the
load state with UNIT_NOT_FOUND, but we did not update the
Unit.fragment_not_found_timestamp_hash. So, the unit may be loaded
multiple times when the unit is in a dependency list of another unit,
as manager_unit_cache_should_retry_load() will be true again even on
next call.
Let's not override the unit state set by unit_load().

Note, after unit_load(), the unit state should not be UNIT_STUB.
Let's also add the assertion about that.

This change is important when combined with the next commit, as with the
next commit we will restart the FOREACH_UNIT_DEPENDENCY() loop if an unit
is reloaded, hence overriding load state with UNIT_NOT_FOUND may cause
infinit loop.

(cherry picked from commit 9b6aa9e443)
(cherry picked from commit 0e5fc0a29c)
2025-06-25 18:17:42 +01:00
Yu Watanabe cca17f069b core/transaction: drop redundant call of bus_unit_validate_load_state()
The function manager_unit_cache_should_retry_load() reutrns true only
when the unit state is UNIT_NOT_FOUND. Hence, it is not necessary to
call bus_unit_validate_load_state() before checking
manager_unit_cache_should_retry_load().

(cherry picked from commit 7ad2e66080)
(cherry picked from commit 915ffa770f)
2025-06-25 18:17:42 +01:00
Yu Watanabe ef1657c7db core/transaction: fix comment
(cherry picked from commit fe51a61477)
(cherry picked from commit e35d83a706)
2025-06-25 18:17:42 +01:00
Yu Watanabe c41a1c28c6 core/transaction: rename ret -> job
(cherry picked from commit fc49b2994d)
(cherry picked from commit 7468208872)
2025-06-25 18:17:42 +01:00
Daan De Meyer 9c4507645b home: Make sure we resolve /etc/skel symlink
Otherwise copy_tree_at() will try to copy the symlink which we obviously
don't want.

(cherry picked from commit 1e0e7c7411)
(cherry picked from commit 2a918e2a97)
2025-06-25 18:17:42 +01:00
Lennart Poettering f6eaadce92 bootspec: ensure memory free in one error path
(cherry picked from commit 1bd9a3c916)
(cherry picked from commit 56d2cd6456)
2025-06-25 18:17:42 +01:00
Lennart Poettering 5b3ab2f8a6 console: when switching console modes and one doesn't work, always go for the next
So far we already had a logic in place to go for the next mode if some
mode doesn't work – but it was only applied if we'd actively cycle
through resolutions.

Let's extend the logic and always apply it: whenever we try to switch to
a mode, and it doesn't work, go to the next one until we find one that
works.

Fixes: #37324
(cherry picked from commit b53c3af3fe)
(cherry picked from commit 66235376a4)
2025-06-25 18:17:42 +01:00
Luca Boccassi bd71224be1 homed: do not log new password when debug logs are enabled
systemd-homed[3443]: Sending to worker:
{
  "enforcePasswordPolicy": false,
  "userName": "foobarbaz",
  "perMachine": [
    {
      "storage": "directory",
      "matchMachineId": "c1082742b92c4f7e8d30d6b17f9d3351"
    }
  ],
  "disposition": "regular",
  "lastChangeUSec": 1750606709833174,
  "lastPasswordChangeUSec": 1750606709833174,
  "privileged": {
    "hashedPassword": [
      "$y$j9T$ai2Fshq0ev9W05WL4SoRJ1$EFfe41ACrJKXMCQ83A05n6UW.HrRr9/O4b1x0CXgAXD"
    ]
  },
  "binding": {
    "c1082742b92c4f7e8d30d6b17f9d3351": {
      "blobDirectory": "/var/cache/systemd/home/foobarbaz",
      "uid": 60056,
      "gid": 60056
    }
  },
  "secret": {
    "password": [
      "test"
    ]
  },
  "__systemd_homework_internal_blob_fdmap": {}
}

(cherry picked from commit e248790263)
(cherry picked from commit a283e832da)
2025-06-25 18:17:42 +01:00
George Tsiamasiotis 807e18536a resolved: Tweak link-local addresses relevancy
We now consider link-local addresses routable when we have configured
unicast link-local dns servers. This allows creating the DNS scope, even
when the interface doesn't get a routable address.

(cherry picked from commit c60d2a626b)
(cherry picked from commit bd9a51fc67)
2025-06-25 18:17:42 +01:00
Luca Boccassi 69beb94574 fstab-generator: set mode=0755 with root=tmpfs
If mode= is not set in rootflags= add mode=0755 when a tmpfs
is used on the rootfs, otherwise it will be group/world writable
as that's the default mode for tmpfs filesystems.

Follow-up for 725ad3b062

(cherry picked from commit d3a57a0853)
(cherry picked from commit 0e8f13faf3)
2025-06-25 18:17:42 +01:00
Yu Watanabe e2130b03d1 manager: also restart stub listner on reload
Previously, the extra stub listners were stopped but new ones were not
started. Also, the main stub listners were not restarted, hence the
new settings were not applied. This fixes the above two issues.

Note, to fix the issue, we need to keep CAP_NET_BIND_SERVICE capability
to make it allow to bind stub listner later.

Fixes #37843.

(cherry picked from commit 752cdf5051)
(cherry picked from commit c2eda0d71b)
2025-06-25 18:17:42 +01:00
Yu Watanabe 579b59ac1d resolve: exit from loop for transactions when transactions has been regenerated
Fixes #37458.

(cherry picked from commit 5814acca9a)
(cherry picked from commit e40fbaa18e)
2025-06-25 18:17:42 +01:00
Luca Boccassi 1613414ac0 socket: downgrade not-supported logging for SO_PASSSEC
Kernel 6.16 started returning EOPNOTSUPP when a required kconfig
is disabled. Downgrade to debug level in that case.

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

(cherry picked from commit bb887cf22e)
(cherry picked from commit 42cc499197)
2025-06-25 18:17:42 +01:00
Lennart Poettering 65c9fbe944 resolvectl: improve error message if we do not support dumping payload of RR
(cherry picked from commit 231a0417cd)
(cherry picked from commit 9df7a197c2)
2025-06-25 18:17:42 +01:00
Lennart Poettering 1171445778 resolvectl: output slightly more data when --raw=payload is used
Let's also show A/AAAA data in binary form if --raw=payload is used. For
these RR types there's only a single data field, hence it's obbviously
meant.

Inspired by: #37737

(cherry picked from commit 141894f53a)
(cherry picked from commit 8a78ab58cc)
2025-06-25 18:17:42 +01:00
Sam Leonard ab830a1d55 vmspawn: fix call to GetUnitByPID
This commit also adds a handler for SIGRTMIN+4 which is another signal
used to shutdown systemd.

(cherry picked from commit 305e58936f)
(cherry picked from commit 6af05bbf29)
2025-06-25 18:17:42 +01:00
Lennart Poettering a332cc7f6a io-util: protect against INT_MAX overflow in flush_fd()
(cherry picked from commit 874c4beb24)
(cherry picked from commit 93fc50ec2b)
2025-06-25 18:17:42 +01:00
Lennart Poettering b5d7d32d65 resolved: honour SD_RESOLVED_NO_CNAME flag when processing cache
Fixes: #33300
Replaces: #35102
(cherry picked from commit 959d7f1759)
(cherry picked from commit 8f1b7ec9ed)
2025-06-25 18:17:42 +01:00
Lennart Poettering 1e3b674b77 compress: avoid a bunch of div-by-zeroes
Follow-up for #37706. Implements the same logic for all compression
algorithms we have.

(cherry picked from commit d483ac1d0d)
(cherry picked from commit f3b35c3e93)
2025-06-25 18:17:42 +01:00
Yu Watanabe ee9434f702 repart: if partition already exists, required size may not be multiple of grain size
See partition_min_size_with_padding().
Fixes #37178.

(cherry picked from commit cb109e00c4)
(cherry picked from commit 4e6d6d885d)
2025-06-25 18:17:42 +01:00
Arian van Putten 4fa8890c8e vmspawn: do not preserve access permissions and xattrs of template OVMF vars
This makes vmspawn work when /usr/share/qemu/edk2-i386-vars.fd is on
disk with 0444 permissions as is the case on NixOS.

The nix package manager does not store any access permissions, ownership,
timestamps, or extended attributes in its package format to increase
reproducibility. The only meta-data that is stored is the executable bit.

Thus when unpacking a nix package, the executable bit is preserved, but no other
access permissions are preserved and all files in /nix/store end up as
read-only.

This causes the template OVMF vars file to have 0444 permissions. If we preserve
those permissions when copying the template file to /tmp that means QEMU can not
write to the file and fails.

So lets not preserve permissions and keep the 0600 permissions that are set by
default.

(cherry picked from commit 96e481bfbd)
(cherry picked from commit e9c4962cef)
2025-06-25 18:17:42 +01:00
Alex eaffe6679b compress: prevent divide-by-zero when no data is read (#37706)
If the first call to `loop_read()` returns 0 (no input), `total_in`
remains 0, causing `total_out/total_in` to potential divide by zero.

We add a check before logging the compression ratio to skip the
percentage calculation when total_in is zero.

Co-authored-by: jinyaoguo <guo846@purdue.edu>
(cherry picked from commit 2584f745e0)
(cherry picked from commit 18a42e321d)
2025-06-25 18:17:42 +01:00
Alex 64206ad137 network: fix a potential divide-by-zero (#37705)
In function `tc_init`, hz is parsed from the content of file
`"/proc/net/psched"` and can be 0.
In function `hierarchy_token_bucket_class_verify`, hz is directly used
as a divisor in
`htb->buffer = htb->rate / hz + htb->mtu;` without any check. This adds a check on hz before using it as a divisor.

Co-authored-by: jinyaoguo <guo846@purdue.edu>
(cherry picked from commit 1a596054a0)
(cherry picked from commit e2c9fdd5c0)
2025-06-25 18:17:42 +01:00
Lennart Poettering 199ca6f474 repart: fix generation of UUID= line for vfat in fstab entries
Fixes: #36735
(cherry picked from commit 8504721e0e)
(cherry picked from commit ddddef495d)
2025-06-25 18:17:42 +01:00
Joaquim Monteiro 7ac7b91ae0 bootctl: fix unclosed quote in debug log
(cherry picked from commit c9e614eb25)
(cherry picked from commit 4af9f5044a)
2025-06-25 18:17:42 +01:00
Lennart Poettering e715fab755 mount-util: avoid unnecessary mount_setattr() call in make_fsmount()
If .attr_set is zero (and .att_clr, .propagation too), then there's no
point in calling mount_setattr().

Fixes: #37062

Note that this optimization is not precisely load-bearing anymore, since
3cc23a2c23 got merged which removes the
only caller of make_fsmount() that might trigger it. But it's worth
fixing generic code anyway, in case it gets used like this later again.

(cherry picked from commit 249752d1ec)
(cherry picked from commit 77babb252d)
2025-06-25 18:17:42 +01:00
Luca Boccassi 8d7dce9a53 sysupdate: change status once operation has completed
Otherwise after the service exits it will still show
"Installing 'foobar'" as the status, which is confusing

(cherry picked from commit 5cfc9c34f4)
(cherry picked from commit 0e502d986b)
2025-06-25 18:17:42 +01:00
Mike Yuan e4a6a58d20 ssh-generator: add missing newline before [Service] and trailing NL to generated service
(cherry picked from commit e72bd8dbc8)
(cherry picked from commit 654c60ba17)
2025-06-25 18:17:42 +01:00
Mike Yuan 4e71330bc4 ssh-generator: fix typo
(cherry picked from commit 0aa4c3f0f9)
(cherry picked from commit 2fc4bc803c)
2025-06-25 18:17:42 +01:00
Yu Watanabe 018e874b84 network/link: update state file when master ifindex is changed
If master ifindex is non-zero, then the carrier state and operational
state of the interface may be the enslaved state.
As the operational state is saved in link state file, and read by
wait-online, we need to update the state file when the master ifindex is
changed.

(cherry picked from commit 7dde00ca57)
(cherry picked from commit e9655c7865)
2025-06-25 18:17:42 +01:00
Yu Watanabe c584dfb205 network/link: ENODATA from reading IFLA_MASTER when an interface has no master
When an interface leaved from the master interface, then reading
IFLA_MASTER attribute causes ENODATA. When the interface was previously
enslaved to another interface, we need to remove reference to the
interface from the previous master interface.

This is especially important when
```
ip link set dev eth0 nomaster
```
is called.

Fixes a bug introduced by 0d411b7f8f (v249).
Fixes #37629.

(cherry picked from commit f44b20b7b6)
(cherry picked from commit 2ad46c0606)
2025-06-25 18:17:42 +01:00
Zbigniew Jędrzejewski-Szmek e1afd271b5 coredump: get rid of a bogus assertion
The check looks plausible, but when I started checking whether it needs
to be lowered for the recent changes, I realized that it doesn't make
much sense.

context_parse_iovw() is called from a few places, e.g.:
- process_socket(), where the other side controls the contents of the
  message. We already do other checks on the correctness of the message
  and this assert is not needed.
- gather_pid_metadata_from_argv(), which is called after
  inserting MESSAGE_ID= and PRIORITY= into the array, so there is no
  direct relation between _META_ARGV_MAX and the number of args in the
  iovw.
- gather_pid_metadata_from_procfs(), where we insert a bazillion fields,
  but without any relation to _META_ARGV_MAX.

Since we already separately check if the required stuff was set, drop this
misleading check.

(cherry picked from commit 13902e0253)
(cherry picked from commit 4c424072b3)
2025-05-29 16:49:36 +02:00
Zbigniew Jędrzejewski-Szmek 9c9e09ed85 coredump: also stop forwarding non-dumpable processes
See the comment in the patch for details.

Suggested-by: Qualys Security Advisory <qsa@qualys.com>

(cherry-picked from 8fc7b2a211)
(cherry-picked from 101058955e)
2025-05-29 16:48:47 +02:00
Zbigniew Jędrzejewski-Szmek 19d439189a coredump: use %d in kernel core pattern
The kernel provides %d which is documented as
"dump mode—same as value returned by prctl(2) PR_GET_DUMPABLE".

We already query /proc/pid/auxv for this information, but unfortunately this
check is subject to a race, because the crashed process may be replaced by an
attacker before we read this data, for example replacing a SUID process that
was killed by a signal with another process that is not SUID, tricking us into
making the coredump of the original process readable by the attacker.

With this patch, we effectively add one more check to the list of conditions
that need be satisfied if we are to make the coredump accessible to the user.

Reportedy-by: Qualys Security Advisory <qsa@qualys.com>

(cherry-picked from 0c49e0049b)
(cherry-picked from c58a8a6ec9)
2025-05-29 16:48:18 +02:00
Zbigniew Jędrzejewski-Szmek cf16b6b6b2 coredump: get rid of _META_MANDATORY_MAX
No functional change. This change is done in preparation for future changes.
Currently, the list of fields which are received on the command line is a
strict subset of the fields which are always expected to be received on a
socket. But when we add new kernel args in the future, we'll have two
non-overlapping sets and this approach will not work. Get rid of the variable
and enumerate the required fields. This set will never change, so this is
actually more maintainable.

The message with the hint where to add new fields is switched with
_META_ARGV_MAX. The new order is more correct.

(cherry-picked from 49f1f2d4a7)
(cherry-picked from aea6a631bc)
2025-05-29 16:44:17 +02:00
Mike Yuan 4dde8c9485 core/manager: do not pop gc_unit_queue before unit_gc_sweep()
Follow-up for 52e3671bf7

unit_gc_sweep() might try to add the unit to gc queue again.
While that becomes no-op as Unit.in_gc_queue is not cleared
yet, it induces minor inconsistency of states.

(cherry picked from commit 741a184a31)
(cherry picked from commit 9645e946f9)
2025-05-28 19:16:16 +01:00
Lennart Poettering 6d33cf046a homed: generate proper error if we cannot create mountpoint for homedir
Let's make this easier to debug. (When this failed for me due to disk
full it took me a bit to figure out what was going on.)

(cherry picked from commit 5b759bf5fd)
(cherry picked from commit 8158c87c36)
2025-05-28 19:16:16 +01:00
Yu Watanabe 5e890ed995 network: do not drop duplicated entries in loop
Fixes #37456.

(cherry picked from commit 6a4fe38f7f)
(cherry picked from commit 936cba12c9)
2025-05-28 19:16:16 +01:00
Zbigniew Jędrzejewski-Szmek 385a33b043 coredump: restore compatibility with older patterns
This was broken in f45b801551. Unfortunately
the review does not talk about backward compatibility at all. There are
two places where it matters:
- During upgrades, the replacement of kernel.core_pattern is asynchronous.
  For example, during rpm upgrades, it would be updated a post-transaction
  file trigger. In other scenarios, the update might only happen after
  reboot. We have a potentially long window where the old pattern is in
  place. We need to capture coredumps during upgrades too.
- With --backtrace. The interface of --backtrace, in hindsight, is not
  great. But there are users of --backtrace which were written to use
  a specific set of arguments, and we can't just break compatiblity.
  One example is systemd-coredump-python, but there are also reports of
  users using --backtrace to generate coredump logs.

Thus, we require the original set of args, and will use the additional args if
found.

A test is added to verify that --backtrace works with and without the optional
args.

(cherry picked from commit ded0aac389)
(cherry picked from commit f9b8b75c11)
2025-05-28 19:16:16 +01:00