Commit Graph
84384 Commits
Author SHA1 Message Date
Lennart Poettering a7a252dc16 sd-json: make sure SD_JSON_BUILD_STRING_UNDERSCORIFY() can deal with NULL strings
SD_JSON_BUILD_STRING() and everything else can deal with it, make sure
SD_JSON_BUILD_STRING_UNDERSCORIFY() can too.

(cherry picked from commit a77a95665f)
(cherry picked from commit 29f4fba3c6)
(cherry picked from commit a09efa6cf5)
2026-05-27 15:29:27 +01:00
Frantisek Sumsal c76657a9bd import: fix an always-true assert()
(cherry picked from commit 6182d0c666)
(cherry picked from commit 58b7da118c)
(cherry picked from commit 3cbae959ba)
2026-05-27 15:29:27 +01:00
Frantisek Sumsal 2f09261d2f strxcpyx: add a paranoia check for vsnprintf()'s return value
vsnprintf() can, under some circumstances, return negative value, namely
during encoding errors when converting wchars to multi-byte characters.
This would then wreak havoc in the arithmetics we do following the
vsnprintf() call. However, since we never do any wchar shenanigans in
our code it should never happen.

Let's encode this assumption into the code as an assert(), similarly how
we already do this in other places (like strextendf_with_separator()).

(cherry picked from commit 774a9f440b)
(cherry picked from commit 066c5e56b5)
(cherry picked from commit 1898ba5965)
2026-05-27 15:29:27 +01:00
Yu Watanabe 28d20c3b95 dhcp-protocol: Option Overload (52) DHCP option value takes flags
(cherry picked from commit c651876cc9)
(cherry picked from commit d6ad6a1bdb)
(cherry picked from commit 30e32868cf)
2026-05-27 15:29:27 +01:00
Yu Watanabe 858ae737a2 resolve: add missing OOM check
(cherry picked from commit 16f5a2992d)
(cherry picked from commit 48366d0272)
(cherry picked from commit 132b08a287)
2026-05-27 15:29:27 +01:00
Yu Watanabe 7bf7799f0b sd-dhcp-client: fix memleak of sd_dhcp_client.timeout_ipv6_only_mode
This also drops unnecessary zero assignments.

(cherry picked from commit 366e1d264a)
(cherry picked from commit ff35fc2616)
(cherry picked from commit 34da6e7dcc)
2026-05-27 15:29:27 +01:00
Sebastian Bernardt 1ed7425d71 mailmap: name change
(cherry picked from commit c8f5a56408)
(cherry picked from commit 70f6f7e4c0)
(cherry picked from commit 92bd0ebbda)
2026-05-27 15:29:27 +01:00
Tobias Stoeckmann 42fb879faf man: Fix NOTES formatting
The NOTES section in os-release(5) contains an unusual formatting.
Switch function and ulink tags and remove a newline within ulink text to
keep the entry formatting in sync with others. Also, this preserves the
formatting within the text itself.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
(cherry picked from commit 4d2847dcc2)
(cherry picked from commit 5511017f4b)
(cherry picked from commit a29c5ab031)
2026-05-27 15:29:27 +01:00
Lennart Poettering 6baf63c7ca boot: gracefully handle LoadFile() implementations that return EFI_SUCCESS with a NULL buffer
LoadFile() with a NULL buffer is supposed to return the file size
without acquiring the data and return EFI_BUFFER_TOO_SMALL.

However it appears some firmware returns EFI_SUCCESS in case the file is
empty, i.e. the file size returned is zero. And I guess that's even
fine.

Let's handle this gracefully hence.

(cherry picked from commit c40f254cca)
(cherry picked from commit 990ec9da53)
(cherry picked from commit a764290f32)
2026-05-27 15:29:27 +01:00
Lennart Poettering f5fb43bc3c boot: never auto-boot a menu entry with the non-default profile
When figuring out which menu entry to pick by default, let's not
consider any with a profile number > 0. This reflects that fact that
additional profiles are generally used for
debug/recovery/factory-reset/storage target mode boots, and those should
never be auto-selected. Hence do a simple check: if profile != 0, simply
do not consider the entry as a default.

