Commit Graph

87285 Commits

Author SHA1 Message Date
dependabot[bot]
39f6e7fedf build(deps): bump meson from 1.10.1 to 1.10.2 in /.github/workflows
Bumps [meson](https://github.com/mesonbuild/meson) from 1.10.1 to 1.10.2.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.10.1...1.10.2)

---
updated-dependencies:
- dependency-name: meson
  dependency-version: 1.10.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
(cherry picked from commit e44f88f275)
2026-04-13 12:40:16 +01:00
dependabot[bot]
322dcc7afe 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](103e5f8824...03d5b806a9)

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](a06a81a03e...153bb8e044)

---
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>
(cherry picked from commit ac725eb953)
2026-04-13 12:40:16 +01:00
Michal Rybecky
578de5cbc8 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.

(cherry picked from commit b675582861)
2026-04-13 12:40:16 +01:00
Michal Rybecky
034f2f439c 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).

(cherry picked from commit 0ffefb8a4d)
2026-04-13 12:40:16 +01:00
Daan De Meyer
f225a3b922 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>
(cherry picked from commit d3cb7a4e0f)
2026-04-13 12:40:16 +01:00
Daan De Meyer
1ff9056d5b 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>
(cherry picked from commit af5126568a)
2026-04-13 12:40:16 +01:00
Daan De Meyer
a5ce5b8c3d 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).

(cherry picked from commit 614509699a)
2026-04-13 12:40:16 +01:00
Daan De Meyer
deaa86f8b4 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>
(cherry picked from commit 138c08d803)
2026-04-13 12:40:16 +01:00
Antonio Alvarez Feijoo
6279ab43d0 man: fix typos in some binary names
(cherry picked from commit d2983ba6e7)
2026-04-13 12:40:16 +01:00
Michael Ferrari
de7a96c5c2 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

(cherry picked from commit 54d927d579)
2026-04-13 12:40:16 +01:00
Luca Boccassi
190d2fcfb4 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

(cherry picked from commit 07167cefd6)
2026-04-13 12:40:16 +01:00
Valentin David
cb6fdfc407 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

(cherry picked from commit bd2c3d35ce)
2026-04-13 12:40:16 +01:00
Valentin David
e9c7335ff5 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.

(cherry picked from commit 53b44ddfa7)
2026-04-13 12:40:16 +01:00
Valentin David
abbd5fb80c sysupdated: Accept "current+pending" key
Since 594d0345fa the key for
current version might be "current+pending". So in order not to fail
we need to accept it.

Fixes #41409

(cherry picked from commit 58dc0abcb1)
2026-04-13 12:40:16 +01:00
Luca Boccassi
d737a4b50f test-json: avoid divide-by-zero coverity warning for index 9
Same fix as d0a066a1a4 did for
index 10: add iszero_safe() check before dividing by the
json variant real value.

CID#1587762

Follow-up for d0a066a1a4

(cherry picked from commit 7f133c996c)
2026-04-13 12:40:16 +01:00
Michael Vogt
5484902895 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.

(cherry picked from commit ad7813844a)
2026-04-13 12:40:16 +01:00
Luca Boccassi
1b8d1b3e76 boot: clamp setup header copy size to sizeof(SetupHeader)
The setup_size field from the kernel image header is used as part
of the memcpy size. Clamp it to sizeof(SetupHeader) to ensure the
copy does not read beyond the struct bounds even if the kernel
image header contains an unexpected value.

CID#1549197

Follow-up for d62c177756

(cherry picked from commit a770fb3e14)
2026-04-13 12:40:16 +01:00
Luca Boccassi
6885e88f81 calendarspec: use ADD_SAFE for repeat offset calculation
Use overflow-safe ADD_SAFE() instead of raw addition when
computing the next matching calendar component with repeat.
On overflow, skip the component instead of using a bogus value.

CID#1548052

Follow-up for a2eb5ea79c

(cherry picked from commit de2a7614f1)
2026-04-13 12:40:16 +01:00
Luca Boccassi
a900f21b31 repart: use INC_SAFE for partition min size accumulation
Use overflow-safe INC_SAFE() instead of raw addition when
accumulating partition minimum size components.

CID#1548041

Follow-up for 170c982345

(cherry picked from commit 1eb2bd5aaf)
2026-04-13 12:40:16 +01:00
Luca Boccassi
8219268106 test-strv: avoid unsigned wraparound in backwards iteration
Use pre-decrement starting from 3 instead of post-decrement
starting from 2, so that the unsigned counter does not wrap
past zero on the final iteration.

CID#1548035

Follow-up for 02f19706a9

(cherry picked from commit ded2e6e976)
2026-04-13 12:40:16 +01:00
Luca Boccassi
425bca3c26 sd-bus: use usec_add() for auth timeout calculation
Use the overflow-safe usec_add() instead of raw addition for
computing the authentication timeout.

