Commit Graph
80391 Commits
Author SHA1 Message Date
Mike Yuan 0a7d86d53d units/systemd-validatefs@.service: FailureAction= is a [Unit] knob 2025-03-31 19:23:51 +02:00
Mike Yuan 28bae3dbe3 man/systemd-validatefs@.service: fix typo 2025-03-31 19:23:50 +02:00
Mike Yuan f361fad245 validatefs: use fgetxattr_malloc() where appropriate 2025-03-31 19:23:50 +02:00
Mike Yuan 8950f7651e validatefs: do not use EXIT_* in run()
The plain DEFINE_MAIN_FUNCTION is used, i.e. all >= 0 retvals
are treated as success. No need for EXIT_* annotations.
2025-03-31 19:23:50 +02:00
Mike Yuan 7b8d6fc836 validatefs: insert empty line after short description in help() text
As per our usual coding style.
2025-03-31 19:23:50 +02:00
Mike Yuan 05587cece5 xattr-util: add missing assertions
Follow-up for ed024abac6
and 9fbe26cfa8

Also, let's not get too tangled up in the style of defining variables
in between. The functions are short enough, and vars involved are still
effectively at the beginning... Put differently, the separation from
'int r' is too deliberate and brings no actual value in my eyes.
2025-03-31 19:23:49 +02:00
Luca Boccassi ebc0514a65 test: pass verbose option to nvme-cli
When the test fails due to nvme-cli/kernel issues it's hard to report it
upstream as there's not enough details, add verbose flags
2025-03-31 17:22:30 +01:00
Yu Watanabe 30252c0ca4 introduce systemd-validatefs@.service that ensures file systems can only be used in the way they were intended (#36714)
If we have multiple trusted fs (i.e. luks or dm-verity) we generate via
repart at boot, we must make sure they cannot be "misappropriated", i.e.
used for a different mount they were intended for.

Hence, let's introduce "mount constraint" data (encoded in xattrs on the
root inode of the fs) that tells us where a file system has to be
mounted, and what the gpt partition metadata has to be for the fs to be
valid.

