Commit Graph
58547 Commits
Author SHA1 Message Date
Daan De Meyer 74c903a28f mount-util: Use new mount API in bind_mount_submounts() (#41008) 2026-03-10 19:49:10 +01:00
Cyrus Xi 9d15e09d5c core/cgroup: fix TasksMaxScale percentage serialization (#41011)
bus_cgroup_set_tasks_max_scale() used a hand-rolled percentage format
that produced values ~10x too small (e.g., "TasksMax=4.0%" instead of
"TasksMax=40.00%").

On daemon-reload, the incorrect value was re-read, silently reducing
the effective TasksMax by ~10x and causing fork rejections on systems
with high thread counts.

Fix by using the existing PERMYRIAD macros, consistent with memory
property handlers (MemoryMax, MemoryHigh, MemoryLow, etc.).

Fixes: #41009
2026-03-11 03:36:21 +09:00
Yu Watanabe f6857cfaf2 fuzz: fix typo
Follow-up for be0db50cad.
2026-03-11 03:23:53 +09:00
Nandakumar Raghavan 6d7cb9a6b8 networkd: fix for networkd crash when client sends Option 82 via SendOption=
When a DHCP client uses SendOption=82:string:..., option_append() calls
the SD_DHCP_OPTION_RELAY_AGENT_INFORMATION case which was written for
the server relay path. It casts optval to sd_dhcp_server* and calls
strlen() on its members, but optval is actually raw binary data from
the client, causing SIGSEGV. The same is applicable when option 43 and
option 77 are passed to SendOption.

Fix by checking optlen > 0 and appending the option as a plain TLV,
skipping the server-specific relay agent logic.
2026-03-10 18:29:59 +01:00
Luca Boccassi 5647a19a58 nsresourced: downgrade benign log message to debug
This is very noisy as there's a dozen of these message every
time it gets called, and it's not really an error but an
expected situation, so downgrade from info to debug
2026-03-10 18:23:14 +01:00
Zbigniew Jędrzejewski-Szmek 0692870fe4 network: fix issue when configuring route (#41000)
Fixes #40106.
2026-03-10 17:14:15 +01:00
Lennart Poettering 0306b2c20e pcrlock: add .pcrlock file for recently added NvPCR separator
Follow-up for: 867e64737a
2026-03-10 13:52:25 +01:00
Lennart Poettering 2fb2428296 pcrlock: do not pass wrong error to log message 2026-03-10 12:03:17 +01:00
Lennart Poettering 809cb1b4d8 pcrlock: add an extra assert() 2026-03-10 12:03:17 +01:00
ppkramer-hubandpatrick e1877e6b06 mount: honor --timeout-idle-sec=SEC option (#41010)
When using systemd-mount to create a transient .mount/.automount file
for removable storage, the option to specify the idle timeout on the
commandline using **--timeout-idle-sec=SEC** is not reflected in the
generated .automount file. Instead, the idle timeout is always set to 1
second.

arg_timeout_idle_set was never set to true when passing the argument, so
arg_timeout_idle was always set to 1s.

Fixes #41007.

Co-authored-by: patrick <patrick@localhost>
2026-03-10 04:31:53 +09:00
Daan De Meyer d733009141 mount-util: Use new mount API in bind_mount_submounts() 2026-03-09 16:25:05 +01:00
Yu Watanabe ed54648b47 network: route bound to a link requires the link is up
We checked if the link is up only when configuring (explicit) nexthop,
but we did not checked that when configuring route which has (implicit)
nexthop.

Let's move the checks from nexthop_is_ready_to_configure() to
gateway_is_ready(), which is called for both implicit and explict
nexthops.

Fixes #40106.
2026-03-09 11:46:14 +09:00
Yu Watanabe 43989de642 network: check if gateway is ready only when the nexthop is bound to link
Currently, we support three types of nexthop:
1. simple nexthop, which is bound to link, may have specific gateway
   address,
2. blackhole nexthop, which is global configuration and is not bound to
   any links,
3. group nexthop, which is also global configuration and is not bound to
   any links.

Thus, gateway_is_ready() is only necessary to call for simple nexthop
case. Let's make the logic simpler.
2026-03-09 11:42:45 +09:00
Yu Watanabe ec4f646759 network: introduce link_is_up() helper function 2026-03-09 10:57:06 +09:00
Yu Watanabe 2cb0ccebf6 Shorten format-table code and fix potential memleak (#40917) 2026-03-09 09:26:30 +09:00
Mike Yuan a7f1670f62 user-record: extract user_record_image_is_blockdev() common helper 2026-03-06 22:50:48 +01:00
Frantisek Sumsal be0db50cad fuzz: add a fuzzer for user records
Add a simple fuzzer that verifies our machinery for parsing user records
from JSON works as intended.

The initial corpus was created with the help of Claude, so we have a
bunch of valid user records with as much fields as possible for the
initial corpus.
2026-03-06 19:03:14 +01:00
Frantisek Sumsal 3c7bd947b2 shared: don't leak memory from array fields
The fido2_hmac_salt/fido2_hmac_credential/recovery_key fields kept
leaking memory as the array itself wasn't deallocated after deallocating
each of its elements data:

$ build-san/userdbctl -F fuzz-corpus-userdb/auth-fido2.json
...
=================================================================
==1292840==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 112 byte(s) in 1 object(s) allocated from:
    #0 0x7f56f00e5e4b in realloc.part.0 (/lib64/libasan.so.8+0xe5e4b) (BuildId: 25975f766867e9e604dc5a71a8befeaed3301942)
    #1 0x7f56ed869e42 in greedy_realloc ../src/basic/alloc-util.c:65
    #2 0x7f56ed7ff5e9 in dispatch_fido2_hmac_salt ../src/shared/user-record.c:836
    #3 0x7f56edd73cbc in sd_json_dispatch_full ../src/libsystemd/sd-json/sd-json.c:5204
    #4 0x7f56edd745fc in sd_json_dispatch ../src/libsystemd/sd-json/sd-json.c:5276
    #5 0x7f56ed80100b in dispatch_privileged ../src/shared/user-record.c:998
    #6 0x7f56edd73cbc in sd_json_dispatch_full ../src/libsystemd/sd-json/sd-json.c:5204
    #7 0x7f56edd745fc in sd_json_dispatch ../src/libsystemd/sd-json/sd-json.c:5276
    #8 0x7f56ed80622c in user_record_load ../src/shared/user-record.c:1697
    #9 0x000000408c15 in display_user ../src/userdb/userdbctl.c:447
    #10 0x7f56ed83cc9a in dispatch_verb ../src/shared/verbs.c:137
    #11 0x00000041df2b in run ../src/userdb/userdbctl.c:1908
    #12 0x00000041dfbe in main ../src/userdb/userdbctl.c:1911
    #13 0x7f56ec8105b4 in __libc_start_call_main (/lib64/libc.so.6+0x35b4) (BuildId: 2b5beec0fd24fe9c9f43eddfdd5facf0b8a1b805)
    #14 0x7f56ec810667 in __libc_start_main@@GLIBC_2.34 (/lib64/libc.so.6+0x3667) (BuildId: 2b5beec0fd24fe9c9f43eddfdd5facf0b8a1b805)
    #15 0x000000404a44 in _start (/home/fsumsal/repos/@systemd/systemd/build-san/userdbctl+0x404a44) (BuildId: 19e8b7e7b7038d2cea20bc18a55bea2a9e4406d5)

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7f56f00e5e4b in realloc.part.0 (/lib64/libasan.so.8+0xe5e4b) (BuildId: 25975f766867e9e604dc5a71a8befeaed3301942)
    #1 0x7f56ed869e42 in greedy_realloc ../src/basic/alloc-util.c:65
    #2 0x7f56ed7fe779 in dispatch_fido2_hmac_credential_array ../src/shared/user-record.c:775
    #3 0x7f56edd73cbc in sd_json_dispatch_full ../src/libsystemd/sd-json/sd-json.c:5204
    #4 0x7f56edd745fc in sd_json_dispatch ../src/libsystemd/sd-json/sd-json.c:5276
    #5 0x7f56ed80622c in user_record_load ../src/shared/user-record.c:1697
    #6 0x000000408c15 in display_user ../src/userdb/userdbctl.c:447
    #7 0x7f56ed83cc9a in dispatch_verb ../src/shared/verbs.c:137
    #8 0x00000041df2b in run ../src/userdb/userdbctl.c:1908
    #9 0x00000041dfbe in main ../src/userdb/userdbctl.c:1911
    #10 0x7f56ec8105b4 in __libc_start_call_main (/lib64/libc.so.6+0x35b4) (BuildId: 2b5beec0fd24fe9c9f43eddfdd5facf0b8a1b805)
    #11 0x7f56ec810667 in __libc_start_main@@GLIBC_2.34 (/lib64/libc.so.6+0x3667) (BuildId: 2b5beec0fd24fe9c9f43eddfdd5facf0b8a1b805)
    #12 0x000000404a44 in _start (/home/fsumsal/repos/@systemd/systemd/build-san/userdbctl+0x404a44) (BuildId: 19e8b7e7b7038d2cea20bc18a55bea2a9e4406d5)

SUMMARY: AddressSanitizer: 176 byte(s) leaked in 2 allocation(s).
2026-03-06 18:39:07 +01:00
Frantisek Sumsal 76ab7861ff shared: don't exclude valid min/max values for cgroup weight fields
1 and 10000 are valid cgroup weight values, but the condition was
incorrectly excluding them:

$ echo '{"userName":"crashhostarray","cpuWeight":1}' | userdbctl -F -
<stdin>:1:42: JSON field 'cpuWeight' is not in valid range 1…10000.

$ echo '{"userName":"crashhostarray","cpuWeight":10000}' | userdbctl -F -
<stdin>:1:42: JSON field 'cpuWeight' is not in valid range 1…10000.
2026-03-06 18:39:01 +01:00
Zbigniew Jędrzejewski-Szmek dc0b438836 various: use asprintf_safe in more places 2026-03-06 17:46:59 +01:00
Zbigniew Jędrzejewski-Szmek 1dc6445bbb shared/format-table: fix potential memleaks of d->formatted
We don't always return d->formatted, even if it is available. And
depending on the cell type, we'd either overwrite it directly or free
first. Let's always free it upfront and then set unconditionally.
(In this case, we don't need to spend effort on preserving the
existing value. It's just a cache.)  Setting the variable directly
allows many temporary variables to be eliminated.

Also use asprintf_safe() to simplify the allocation of the buffer.
This is probably a tiny bit slower than the direct allocation, but
table formatting shouldn't be a hot path.
2026-03-06 17:46:59 +01:00
Zbigniew Jędrzejewski-Szmek 52abc9fe96 basic/stdio-util: introduce asprintf_safe
asprintf is nice to use, but the _documented_ error return convention is
unclear:
> If  memory  allocation  wasn't possible, or some other error occurs,
> these functions will return -1, and the contents of strp are undefined.

What exactly "undefined" means is up for debate: if it was really
undefined, the caller wouldn't be able to meaningfully clean up, because
they wouldn't know if strp is a valid pointer. So far we interpreted
"undefined" — in some parts of the code base — as "either NULL or a
valid pointer that needs to be freed", and — in other parts of the
codebase — as "always NULL". I checked glibc and musl, and they both
uncoditionally set the output pointer to NULL on failure.

There is also no information _why_ asprintf failed. It could be an
allocation error or format string error. But we just don't have this
information.

Let's add a wrapper that either returns a good string or a NULL pointer.
Since there's just one failure result, we don't need a separate return
value and an output argument and can simplify callers.
2026-03-06 17:46:59 +01:00
Zbigniew Jędrzejewski-Szmek d1278e1847 basic/alloc-util: make realloc0 non-inline
It's actually only used in one place in libsystemd and moving it even makes
libsystemd smaller (in a non-optimized build):

$ ls -l build/libsystemd.so.0.43.0*
-rwxr-xr-x 1 zbyszek zbyszek 5763336 Mar  3 09:54 build/libsystemd.so.0.43.0-old
-rwxr-xr-x 1 zbyszek zbyszek 5763216 Mar  3 09:54 build/libsystemd.so.0.43.0

Also, move the definitions in the .h file so that similar functions are
grouped together and then move the definitions around in the .c file so
that they are in the same order as in the header.
2026-03-06 17:46:59 +01:00
Zbigniew Jędrzejewski-Szmek 3abe1e53f6 basic/allow-util: make free_many non-inline
Definition of free_many is moved to the .c file, no particular reason
for it to be inline and we can make the header file shorter.
2026-03-06 17:46:59 +01:00
Zbigniew Jędrzejewski-Szmek 54ed92e17c shared/format-table: use 'char*'-style in function signatures 2026-03-06 17:46:59 +01:00
Frantisek Sumsal 1e2517bf2e shared: fix segfault when processing matchHostname field
Fix a typo which causes a segfault when processing a user record
with matchHostname when it's an array instead of a simple string:

$ echo '{"userName":"crashhostarray","perMachine":[{"matchHostname":["host1","host2"],"locked":false}]}' | userdbctl -F -
Segmentation fault         (core dumped)

$ coredumpctl info
...
       Message: Process 1172301 (userdbctl) of user 1000 dumped core.

                Module libz.so.1 from rpm zlib-ng-2.3.3-1.fc43.x86_64
                Module libcrypto.so.3 from rpm openssl-3.5.4-2.fc43.x86_64
                Stack trace of thread 1172301:
                #0  0x00007fded7b3a656 __strcmp_evex (libc.so.6 + 0x159656)
                #1  0x00007fded7e95397 per_machine_hostname_match (libsystemd-shared-260.so + 0x295397)
                #2  0x00007fded7e955b5 per_machine_match (libsystemd-shared-260.so + 0x2955b5)
                #3  0x00007fded7e957c6 dispatch_per_machine (libsystemd-shared-260.so + 0x2957c6)
                #4  0x00007fded7e96c97 user_record_load (libsystemd-shared-260.so + 0x296c97)
                #5  0x000000000040572d display_user (/home/fsumsal/repos/@systemd/systemd/build/userdbctl + 0x572d)
                #6  0x00007fded7ea9727 dispatch_verb (libsystemd-shared-260.so + 0x2a9727)
                #7  0x000000000041077c run (/home/fsumsal/repos/@systemd/systemd/build/userdbctl + 0x1077c)
                #8  0x00000000004107ce main (/home/fsumsal/repos/@systemd/systemd/build/userdbctl + 0x107ce)
                #9  0x00007fded79e45b5 __libc_start_call_main (libc.so.6 + 0x35b5)
                #10 0x00007fded79e4668 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x3668)
                #11 0x00000000004038d5 _start (/home/fsumsal/repos/@systemd/systemd/build/userdbctl + 0x38d5)
                ELF object binary architecture: AMD x86-64
2026-03-06 17:24:53 +01:00
Lennart Poettering dfb1fa0197 sd-varlink: pin error message while we invoke a reply callback
Let's make sure the parameters/error pointers into the message remain
valid as long as the reply callback is running, even if the reply
otherwise resets the pending message.
2026-03-06 14:51:35 +01:00
Yu Watanabe 2f32c49a18 network: slightly reword polkit message 2026-03-06 04:43:30 +09:00
Yu Watanabe 8903e6b5f7 tree-wide: suppress misc-use-internal-linkage warnings
Suppress warnings like the following from clang tidy:
```
../src/boot/addon.c:11:19: error: function 'efi_main' can be made static to enforce internal linkage [misc-use-internal-linkage,-warnings-as-errors]
   11 | EFIAPI EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table);
      |                   ^
```

Some warnings are suppressed simply by setting comments to ignore the warning,
some are by making global variables static, or include a suitable header.
2026-03-05 20:23:24 +01:00
Mike Yuan e65a6e26ad core/varlink-unit: distinguish PIDREF_AUTOMATIC from unset
Follow-up for ab73333c43

Methods that take numeric pid values use 0 to denote the peer,
hence let's log about 0 on PIDREF_AUTOMATIC, -1 if truly unset.
2026-03-06 04:05:28 +09:00
Mike Yuan ae4c3904af boot/pe: remove unneeded parens
Follow-up for f8ed94ea99
2026-03-06 04:05:28 +09:00
Luca Boccassi 88ed85137c libcrypt: also try to dlopen libcrypt.so.1.1
On top of libcrypt.so.2 and libcrypt.so.1, also try libcrypt.so.1.1
as a third fallback. This is used on debian alpha, and it was
reported that it is intended to ship like that, with a different
SONAME than other architectures:

https://packages.debian.org/sid/alpha/libcrypt1/filelist
2026-03-06 04:04:29 +09:00
Fergus Dall d73dc51fbd pcrlock: Record predictions at start of component range
Currently pcrlock won't predict PCR values that would be present at the start
of the requested location range (unless there are no events for that PCR in the
location range). This means predictions for the default range 760:940, which is
intended to start just after entering the initrd, are not actually possible to
fulfill until after the initrd is exited (or possibly even later, depending on
what other events are recorded).

Fix this by recording predictions immediately prior to processing components
after the start point.

Fixes #39946
2026-03-06 04:03:25 +09:00
Mike Yuan df51a04a75 path-util: drop unused paths_check_timestamp() 2026-03-06 02:39:39 +09:00
Hans de Goede f8ed94ea99 boot: Make missing CHID DTB match a debug message instead of an error
With distributions like Ubuntu and Fedora using systemd-stub to auto load
DTB's on Windows on ARM laptops, the CHID DTB match failing is expected
when that same UKI is instead booted on an ARM SystemReady system where
no DTB is necessary.

In the ARM SystemReady case showing a big red error message is undesirable
and leads to confused users and bug-reports. Lower the message to debug
level when the status is EFI_NOT_FOUND to avoid these false positive error
messages.

Link: https://bugzilla.redhat.com/show_bug.cgi?id=2444759
2026-03-05 18:29:16 +01:00
Mike Yuan 909108163f tree-wide: various Coccinelle-suggested tweaks and related fixes (#40950) 2026-03-05 17:07:39 +01:00
Michal Sekletar 0c98e432d1 core: cleanup unit's dropin directories from global cache
When user creates dropin files via API (e.g. systemctl set-property ...)
we put the dropin directory path into unit_path_cache. Drop those
directories from the cache in unit_free() and prevent memory leak.

Follow-up for fce94c5c56.
2026-03-05 16:50:25 +01:00
Frantisek Sumsal ab73333c43 core: drop unused errno from debug message
And properly guard unset parameters.
2026-03-05 10:27:59 +01:00
Frantisek Sumsal 90f5d2a202 tree-wide: various fixlets suggested by Coccinelle 2026-03-05 10:27:58 +01:00
Frantisek Sumsal a8335fb91f tree-wide: use typed SD_JSON_BUILD_PAIR_* macros more 2026-03-05 10:27:58 +01:00
Mike Yuan ab7d40ff0c machine-varlink: reference the right struct in VARLINK_DISPATCH_MACHINE_LOOKUP_FIELDS
This practically shouldn't matter, as the layout for name
and pidref fields are identical for all the structs. But
let's get things right.
2026-03-05 08:56:34 +01:00
Mike Yuan 568dbbd5a9 journalctl-filter: drop doubled newline
Follow-up for d8302c2fd9
2026-03-05 01:01:33 +01:00
Lennart Poettering 35742907a7 pcrextend-util: fix log message
The NvPCR is actually named differently from what the log msg said. Fix it.
2026-03-04 15:28:06 +00:00
Mike Yuan e8c542981b machine-dbus: do not check for overlapping condition
Follow-up for c5e48e3a66

This also makes things in line with the varlink method.
2026-03-04 14:32:46 +01:00
Mike Yuan f1f38e2fc1 sd-journal/catalog: make catalog_file_dirs static 2026-03-04 14:32:17 +01:00
Mike Yuan ae558ebd42 bpf-dlopen: mark bpf_get_error() as static
Any use of this function should go via bpf_get_error_translated().
2026-03-04 14:32:17 +01:00
Mike Yuan 2853e4cb1c shared/password-quality-util-*: make dl functions static 2026-03-04 14:32:16 +01:00
Mike Yuan a521abbf27 machined: move declaration of manager_object to machined-dbus.h 2026-03-04 14:32:16 +01:00
Mike Yuan 08e4cf491a various: make bus objects static 2026-03-04 14:32:16 +01:00
Mike Yuan 5aeda638bb core/varlink-metrics: make metric_family_table static 2026-03-04 14:32:16 +01:00