CID#1548036

Follow-up for e3017af973

(cherry picked from commit aa2cc18c76)
2026-04-13 12:40:16 +01:00
Adam Dinwoodie
4bc0c98834 man: fix caps in example path
(cherry picked from commit 566a4f3437)
2026-04-13 12:40:16 +01:00
Morten Linderud
32f53e3a78 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>
(cherry picked from commit 3242308ce3)
2026-04-13 12:40:16 +01:00
Morten Linderud
1ea05f376e man/systemd-repart: remove extra pipe character in manpage
Signed-off-by: Morten Linderud <morten@linderud.pw>
(cherry picked from commit a0ba770edc)
2026-04-13 12:40:16 +01:00
Adrian Wannenmacher
5665b14945 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.

(cherry picked from commit f377be7081)
2026-04-13 12:40:16 +01:00
Luca Boccassi
b8fc02e8e3 exec-util: use unsigned shift for ExecCommandFlags
Using signed int literal '1' in left shift operations can
theoretically lead to undefined behavior. Use 1U to be explicit
about unsigned arithmetic.

CID#1548018

Follow-up for b3d593673c

(cherry picked from commit 3e38052f1d)
2026-04-13 12:40:16 +01:00
Luca Boccassi
299afcbc49 debug-generator: use unsigned bit shift for breakpoint flags
Using signed int literal '1' in left shift can lead to undefined
behavior if the shift amount causes overflow of a signed int. Use
UINT32_C(1) since the result is stored in a uint32_t variable.

CID#1568482

Follow-up for e9f781a5a4

(cherry picked from commit 1929226e7e)
2026-04-13 12:40:16 +01:00
Luca Boccassi
bf5951ea7d scsi_id: use strscpy instead of strncpy for wwn fields
strncpy does not null-terminate the destination buffer if the source
string is longer than the count parameter. Since wwn and
wwn_vendor_extension are char[17] and we copy up to 16 bytes, there's
a risk of missing null termination. Use strscpy which always
null-terminates.

CID#1469706

Follow-up for 4e9fdfccbd

(cherry picked from commit 86fd0337c6)
2026-04-13 12:40:16 +01:00
Luca Boccassi
f43012d6cd resolved: fix TOCTOU in hook discovery
Coverity complains that the directory is not pinned by FD
so it might changed between the stat and the open

CID#1643236

Follow-up for 8209f4adcd

(cherry picked from commit 3e889473c9)
2026-04-13 12:40:16 +01:00
Luca Boccassi
737f1ef162 stat-util: fix return type of mode_verify_socket()
It returns an error code, not a mode

Follow-up for 97fe03e12f

(cherry picked from commit 8fe512a02e)
2026-04-13 12:40:16 +01:00
Luca Boccassi
021dc31682 pe-binary: fix error reporting
This is a local calculation, errno is not set

Follow-up for a434270139

(cherry picked from commit 1a0fe20bc2)
2026-04-13 12:40:16 +01:00
Luca Boccassi
900ae49b0d boot: add overflow check in GPT parser
ALIGN_TO() can overflow and return SIZE_MAX

CID#1644887

Follow-up for ccbd324a3a

(cherry picked from commit 85b20f5fa7)
2026-04-13 12:40:16 +01:00
Luca Boccassi
f1112b15d1 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
(cherry picked from commit abe3d570f8)
2026-04-13 12:40:16 +01:00
Luca Boccassi
fda27212ab networkd: fix assert with IPFamily=both in MobileNetwork conf
Fixes https://github.com/systemd/systemd/issues/41389

Follow-up for f8a4c3d375

(cherry picked from commit e0ab84e21b)
2026-04-13 12:40:16 +01:00
Luca Boccassi
5d8b1c22ce sysupdate: add more input validation
Ensure bogus inputs are cleanly rejected. These are privileged
interfaces so in practice it's not a problem.

Reported on yeswehack.com as YWH-PGM9780-168

Follow-up for bf2c741fd7

(cherry picked from commit b3c3a40b35)
2026-04-13 12:40:16 +01:00
Luca Boccassi
a414d73325 mkosi: add test job for Ubuntu 26.04
It is now in beta freeze, so we can start adding test coverage

(cherry picked from commit b4335ea9fc)
2026-04-13 12:40:16 +01:00
Luca Boccassi
6a84afd4b0 mkosi: pull in gnu coreutils for Ubuntu 26.04 and newer
The default coreutils in Ubuntu 26.04 moved to uutils, which is broken
in many subtle and annoying ways, breaking various tests. It's also
a giant monolithic megabinary which makes the minimal image size
go up and break other tests.

Force the gnu coreutils to be pulled in all images.