We might eventually want to beef this up, and add a property one can set
in the profile metadata that controls this behaviour, but for now let's
just do a this simple fix.

(cherry picked from commit a93fa2c6b4)
(cherry picked from commit 2897eaf648)
(cherry picked from commit a7f3f2241e)
2026-05-27 15:29:27 +01:00
Lennart Poettering f137414c6a man: drop redundant word from varlinkctl man page
(cherry picked from commit c83c21a054)
(cherry picked from commit e06e0e0f20)
(cherry picked from commit f41cadb386)
2026-05-27 15:29:26 +01:00
Frantisek Sumsal de64c3575e namespace: don't log misleading error in the r > 0 path
fd_is_fs_type() returns < 0 for errors, 0 for false, and > 0 for true, so
in the r > branch we'd most likely report EPERM together with the error
message which is misleading.

(cherry picked from commit c859d41232)
(cherry picked from commit 973ade990f)
(cherry picked from commit a513464dfb)
2026-05-27 15:29:26 +01:00
Frantisek Sumsal 832b5565cd nspawn: avoid passing NULL to log_syntax()
If range is NULL (i.e. when PrivateUsers= doesn't contain ':'),
both later error paths will then pass NULL to log_syntax():

~# cat foo.nspawn
[Exec]
PrivateUsers=9999999999999999999

~# SYSTEMD_LOG_LEVEL=debug systemd-nspawn -D foo |& grep foo.nspawn
Found settings file: /root/foo.nspawn
/root/foo.nspawn:2: UID/GID shift invalid, ignoring: (null)

or

~# cat foo.nspawn
[Exec]
PrivateUsers=4294967294

~ # SYSTEMD_LOG_LEVEL=debug systemd-nspawn -D foo |& grep foo.nspawn
Found settings file: /root/foo.nspawn
/root/foo.nspawn:2: UID/GID shift and range combination invalid, ignoring: (null)

Let's just use rvalue in both of these cases instead.

(cherry picked from commit d651df8283)
(cherry picked from commit 967fec09a2)
(cherry picked from commit a7705c8034)
2026-05-27 15:29:26 +01:00
Frantisek Sumsal 005d63beb4 udev-builtin: add a couple of asserts
(cherry picked from commit 4977c00e2a)
(cherry picked from commit 1623e4730e)
(cherry picked from commit 6fbfb01587)
2026-05-27 15:29:26 +01:00
Frantisek Sumsal e1135893bf scsi_id: use safe_atoi() instead of plain atoi()
(cherry picked from commit 5853d0a533)
(cherry picked from commit 0d02fa0ff7)
(cherry picked from commit 77da8a4122)
2026-05-27 15:29:26 +01:00
Zbigniew Jędrzejewski-Szmek 9f2760319c test-string-util: test empty_to_null on a char array
Unfortunately empty_to_null(t) where t is char[] fails. But it
works with &t[0].

(cherry picked from commit 067aa9b767)
(cherry picked from commit e1a30036b5)
(cherry picked from commit 219edc81f7)
2026-05-27 15:29:26 +01:00
Frantisek Sumsal 90e15f1fb6 timesync: verify the actual size of the received data
iov.iov_len doesn't change after calling recvmsg() so it remains set to
sizeof(ntpmsg), which makes the check for a short packet always false.
Let's fix that by checking the actual size of the received data instead.

(cherry picked from commit 335cc8f39c)
(cherry picked from commit ff5b71f38f)
(cherry picked from commit 57ff31cc49)
2026-05-27 15:29:26 +01:00
Frantisek Sumsal a03c2d39a5 string-util: check for overflow in strrep()
This simply mirrors the same overflow check we already have in
strrepa(), in case someone passed us a sufficiently long string.

strrep() is currently used only in tests, so this is just hardening.

(cherry picked from commit b22daa97e1)
(cherry picked from commit d8f2a2fb92)
(cherry picked from commit e0d0c93f65)
2026-05-27 15:29:26 +01:00
Luca Boccassi f1664f7016 machined: gate metadata querying behind inspect-machines/images action
Ensure only privileged users can call the system scope machined's
APIs that get data out of a machine

Follow-up for 1bd979dddb
Follow-up for 9153b02bb5

(cherry picked from commit 3e716178cc)
(cherry picked from commit 6e6aa47f46)
(cherry picked from commit b808894777)
2026-05-27 15:29:26 +01:00
Zbigniew Jędrzejewski-Szmek 3ed9869c47 various: fix compilation with openssl-4.0.0-beta1
Various types have been made opaque, so we need to use some accessor
functions.

(cherry picked from commit 693ecaac7e)
(cherry picked from commit bf29422d62)
(cherry picked from commit d082d842e2)
2026-05-27 15:23:32 +01:00
Luca Boccassi 121b8479c8 resolved: check for reset-statistics polkit action via D-Bus too
The varlink method checks for polkit authorization, so also
update the D-Bus method to match it.

Follow-up for cf01bbb7a4

(cherry picked from commit b1d9127c39)
(cherry picked from commit d5129d8433)
(cherry picked from commit b8d6b85609)
2026-05-27 15:23:32 +01:00
Daan De Meyer b064e932cc TEST-75-RESOLVED: Make sure --suppress-sync is not used
(cherry picked from commit 0d57260976)
(cherry picked from commit bcf9560093)
(cherry picked from commit 0d4ccb7069)
2026-05-27 15:23:32 +01:00
Daan De Meyer 32c99a6127 test-seccomp: Handle environment where sync() is already suppressed
We might be running in an nspawn container booted with --suppress-sync,
so make sure we handle that scenario gracefully.

(cherry picked from commit 31441cb782)
(cherry picked from commit 4f974b5492)
(cherry picked from commit 6c2be56375)
2026-05-27 15:23:32 +01:00
Daan De Meyer 50f1c13a32 TEST-64-UDEV-STORAGE: Add missing scsi controllers
(cherry picked from commit 014a4d93e0)
(cherry picked from commit e7e6b741bb)
(cherry picked from commit db2ae46225)
2026-05-27 15:23:32 +01:00
Daan De Meyer a05f87d4e0 TEST-24-CRYPTSETUP: Use virtio-blk-pci
Doesn't require a controller.

(cherry picked from commit a8416614b0)
(cherry picked from commit 9f5c5005f2)
(cherry picked from commit cab01d6205)
2026-05-27 15:23:32 +01:00
Daan De Meyer 3ea1c33a1d TEST-13-NSPAWN: Use timeout --foreground in two more places
(cherry picked from commit 518dcfadab)
(cherry picked from commit 1c4ab1c308)
(cherry picked from commit 9cb64d55e1)
2026-05-27 15:23:32 +01:00
Daan De Meyer 76d61b5f9d TEST-07-PID1: Use --foreground with timeout
Otherwise the test fails if a TTY is attached to stdio.

(cherry picked from commit 9c0abfaf15)
(cherry picked from commit fc4159dd95)
(cherry picked from commit ccd3975ae4)
2026-05-27 15:23:32 +01:00
Daan De Meyer 410b3745a5 TEST-07-PID1: Don't fail in vm without ESP or XBOOTLDR mount
(cherry picked from commit e7d1030d77)
(cherry picked from commit 0ecb372eac)
(cherry picked from commit db1dbca274)
2026-05-27 15:23:32 +01:00
roib 5c4701e107 docs: update footer to 2026
(cherry picked from commit db1ca20591)
(cherry picked from commit 2aa3e50692)
(cherry picked from commit 10824f7465)
2026-05-27 15:23:32 +01:00
Luca Boccassi 2007bfa580 hwdb: update to main@{2026-04-14}
The addition of hwdb.d/40-imds.hwdb is dropped. (Corresponding changes
in hwdb_parse.py are kept, they are not a problem.)

(cherry picked from commit deb3b034e2)
(cherry picked from commit a2e4f29a82)
2026-05-27 15:23:31 +01:00
Luca Boccassi 12d675ad04 importd: harden curl file protocol handling
With old libcurl versions file:// can get redirects which can be messy, while
the new version rejects them. Set an option to explicit block them.

(cherry picked from commit 275ec1160b)
(cherry picked from commit 7cb8d612ef)
(cherry picked from commit 154e1a669e)
2026-05-27 15:23:31 +01:00
Luca Boccassi 652c7ded80 journal-upload: also disable VERIFYHOST when --trust=all is used
When --trust=all disables CURLOPT_SSL_VERIFYPEER, the residual
CURLOPT_SSL_VERIFYHOST check is ineffective since an attacker can
present a self-signed certificate with the expected hostname. Disable
both for consistency and log that server certificate verification is
disabled.

Follow-up for 8847551bcb

(cherry picked from commit f125fc6a22)
(cherry picked from commit 20e7ffd9d4)
(cherry picked from commit 5278c63c2e)
2026-05-27 15:23:31 +01:00
Luca Boccassi 5e7656b43c machined: pass user as positional argument in machine_default_shell_args()
Instead of interpolating the user name directly into the sh -c script
body via asprintf %s, pass it as a positional parameter ($1) in a
separate argv entry. This avoids the user string being parsed as part
of the shell script syntax.

Also validate the user name in bus_machine_method_open_shell() with
valid_user_group_name(), matching the validation already done on the
Varlink path via json_dispatch_const_user_group_name().

Follow-up for 49af9e1368

(cherry picked from commit a9e9288288)
(cherry picked from commit df18d26c37)
(cherry picked from commit 50e3b71952)
2026-05-27 15:23:31 +01:00
Luca Boccassi 9edcc15285 logind: reject wall messages containing control characters
method_set_wall_message() and the property setter only checked the
message length but not its content. Since wall messages are broadcast
to all TTYs, control characters in the message could interfere with
terminal state. Reject messages containing control characters other
than newline and tab.

Follow-up for 9ef15026c0
Follow-up for e2fa5721c3

(cherry picked from commit 4bf9db7314)
(cherry picked from commit 32bfd96324)
(cherry picked from commit e21bfed990)
2026-05-27 15:23:31 +01:00
Luca Boccassi 74a23ac84d core: check selinux access on each unit when listing
Units might have different access rules, so check the access on each
unit when querying the full list.

(cherry picked from commit 04f32dddd7)
(cherry picked from commit 0952b4e793)
(cherry picked from commit a806377739)
2026-05-27 15:23:31 +01:00
Luca Boccassi ea31d9bab0 core: add missing SELinux access checks when listing units
Add mac_selinux_unit_access_check_varlink() to the unit enumeration
loop in vl_method_list_units(), silently skipping units the caller
is not permitted to see, matching the D-Bus ListUnits behavior.
Add mac_selinux_access_check_varlink() to vl_method_describe_manager().

Follow-up for 472abf7bec
Follow-up for 736349958e

(cherry picked from commit 26fd286210)
(cherry picked from commit de05ec8318)
(cherry picked from commit caae0bf26c)
2026-05-27 15:23:31 +01:00
rusty-snake 9f26143db8 docs: fix capability name, it's CAP_MKNOD not CAP_SYS_MKNOD (#41621)
(cherry picked from commit b40ed2067f)
(cherry picked from commit c36c8a31e6)
(cherry picked from commit 524adaec7d)
2026-05-27 15:23:31 +01:00
Yu Watanabe 170db64e58 dhcp: fix user class and vendor specific option assignment
The commit 6d7cb9a6b8 fixes the assignment
of the these options when specified through SendOption=. However, it
breaks when specified through UserClass= or SendVendorOption=.

When UserClass= or SendVendorOption= is specified, the option length is
calculated from the sd_dhcp_client.user_class or .vendor_options. Hence,
we can use 0 for the length in that case.

Follow-up for 6d7cb9a6b8.

(cherry picked from commit 55f2fdd508)
(cherry picked from commit 98983d4f67)
(cherry picked from commit 5e19255a6c)
2026-05-27 15:23:31 +01:00
Duncan Overbruck 5e69dcdcfa boot-entry: add 'auto' keyword to parse_boot_entry_token_type
Add the auto keyword as documented in the help message and man pages of
`kernel-install`, `bootctl` and `systemd-pcrlock`.

(cherry picked from commit 7208a74a2b)
(cherry picked from commit acc71ff6ca)
(cherry picked from commit 329a3d27e4)
2026-05-27 15:23:31 +01:00
Milan Kyselica 1ba717af47 boot: fix loop bound and OOB in devicetree_get_compatible()
The loop used the byte offset end (struct_off + struct_size) as the
iteration limit, but cursor[i] indexes uint32_t words. This reads
past the struct block when end > size_words.

Use size_words (struct_size / sizeof(uint32_t)) which is the correct
number of words to iterate over.

Also fix a pre-existing OOB in the FDT_BEGIN_NODE handler: the guard
i >= size_words is always false inside the loop (since the loop
condition already ensures i < size_words), so cursor[++i] at the
boundary reads one word past the struct block. Use i + 1 >= size_words
to check before incrementing.

Fixes: https://github.com/systemd/systemd/issues/41590
(cherry picked from commit 2c664b9531)
(cherry picked from commit 93e3c738d2)
(cherry picked from commit b3c8a71d78)
2026-05-27 15:23:31 +01:00
Milan Kyselica 1b5938d5c1 boot: fix integer overflow and division by zero in BMP splash parser
Bound image dimensions before computing row_size to prevent overflow
in the depth * x multiplication on 32-bit. Without this, crafted
dimensions like depth=32 x=0x10000001 wrap to a small row_size that
passes all subsequent checks.

Reject channel masks where all bits are set (popcount == 32), since
1U << 32 is undefined behavior and causes division by zero on
architectures where it evaluates to zero. Move the validation before
computing derived values for clarity. Use unsigned 1U in shifts to
avoid signed integer overflow UB for popcount == 31.

Also reject zero-width and zero-height images.

Fixes: https://github.com/systemd/systemd/issues/41589
(cherry picked from commit c3c9cc7adb)
(cherry picked from commit b23313a47e)
(cherry picked from commit 940e2016ed)
2026-05-27 15:23:31 +01:00
Lennart Poettering f28a2371fe core: use JSON_BUILD_CONST_STRING() where appropriate
(cherry picked from commit 087733e348)
(cherry picked from commit e8ae506245)
(cherry picked from commit b2016c3b01)
2026-05-27 15:23:31 +01:00
Luca Boccassi f7e8b25e46 udev/scsi-id: check for invalid header from kernel buffer
(cherry picked from commit 06d3f37336)
(cherry picked from commit 54b4851d27)
(cherry picked from commit 661600fb4a)
2026-05-27 15:23:31 +01:00
Luca Boccassi d2d3aab7ab udev/scsi-id: check for invalid chars in various fields received from the kernel
Follow-up for 16325b35fa

(cherry picked from commit 5f700d148c)
(cherry picked from commit 4a4d0838b8)
(cherry picked from commit 8ecee45b24)
2026-05-27 15:23:31 +01:00
Milan Kyselica 5689970d20 nss-systemd: fix off-by-one in nss_pack_group_record_shadow()
nss_count_strv() counts trailing NULL pointers in n. The pointer area
then used (n + 1), reserving one slot more than the size check
accounted for.

Drop the + 1 since n already includes the trailing NULLs, unlike the
non-shadow nss_pack_group_record() where n does not.

Fixes: https://github.com/systemd/systemd/issues/41591
(cherry picked from commit aa85a742fe)
(cherry picked from commit 97e3d2467b)
(cherry picked from commit c4b4eb8078)
2026-05-27 15:23:31 +01:00
Frantisek Sumsal d5b3bccb62 journal: limit decompress_blob() output to DATA_SIZE_MAX
We already have checks in place during compression that limit the data
we compress, so they shouldn't decompress to anything larger than
DATA_SIZE_MAX unless they've been tampered with. Let's make this
explicit and limit all our decompress_blob() calls in journal-handling
code to that limit.

One possible scenario this should prevent is when one tries to open and
verify a journal file that contains a compression bomb in its payload:

$ ls -lh test.journal
-rw-rw-r--+ 1 fsumsal fsumsal 1.2M Apr 12 15:07 test.journal

$ systemd-run --user --wait --pipe -- build-local/journalctl --verify --file=$PWD/test.journal
Running as unit: run-p682422-i4875779.service
000110: Invalid hash (00000000 vs. 11e4948d73bdafdd)
000110: Invalid object contents: Bad message
File corruption detected at /home/fsumsal/repos/@systemd/systemd/test.journal:272 (of 1249896 bytes, 0%).
FAIL: /home/fsumsal/repos/@systemd/systemd/test.journal (Bad message)
          Finished with result: exit-code
Main processes terminated with: code=exited, status=1/FAILURE
               Service runtime: 48.051s
             CPU time consumed: 47.941s
                   Memory peak: 8G (swap: 0B)

Same could be, in theory, possible with just `journalctl --file=`, but
the reproducer would be a bit more complicated (haven't tried it, yet).

Lastly, the change in journal-remote is mostly hardening, as the maximum
input size to decompress_blob() there is mandated by MHD's connection
memory limit (set to JOURNAL_SERVER_MEMORY_MAX which is 128 KiB at the
time of writing), so the possible output size there is already quite
limited (e.g. ~800 - 900 MiB for xz-compressed data).

(cherry picked from commit 31d360fb0b)
(cherry picked from commit 02fdf1d0fe)
(cherry picked from commit ac9b00479e)
2026-05-27 15:23:31 +01:00
Frantisek Sumsal 3e683cad61 compress: limit the output to dst_max bytes with LZ4 if set
We already do that with other algorithms, so let's make
decompress_blob_lz4() consistent with the rest.

(cherry picked from commit 2cda5f6169)
(cherry picked from commit ae587dfa54)
(cherry picked from commit 6b0eb70ea4)
2026-05-27 15:23:31 +01:00
Frantisek Sumsal 611f17c092 journal: move the {DATA,ENTRY}_SIZE constants to sd-journal
So we can access them from the code there as well.

(cherry picked from commit d830bb1fc1)
(cherry picked from commit 3b197747a2)
(cherry picked from commit 9c7ad0c3cf)
2026-05-27 15:23:31 +01:00
Luca Boccassi c430508850 test-json: add iszero_safe guards for float division at index 0 and 1
The existing iszero_safe guards at index 9 and 10 were added to
silence Coverity, but the same division-by-float-zero warning also
applies to the divisions at index 0 (DBL_MIN) and 1 (DBL_MAX).

CID#1587762

Follow-up for 7f133c996c

(cherry picked from commit 44296e41db)
(cherry picked from commit 96daa8d1b9)
(cherry picked from commit 5b5429eeb4)
2026-05-27 15:23:31 +01:00
Luca Boccassi d6c3494a3b nss-myhostname: add more INC_SAFE for buffer index accumulation
Use overflow-safe INC_SAFE() instead of raw addition for idx
accumulation, so that Coverity can see the addition is checked.

CID#1548028

Follow-up for a05483a921

(cherry picked from commit 1afc0c6c60)
(cherry picked from commit 93ca4634bf)
(cherry picked from commit 5c848e427b)
2026-05-27 15:23:31 +01:00