Inspired by this thread:
https://lists.freedesktop.org/archives/systemd-devel/2025-March/051244.html
2025-04-01 01:14:33 +09:00
Yu Watanabe 7e0f0d702d Several updates for socket option (#36905) 2025-04-01 01:09:04 +09:00
Yu Watanabe c7464843ad tree-wide: extend the comment about the issue in __convert_scm_timestamps() 2025-03-31 23:22:38 +09:00
Yu Watanabe 566b8f4d46 core/manager: update comment 2025-03-31 23:22:38 +09:00
Yu Watanabe 385024b75d README: fix version of SO_BINDTOIFINDEX
Follow-up for 33746caf8f.
2025-03-31 23:22:38 +09:00
Yu Watanabe 4216018807 missing_socket: drop unnecessary definitions and update comments
- SO_PEERGROUPS is since kernel v4.13
  (28b5ba2aa0f55d80adb2624564ed2b170c19519e),
- SO_BINDTOIFINDEX is since kernel v5.1
  (f5dd3d0c9638a9d9a02b5964c4ad636f06cf7e2c).
2025-03-31 23:22:12 +09:00
Lennart Poettering 681e7c6759 update TODO 2025-03-31 15:14:56 +02:00
Lennart Poettering 6e003d18bb ci: add test for new validatefs work 2025-03-31 15:14:53 +02:00
Lennart Poettering 84b41ef082 ci: add -no-xattrs to unsquashfs cmdline
If the target dir is tmpfs and we run on old kernels we cannot extract
xattrs and the extracting will fail if there are any. hence add
-no-xattrs to the two remaining unsquashfs invocations that don't have
it.

(Also all other invocations across our test tree spell "-dest" instead
of "-d", hence do so here too.)
2025-03-31 15:14:50 +02:00
Lennart Poettering 85afe4760b repart: automatically generate validatefs xattrs
Let's automatically generate validatefs xattrs by default, that encode
the intended use of partitions.

This defaults to on, since the structure of repart definition files
tells us enough on use for this to be safe. There's an option however,
to turn this off.
2025-03-31 15:14:45 +02:00
Lennart Poettering f872373a26 generators: hook in validatefs on gpt-auto and fstab generator mounts
Let's turn on validatefs automatically for all auto-discovered
partitions.

Let's add an x-systemd.validatefs option to optionally turn this on for
fstab listed file systems.
2025-03-31 15:14:28 +02:00
Lennart Poettering 0bdd5ccc81 validatefs: add new tool that enforces mount constraints
This new tool looks for a three xattr on the root inode of a file system
that encode mount constraints of the file system. The tool is supposed
to be hooke into the mount logic and is supposed to protect against
misappropriating trusted file systems in unintended ways.

Consider the following scenario: we boot up on first boot and create a
tpm-locked pair of /var/ and /srv/ partitions via systemd-repart. An
attacker then offline modifies the partition table, exchanging the
metadata of the /var/ and /srv/ partition. So far we'd happily accept
that, honour the modified metadata and boot up. This could be used to
revert changes to /var/ or similar. And all that even though both
partitions are encrypted and locked to TPM!

With this new mechanism we can encode in the protected contents of the
file systems the ways it can be used: the partition type uuid, the
partition label and the intended mount point can be stored in xattrs,
and we can check them automatically on mount, and take action on
mismatch. (action would typically be immediate reboot).
2025-03-31 15:14:13 +02:00
Lennart Poettering 9fbe26cfa8 xattr-util: add trivial xsetxattr_strv() wrapper 2025-03-31 15:13:55 +02:00
Lennart Poettering ed024abac6 xattr-util: add trivial getxattr_at_strv() helper 2025-03-31 15:13:28 +02:00
Luca Boccassi 33746caf8f README: note min kernerl version for SO_BINDTOIFINDEX
Prompted by https://github.com/systemd/systemd/pull/36893
2025-03-31 14:06:57 +01:00
Yu Watanabe 072ebe3ece watchdog: fix typo
Follow-up for ab596e4cde.
2025-03-31 21:27:00 +09:00
Yu Watanabe b457af42e5 Log message improvements (#35237)
Various improvements to log messages. Inspired by
https://bugzilla.redhat.com/show_bug.cgi?id=2327296.
2025-03-31 21:23:23 +09:00
Yu Watanabe 5578f8e974 homed: move things over to quotactl_fd() (#36902)
Let's use quotactl_fd() wherever we can, it's 2025. quotactl() is such a
mess after all.
2025-03-31 21:15:03 +09:00
Lennart Poettering 8b21bbd6f0 pcrextend: whenever we fail to extend PCRs, reboot immediately
PCR extensions are supposed to be useful for "destroying" the ability to
access TPM bound secrets. Hence, if for some reason we fail to extend a
PCR, it's safer to just reboot, instead of going on without the
extension, leaving secrets potentially accessible which should not be
accessible.

Note that the services exit gracefully if no TPM is found, hence this
should not be triggered on TPM-less systems. However, this enforces that
if there is a TPM that is accessible to Linux and that works properly,
the PCR measurement must complete too.

Inspired by this thread:

https://lists.freedesktop.org/archives/systemd-devel/2025-March/051244.html
2025-03-31 21:13:33 +09:00
Busayo Dada 1220625a81 socket-proxy: add syntax highlighting to help output 2025-03-31 21:09:14 +09:00
Lennart Poettering 521b6bb117 homed: don't log error we don't have 2025-03-31 11:51:38 +02:00
Lennart Poettering 5daca30b0f homed: always use quotactl_fd() if its available
Let's always prefer quotactl_fd() when it's available and use quotactl()
only as as a fallback on old kernels.

This way we can operate on the fds we typically already have open, or if
needed we can open a new one, and use for multiple fs operation.

In the long run we should really focus on operating exclusively by fd
instead of by path, by device nor or otherwise. This gets us a step
closer to that.
2025-03-31 11:51:15 +02:00
Luca Boccassi da24983526 test: skip networkd tests if networkd/resolved are disabled at build time 2025-03-30 10:18:18 +02:00
Luca Boccassi 75b16ac59e test: skip TEST-75-RESOLVED if resolved is disabled at build time 2025-03-30 10:18:18 +02:00
Mike Yuan 6b4a05519b sd-bus/bus-common-errors: add missing error map entries 2025-03-29 19:51:13 +01:00
Luca Boccassi fce07bcb7a meson: add feature flag for nspawn build (#36876)
Other tools have it, nspawn doesn't, add one
2025-03-28 13:55:19 +00:00
Luca Boccassi 6561d02ee1 mkosi: Use build image prepare scripts for tools tree as well (#36861)
Instead of listing dependencies manually for the default tools tree,
let's reuse the prepare scripts from the build image. To make this work,
the sync script has to be configured for the tools tree as well so that
it's invoked both when building the tools tree and for the regular
image,
otherwise, when doing the first build in a fresh checkout, the sync
script
won't have executed yet as sync scripts for the regular images are
executed
after building the default tools tree.
2025-03-28 13:31:28 +00:00
Daan De Meyer 848b5ae0d1 test: Drop --no-rebuild from meson test invocations
With meson 1.7.0, meson won't rebuild the world anymore when running
meson test so since meson 1.7.0 is in tumbleweed, debian testing, fedora
rawhide and Arch Linux, drop --no-rebuild from the docs since all the default
tools trees built by mkosi in the systemd repo will have meson 1.7.0 or newer
installed.

We keep --no-rebuild in CI because in CI we run with the same tools tree
distribution as the target distribution we're building and in those it's not
guaranteed for meson 1.7.0 to be available yet.

The advantage of dropping --no-rebuild is that meson will now reconfigure itself
if needed, which is required if we change or move around meson files, as otherwise
meson tends to explode spectacularly in hard to debug ways.

https://mesonbuild.com/Release-notes-for-1-7-0.html#test-targets-no-longer-built-by-default
2025-03-28 13:02:20 +01:00
Daan De Meyer 1b49fb9aaa mkosi: Use build image prepare scripts for tools tree as well
Instead of listing dependencies manually for the default tools tree,
let's reuse the prepare scripts from the build image. To make this work,
the sync script has to be configured for the tools tree as well so that
it's invoked both when building the tools tree and for the regular image,
otherwise, when doing the first build in a fresh checkout, the sync script
won't have executed yet as sync scripts for the regular images are executed
after building the default tools tree.
2025-03-28 12:29:09 +01:00
Daan De Meyer e7df838a07 test: Use /dev/shm for TEST_JOURNAL_USE_TMP if /tmp isn't tmpfs
If /dev/shm is a tmpfs and /tmp isn't, use /dev/shm instead.
2025-03-28 11:40:39 +01:00
Daan De Meyer 29a1e7df64 test: Mark tests as skipped if requirements were not satisfied
Instead of not creating the test at all, let's always create test but
simply mark them as skipped as this is more observable than simply not
creating the test at all.
2025-03-28 11:40:39 +01:00
Daan De Meyer c2d2b382b6 TEST-06-SELINUX: Only enable if meson was invoked as root
This test only works if the image was built as root. Since that's
impossible to check as meson generally runs before we build the image,
let's use whether meson is run as root as a proxy.
2025-03-28 11:40:39 +01:00
Daan De Meyer 51b4920746 test: Boot integration test VMs without an initrd if possible
If we don't need an initrd, let's not waste time in one. We have to
gate this by distributions that have the necessary kernel modules to
make this work as builtin modules, hopefully we can expand the list in
the future.
2025-03-28 11:40:39 +01:00
Daan De Meyer c4fcd6ea78 mkosi: Bump minimum version to 25~devel 2025-03-28 11:40:39 +01:00
Luca Boccassi 980aced10b test: always install test-resolve subdir
Content is also used by unit tests, not just resolved tests,
so they are needed even when resolved is disabled, as unit
tests are still built and run
2025-03-28 10:34:02 +00:00
Luca Boccassi d95818f522 meson: add feature flag for nspawn build
Other tools have it, nspawn doesn't, add one
2025-03-28 10:34:02 +00:00
Daan De Meyer 858e59c82c mkosi: Mark /etc /var as updated in a finalize script
Let's make sure we don't run ldconfig.service and other services
again on first boot.
2025-03-28 09:49:17 +01:00
Daan De Meyer d3ae14bd2f mkosi: Disable various extra things in the default preset 2025-03-28 09:49:17 +01:00
Daan De Meyer eeb43426de mkosi: Remove debian/ubuntu pinning
mkosi does this natively now.
2025-03-28 09:49:17 +01:00
Daan De Meyer ddc2234f4a mkosi: Update to latest 2025-03-28 09:49:15 +01:00
Allison Karlitskaya f32962d758 test/README.md: mention mkosi genkey
This is a required first step before testing and it's not specifically
mentioned in the doc.  This tripped me up for a while, so let's save the
trouble for the next person.
2025-03-28 09:42:51 +01:00
Luca Boccassi 3f8431d038 mkosi: update fedora commit reference (#36875)
* 617952132d Run integration testsuite standalone if available
2025-03-28 02:06:06 +00:00
Daan De Meyer 803e2e24df mkosi: update fedora commit reference
* 617952132d Run integration testsuite standalone if available
2025-03-27 22:49:26 +01:00