(cherry picked from commit 1d6585f218)
2026-04-13 12:40:16 +01:00
Luca Boccassi
ecf27a3eef test: exclude gnusleep from coredumps parsing
In Ubuntu 26.04 the actual binary is called gnusleep, and sleep is a symlink,
so fix the regex exclusion for the coredump checks

(cherry picked from commit f737b38977)
2026-04-13 12:40:16 +01:00
Luca Boccassi
8f06afa8c9 test: check for bin/bash in dissect --mtree instead of cat
Ubuntu is doing shenanigans with their coreutils so they are now
symlinks instead of binaries, so the grep fails. Check bash instead
to fix test failure on 26.04.

(cherry picked from commit 9f56d62f92)
2026-04-13 12:40:16 +01:00
Luca Boccassi
6a4faecb43 mkosi: depend on bpftool for Ubuntu 26.04 build image
bpftool was disentangled, so we can depend on it, and build with bpf

(cherry picked from commit a1dada941d)
2026-04-13 12:40:16 +01:00
Lennart Poettering
57b1870ca6 tmpfile-util: don't log about lack of O_TMPFILE support
It's a very common case (vfat...), and it's just too much noise. After
all the whole function exists primarily to deal with O_TMPFILE not being
availeble everywhere...

(cherry picked from commit b34ff170d1)
2026-04-13 12:40:16 +01:00
Luca Boccassi
5a82abcd28 boot: avoid division by zero in splash image handling
A malformed image can cause a division by zero, check that
the parameters are not zero.

Reported on yeswehackl.com as YWH-PGM9780-173

Follow-up for 0fa2cac4f0

(cherry picked from commit 78ab70a46f)
2026-04-13 12:40:16 +01:00
Lennart Poettering
15f716dd20 bootspec: honour profile number when sorting properly
This corrects sorting of menu entries regarding profile numbers:

1. If the profile number is unset, let's treat this identical to profile
   0, when ordering stuff, because an item with no profile is
   conceptually the same as an item with only a profile 0.

2. Let's take the profile number into account also if sort keys are
   used. This was makes profiles work sensibly in type 1 entries, via
   the recently added "profile" stanza.

Follow-up for: 5fb90fa319

(cherry picked from commit 6a4a4f0302)
2026-04-13 12:40:16 +01:00
Lennart Poettering
3a10cafbad boot: do no show pixel width/height in text mode
When running in pure text mode (i.e. serial terminal) the pixel
width/height is zero and makes no sense to report. Suppress it.

(cherry picked from commit 208cc69c50)
2026-04-13 12:40:16 +01:00
Lennart Poettering
9aa214c42a boot: properly track internal menu entries
When showing the list of menu entries via "p", the "internal call:"
field was showing nonsense, since
fb6cf4bbb7.

Fix that by adding a proper entry type for "internal" menu items such as
reboot/firmware/poweroff, and then check for that.

With this in place all entries now have a loader type that makes sense
and describes precisely what an entry is about.

(cherry picked from commit 3d4e3c1a5e)
2026-04-13 12:40:16 +01:00
Zbigniew Jędrzejewski-Szmek
1e5c7a27e7 basic/proc-cmdline: extend comments
Inspired by the discussion in #41161.

Also change the order of flags to be more logical. First the option
to specify at what fields we look, then the option to specify how we
return their name, the the value, and finally what to do if the value
is missing.

(cherry picked from commit 2d2dc38f00)
2026-04-13 12:40:16 +01:00
Lennart Poettering
aa4c66dc50 units: make use of nvpcrs only after the NV anchor completion measurement is done
This makes sure we don't use the "hardware" or "verity" nvpcrs before
the NV anchor measurement is done.

This is mostly to avoid confusing output, and to indirectly ensure the
nvpcr allocation in tpm2-setup is the load bearing one, but it should
not be load bearing for security afaics.

(cherry picked from commit eaeeae6598)
2026-04-13 12:40:16 +01:00
Lennart Poettering
34010a283b creds-util: only lock against public key PCR stuff if we are booted with UEFI supporting TPMs
The UKI public key PCR stuff only works if we get PCR measurements from
the pre-boot environment, hence automatically disable the logic by
default if we don't have that.

(cherry picked from commit 3b20cc4526)
2026-04-13 12:40:16 +01:00
Lennart Poettering
cc6e1a87c6 pcrlock: deal with firmwares which understand TPM but where no TPM is available
This is a potentially common case in VMs: firmwares might know the
concept of TPMs, but the hardware is not enabled in the specific VM.
Let's handle this case nicely.

(cherry picked from commit 96bb950ffa)
2026-04-13 12:40:16 +01:00
Lennart Poettering
3d9fc4af2d pcrlock: don't fail if firmware measurements aren't available
With swtpm in place we now commonly have systems where TPM is available
during runtime, but not in the firmware. Handle that nicely.

(cherry picked from commit 1494cb04ea)
2026-04-13 12:40:16 +01:00