Commit Graph

84158 Commits

Author SHA1 Message Date
Marien Zwart
1599b6fbe2 docs: fix conversion / calculation errors
0x1770 is 6000, not 60000. It looks like 60000 is intended (the next
range starts at 60000 in both decimal and hex), so use that.

1000 to 60000 is 59001 users, as the range is inclusive on both sides.
Similar off-by-one for one of the "unused" ranges. After these changes,
the sizes of the ranges up to and including the "-1" ID sum up to 65536,
as expected.

I'm not sure where the size of the unused range after the container UID
range came from, but it is not correct (the "Container UID" and this
reserved range combined would be larger than the "HIC SVNT LEONES" 2^31
to 2^32-2 range...). Fix it.

It is unfortunate that the first half of this table makes more sense in
decimal while the second half makes more sense in hex (which would also
make the size in 65536 chunks easy to obtain): I'm tempted to add a
"sizes in hex" column...
2025-10-20 10:36:08 +09:00
Luca Boccassi
d29f181cf0 ci: add bpftool workaround to coverity too 2025-10-18 15:43:06 +01:00
Yu Watanabe
a6836cfa0b ci: fix workaround about bpftool for codeql
Follow-up for e9fd2bbfff.
2025-10-18 09:10:35 +02:00
Luca Boccassi
5ee8ffb5c5 Assorted coverity fixes (#39355) 2025-10-17 20:30:09 +01:00
Luca Boccassi
dc567bc406 mkosi: install new knot-keymgr in Fedora rawhide
52aa1c6b27

TEST-75-RESOLVED.sh[116]: + keymgr . generate algorithm=ECDSAP256SHA256 ksk=yes zsk=yes
TEST-75-RESOLVED.sh[454]: /usr/lib/systemd/tests/testdata/units/TEST-75-RESOLVED.sh: line 153: keymgr: command not found
2025-10-17 18:35:29 +01:00
Luca Boccassi
b62c681b11 log: add underflow assert guard
We often use ssize_t in log_error macros, but typically return int
which confuses coverity, as technically there is no guarantee that
int and ssize_t have the same range. Add an assert to enforce it.
2025-10-18 01:11:49 +09:00
Luca Boccassi
e9fd2bbfff ci: add bpftool workaround to codeql job too 2025-10-18 01:11:11 +09:00
Luca Boccassi
d0a066a1a4 test: avoid divide-by-zero coverity warning
CID#1587762
2025-10-17 16:44:15 +01:00
Luca Boccassi
8112069be0 bpf: do not leak dlopen object
CID#1609833
2025-10-17 16:44:15 +01:00
Luca Boccassi
05d45875f7 efivars: fix potential memory leak
If 'ret' is not passed, 'x' is leaked

Follow-up for c8d60ae79d

CID#1621673
2025-10-17 16:44:15 +01:00
Luca Boccassi
8240a0942b blockdev-list: add overflow check assert
Fixes coverity warning

CID#1630794
2025-10-17 16:44:15 +01:00
Luca Boccassi
d275410086 dissect: drop leftover assert
This was refactored, and the assert is now wrongly placed. Drop
it to fix coverity warning.

Follow-up for dfdeb0b1cb

CID#1639975
2025-10-17 16:42:24 +01:00
Luca Boccassi
3b11139c0d ci: re-enable bpf-framework option for build and unit test jobs
Use the same trickery we do in the package build and search for
the actual bpftool binary. For the CI job any one we find is
good enough.
When we switch all jobs to 26.04 we can drop all of this.

This reverts commit cc814110af.
2025-10-17 15:08:54 +01:00
Frantisek Sumsal
1ec5d43a0e test: let kernel OOM-kill a child process instead of the main one
This test occasionally fails due to a race where systemd processes
kernel's SIGKILL before the OOM notification, so the test service dies
with Result=signal instead of the expected Result=oom-kill:

[   51.008765] TEST-55-OOMD.sh[906]: + systemd-run --wait --unit oom-kill -p OOMPolicy=kill -p Delegate=yes -p DelegateSubgroup=init.scope /tmp/script.sh
[   51.048747] TEST-55-OOMD.sh[907]: Running as unit: oom-kill.service; invocation ID: 456645347d554ea2878463404b181bd8
[   51.066296] sysrq: Manual OOM execution
[   51.066596] kworker/1:0 invoked oom-killer: gfp_mask=0xcc0(GFP_KERNEL), order=-1, oom_score_adj=0
[   51.066915] CPU: 1 UID: 0 PID: 27 Comm: kworker/1:0 Not tainted 6.17.1-arch1-1 #1 PREEMPT(full)  d2b229857b2eb4001337041f41d3c4f131433540
[   51.066919] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Arch Linux 1.17.0-2-2 04/01/2014
[   51.066921] Workqueue: events moom_callback
[   51.066928] Call Trace:
[   51.066931]  <TASK>
[   51.066936]  dump_stack_lvl+0x5d/0x80
[   51.066942]  dump_header+0x43/0x1aa
<...snip...>
[   51.087814] 47583 pages reserved
[   51.087969] 0 pages cma reserved
[   51.088208] 0 pages hwpoisoned
[   51.088519] Out of memory: Killed process 908 (sleep) total-vm:3264kB, anon-rss:256kB, file-rss:1916kB, shmem-rss:0kB, UID:0 pgtables:44kB oom_score_adj:1000
[   51.090263] TEST-55-OOMD.sh[907]:           Finished with result: signal
[   51.094416] TEST-55-OOMD.sh[907]: Main processes terminated with: code=killed, status=9/KILL
[   51.094898] TEST-55-OOMD.sh[907]:                Service runtime: 58ms
[   51.095436] TEST-55-OOMD.sh[907]:              CPU time consumed: 22ms
[   51.095854] TEST-55-OOMD.sh[907]:                    Memory peak: 1.6M (swap: 0B)
[   51.096722] TEST-55-OOMD.sh[912]: ++ systemctl show oom-kill -P Result
[   51.106549] TEST-55-OOMD.sh[879]: + assert_eq signal oom-kill
[   51.107394] TEST-55-OOMD.sh[913]: + set +ex
[   51.108256] TEST-55-OOMD.sh[913]: FAIL: expected: 'oom-kill' actual: 'signal'
[FAILED] Failed to start TEST-55-OOMD.service.

To mitigate this, let's spawn a child process and move it to the
subcgroup to get killed instead of the main process, so systemd has more
time to react to the OOM notification and terminate the service with the
expected oom-kill result.
2025-10-17 15:19:16 +02:00
Daan De Meyer
b8ee7c2206 tree-wide: Various forward header cleanups
- Make sure forward headers have the iwyu pragma to always keep them
- Make sure we always include the daemon specific forward header
  instead of shared-forward.h
- Remove shared-forward.h include where the daemon specific forward
  header is already included
2025-10-17 21:11:23 +09:00
Daan De Meyer
cc814110af ci: Disable bpf-framework option for build and unit test jobs
/usr/sbin/bpftool is completely broken inside containers on
Ubuntu which makes meson blow up so disable the bpf-framework
stuff to avoid the issue.

TODO: Drop when we move off Ubuntu Noble as this will be fixed
in the next Ubuntu LTS release.
2025-10-17 21:11:23 +09:00
Mike Yuan
28aa0a1f25 core/mount: properly handle REMOUNTING_* states in mount_stop() (#39269) 2025-10-16 20:50:03 +02:00
Matteo Croce
e1e16b4763 core: fix build error due to merge conflict in varlink-execute.h
During last refactor, an include wasn't changed and led to a build
error.

Follow-up for fdb2c0dd6f
2025-10-16 19:47:40 +01:00
Luca Boccassi
c92b14ec13 dissect: add support for verity-protected bare filesystems via mountfsd (#39325)
Needed to implement support for RootHashSignature=/RootVerity=/RootHash=
and friends when going through mountfsd, for example with user units,
so that system and user units provide the same features at the same
level
2025-10-16 19:43:45 +01:00
Zbigniew Jędrzejewski-Szmek
48aec295a8 test/parse_hwdb: wrap Or inside an And in a Group
I now get a warning like this with python3-pyparsing-3.1.2-8.fc42:

hwdb.d/parse_hwdb.py:208: UserWarning: warn_multiple_tokens_in_named_alternation:
  setting results name 'VALUE' on Or expression will return a list of all parsed
  tokens in an And alternative, in prior versions only the first token was returned;
  enclose contained argument in Group
('!' ^ (Optional('!') - Word(alphanums + '_')))('VALUE')
2025-10-16 18:09:37 +01:00
Daan De Meyer
06d73c5046 implement ExecContext for io.systemd.Unit.List (#38212) 2025-10-16 19:06:46 +02:00
Lennart Poettering
b0c6d129a5 two small varlink additions (#39323)
Split out of #39293, but make a ton of sense on their own.
2025-10-16 17:42:57 +02:00
Lennart Poettering
0aad728daa kmod-setup: don't load unix.ko as a module anymore
Building unix.ko as a module always has been a really bad idea, from day
1. Debian used to do this, but has long been fixed. Kernel developers
saw the light too, and removed support for it in 6.5
(97154bcf4d1b7cabefec8a72cff5fbb91d5afb7b). Let's hence drop support for
this here too, and delete some old cruft. AF_UNIX is simply our most
basic IPC system and supporting systems without it being around is just
not realistic.
2025-10-16 17:42:33 +02:00
Luca Boccassi
bc019f7c06 test: add coverage for image policy and bare filesystems with verity 2025-10-16 16:22:33 +01:00
Luca Boccassi
fad01f798d dissect: add support for verity-protected bare filesystems via mountfsd
Needed to implement support for RootHashSignature=/RootVerity=/RootHash=
and friends when going through mountfsd, for example with user units,
so that system and user units provide the same features at the same
level
2025-10-16 16:22:33 +01:00
Luca Boccassi
674b4b4f96 mountfsd: add support for verity-protected bare filesystems
Add optional varlink parameters to pass in verity data/roothash/sig
2025-10-16 16:22:33 +01:00
Luca Boccassi
26bf1b9e85 json: add json_dispatch_unhex_iovec helper 2025-10-16 16:22:33 +01:00
Govind Venugopal
48c64813ec varlink: omit empty parameters field in JSON messages (#38922)
When varlink parameters are empty, omit the "parameters" field entirely
rather than sending "parameters":{}. This reduces message size and
follows varlink specification which allows parameters to be omitted.

The implementation supports three equivalent representations for empty
parameters: field omission, JSON null, and empty object {}. All three
are accepted on input for backward compatibility.

Fixes: #38474
2025-10-16 17:06:17 +02:00
Daan De Meyer
f102bc3e5f tree-wide: Introduce sd-forward.h and shared-forward.h headers
Let's not leak details from src/shared and src/libsystemd into
src/basic, even though you can't actually do anything useful with
just forward declarations from src/shared.

The sd-forward.h header is put in src/libsystemd/sd-common as we
don't have a directory for shared internal headers for libsystemd
yet.

Let's also rename forward.h to basic-forward.h to keep things
self-explanatory.
2025-10-16 17:00:29 +02:00
Luca Boccassi
5e97d50e17 dissect: fix image policy check for bare dm-verity filesystem
The root_hash_sig pointer might be set, but to an empty iovec. Check
that the length is > 0 instead.

Follow-up for cd22d8562d
2025-10-16 15:50:45 +01:00
Luca Boccassi
39175477bd mkosi: provide detached verity signatures too for minimal images
Useful for manual testing in the VM
2025-10-16 15:50:45 +01:00
Luca Boccassi
ac9391c552 Support ExtensionImages=/MountImages= in user services via mountfsd and PrivateUsers=yes (#39341) 2025-10-16 15:49:46 +01:00
Lennart Poettering
78a135f567 varlink: move definition of varlink_hash_ops into common code
This is truly useful whenever we have to deal with multiple varlink
connections.
2025-10-16 16:24:29 +02:00
Lennart Poettering
73740ca2fc sd-varlink: add sd_varlink_is_connected() 2025-10-16 16:24:29 +02:00
Luca Boccassi
68b476a298 core: also enable PrivateUsers= for user services when using images via mountfsd
RootDirectory= and other options already implicitly enable PrivateUsers=
since 6ef721cbc7 if they are set in user
units, so that they can work out of the box.
Now with mountfsd support we can do the same for the images settings,
so enable them and document them.
2025-10-16 12:58:59 +01:00
Luca Boccassi
29e97643e7 Support ExtensionImages=/MountImages= in user services via mountfsd
Support for RootImage= was added by 046a1487db
but it was not wired in for ExtensionImages=/MountImages=
2025-10-16 12:58:59 +01:00
Luca Boccassi
1ebbb0b0f4 test: add coverage for RootImage= in user units
Follow-up for 046a1487db
2025-10-16 12:58:55 +01:00
Daan De Meyer
f875a8026e core: Don't use TTYPath= for PAM unless StandardInput=tty
Fixes #39334
2025-10-16 13:46:19 +02:00
Zbigniew Jędrzejewski-Szmek
6c80ab85f5 core/cgroup: two follow-ups for recent OOMKills PR (#39215)
Follow-ups for #38906.
2025-10-16 13:38:01 +02:00
Ivan Kruglov
55eccf3b0d core: add comments in varlink-io.systemd.Unit.c 2025-10-16 03:52:08 -07:00
Ivan Kruglov
fdb2c0dd6f core: ExecContext for io.systemd.Unit.List method 2025-10-16 03:52:08 -07:00
Ivan Kruglov
3064c04473 core: exec_log_level_max_with_exec_params() 2025-10-16 03:52:08 -07:00
Ivan Kruglov
fbfc439438 core: move cpuset_build_json() to varlink-common 2025-10-16 03:52:02 -07:00
Frantisek Sumsal
92631f1962 test: wait for signed.test's zone DS records to get pushed to the parent zone
It looks like the 4 second sleep might not be enough on some slower
machines (like the ARM GH Actions nodes) which can lead to the DS RRs
propagation to clash with the manual test zone edit, and the
signed.test zone then might end up not properly signed:

TEST-75-RESOLVED.sh[749]: + : '--- ZONE: signed.test (static DNSSEC) ---'
TEST-75-RESOLVED.sh[749]: + run_delv @ns1.unsigned.test signed.test
TEST-75-RESOLVED.sh[749]: + run delv -a /etc/bind.keys @ns1.unsigned.test signed.test
TEST-75-RESOLVED.sh[778]: + delv -a /etc/bind.keys @ns1.unsigned.test signed.test
TEST-75-RESOLVED.sh[779]: + tee /tmp/tmp.2KOIiyrgth
TEST-75-RESOLVED.sh[779]: ;; /etc/bind.keys:1: option 'managed-keys' is deprecated
TEST-75-RESOLVED.sh[779]: ;; validating signed.test/DS: no valid signature found
TEST-75-RESOLVED.sh[779]: ;; validating signed.test/A: no valid signature found
TEST-75-RESOLVED.sh[779]: ; unsigned answer
TEST-75-RESOLVED.sh[779]: signed.test.		86400	IN	A	10.0.0.10
TEST-75-RESOLVED.sh[779]: signed.test.		86400	IN	RRSIG	A 13 2 86400 20251028114356 20251014101356 39330 signed.test. oo3ca8WPusbBPRhzsEKw3bsBBqFtI8i4bckoMVNzt7lY+udGW6PlaSYj OjpQGgY9oglowVM9bteNtwJKHUbvtw==
TEST-75-RESOLVED.sh[749]: + grep -qF '; fully validated' /tmp/tmp.2KOIiyrgth
[FAILED] Failed to start TEST-75-RESOLVED.service - TEST-75-RESOLVED.

Let's explicitly wait for the DS records propagation to finish before we
start editing the test zone to avoid this.

I'm still not completely sure if this is the root cause, but it's the
best shot I currently have, so I'll let the CIs decide.
2025-10-16 11:51:03 +01:00
Antonio Alvarez Feijoo
b8ad88a407 meson: fix HAVE_LIBARCHIVE_* conditions
Follow-up for a7c8f92d1f
2025-10-16 11:48:53 +01:00
Ivan Kruglov
3de607b48b basic: secure_bits_to_strv() 2025-10-16 03:29:14 -07:00
Ivan Kruglov
115083886a nsflags: namespace_flags_to_strv() 2025-10-16 03:26:39 -07:00
Zbigniew Jędrzejewski-Szmek
f0562fc819 test: minor fixlets for TEST-50-DISSECT (#39328) 2025-10-16 12:25:41 +02:00
Daan De Meyer
73623f1984 core: Make sure we don't clobber return argument on failure
As documented in the coding style, let's make sure we follow it.
2025-10-16 11:06:43 +01:00
Daan De Meyer
e8a0463c16 test: fixes for debian unstable and TEST-50-DISSECT (#39331)
Test failed in a weird way, turns out we don't use pipefail and an
intermediate command was moved to a different package so it wasn't in
the minimal image anymore. Add it, and use pipefail so in the future
it's easier to spot.
2025-10-16 08:45:46 +02:00