Commit Graph

79608 Commits

Author SHA1 Message Date
Yu Watanabe
1930f5afe6 fuzz: decompress_startswith() may return zero (#36490)
Also, disables fuzz-compress on oss-fuzz.
Fixes #36472.
2025-02-25 11:05:06 +09:00
Luca Boccassi
323213cfea repart: when using erofs and log level is not debug, use --quiet
mkfs.erofs is extremely verbose and will log every single file added
to the filesystem, which is a lot of them when building a rootfs.
2025-02-24 14:55:25 +00:00
Dan Streetman
af69ea714d systemd-keyutil: add verb to conver PKCS#1 to PKCS#7
Add verb that takes a PKCS#1 signature (plain rsa) as input and a
certificates, and outputs a PKCS#7 binary detached signature (p7s),
which is what the kernel dm-verity driver expects.

Co-authored-by: Luca Boccassi <bluca@debian.org>
2025-02-23 14:14:09 +00:00
Daan De Meyer
012fd82d43 fstab-util: port use of setmntent() and friends to libmount (#36489) 2025-02-23 12:21:19 +01:00
Mike Yuan
19e1a908b5 sd-event: pidfdize sd_event_source_send_child_signal()
Follow-up for c6cc7efcd3

The documentation has been updated, but apparently I forgot
to update the function itself...

Also, actually pass flags to pidfd_send_signal(). Previously
it was spuriously ignored.
2025-02-23 12:16:58 +01:00
Yu Watanabe
0656b3a083 fuzz: tentatively disable fuzz-compress on oss-fuzz
It does not work on oss-fuzz for some reasons. See #11018.
2025-02-23 05:37:05 +09:00
Yu Watanabe
339f2f2eeb fuzz: decompress_startswith() may return zero
Fixes #36472.
2025-02-23 05:04:49 +09:00
Yu Watanabe
8e0037fb3b sd-event: always operate on child source via pidfd (#36480) 2025-02-23 04:41:28 +09:00
Mike Yuan
58bf70f925 fstab-util: port use of setmntent() and friends to libmount 2025-02-22 19:26:49 +01:00
Mike Yuan
87f7adb8a6 libmount-util: introduce libmount_parse_fstab() wrapper 2025-02-22 19:26:48 +01:00
Mike Yuan
2f3d986053 fstab-util: join 'filtered' only if requested by caller 2025-02-22 19:26:48 +01:00
Daan De Meyer
66584a9335 sbsign: Don't set bit in SpcPeImageData->flags
Neither sbsign nor pesign set this flag in SpcPeImageData->flags,
which is about which resources should be included specifying "Which
portions of the Windows PE file are hashed." according to the
authenticode spec. However, this is followed by "Although flags is
always present, it is ignored when calculating the file hash for both
signing and verification purposes". So as it doesn't seem to do
anything useful and the other tools don't set any of these flags
either, let's follow suite and not set this flag ourselves either.
2025-02-22 01:05:25 +01:00
KidGrimes
81cb404a92 hwdb: add axis range corrections for the Lenovo Yoga Slim 7 14ARE05 2025-02-21 22:44:17 +00:00
Luca Boccassi
44e62bc62b mkosi: add libapparmor1 to package list for opensuse
TEST-02-UNITTESTS.sh[4381]: [ 2329.636166] test-dlopen-so[650]: libapparmor.so.1 is not installed: libapparmor.so.1: cannot open shared object file: No such file or directory
TEST-02-UNITTESTS.sh[4381]: [ 2329.636174] test-dlopen-so[650]: Assertion 'dlopen_libapparmor() >= 0' failed at src/test/test-dlopen-so.c:103, function run(). Aborting.

Follow-up for 384949f7de
2025-02-21 22:35:44 +00:00
Luca Boccassi
dad055ee52 Coding style followups (#36476) 2025-02-21 21:58:54 +00:00
Mike Yuan
3ddbc34e15 process-util: refuse FORK_WAIT + FORK_FREEZE combination 2025-02-21 21:35:05 +00:00
Mike Yuan
c6cc7efcd3 sd-event: always operate on child source via pidfd
Follow-up for 6e14c46bac

Nowadays a pidfd is guarenteed to be around for child
event sources, hence drop the effectively unused pid-based
branches.

Addresses https://github.com/systemd/systemd/pull/36410#discussion_r1959930716
2025-02-21 18:08:55 +01:00
Mike Yuan
4f63673482 sd-event: assert on hashmap_remove(child.pid)
Follow-up for 54988a27b9
and a342c71d36
2025-02-21 18:08:02 +01:00
Mike Yuan
37149e692a process-util: introduce SIGINFO_CODE_IS_DEAD helper 2025-02-21 18:08:02 +01:00
Lin Jian
7593173c94 docs/CONTROL_GROUP_INTERFACE: fix typo 2025-02-21 16:51:49 +00:00
Mike Yuan
db3e0393ea udev-builtin-blkid: merge var definitions, fix grammar
Follow-up for f8825c1364
2025-02-21 16:12:59 +01:00
Mike Yuan
012658fc85 basic/utf8: add missing assertion
Follow-up for 104a6b8c39
2025-02-21 16:12:59 +01:00
Mike Yuan
3ab19c1f0a basic/strv: minor coding style follow-ups
Follow-up for 428146dc89

Addresses https://github.com/systemd/systemd/pull/36271#discussion_r1958334800
2025-02-21 16:12:59 +01:00
Mike Yuan
384949f7de core: dlopen()'ify libapparmor
In Arch Linux we currently have a half-baked apparmor support,
in particular we cannot link systemd to libapparmor for service
context integration, since that will pull apparmor into base system.
Hence, let's turn this into a dlopen dep.

Ref: https://gitlab.archlinux.org/archlinux/packaging/packages/systemd/-/issues/22
2025-02-21 14:22:51 +01:00
Lennart Poettering
4a2f437790 Support booting from rootfs acquired via HTTP (#36314)
This extends systemd-import-generator to not only download a disk image
at boot, but also attach it to a loopback device, so that we can boot
from it.

We have most of the pieces already in place, this just polishes some
things, to make this round.

The topmost commit contains example command lines that just work to make
`systemd-vmspawn` boot from a `mkosi serve` call.

Note that this does not address how to get the UKI running on the target
system, this only deals with the later boot phase once the UKI is
already running.

This is WIP, because it lacks docs, and I want to do some more
polishing. But it works great.

Ultimate goal, provide a complete solution so that we also can do uefi
http boot for ukis
2025-02-21 11:26:14 +01:00
Lennart Poettering
898944a51a update TODO 2025-02-21 10:04:15 +01:00
Lennart Poettering
fc8f0089bf boot: when we detect that sd-boot is called as NBP, print friendly message
Fixes: #11850
2025-02-21 10:04:15 +01:00
Lennart Poettering
4f3a3b7695 sd-boot: also read type #1 entries from SMBIOS Type #11
With this we can now do:

systemd-vmspawn -n -i foobar.raw -s io.systemd.boot.entries-extra:particleos-current.conf=$'title ParticleOS Current\nuki-url http://example.com/somedir/uki.efi'

Assuming sd-boot is available inside the ESP of foobar.raw a new item
will show up in the boot menu that allows booting directly into the
specified UKI.
2025-02-21 10:04:15 +01:00
Lennart Poettering
fab0f6e0fc vmspawn: simplify cmdline_add_vsock() a tiny bit 2025-02-21 10:04:15 +01:00
Lennart Poettering
89cecfb100 vmspawn: add --smbios11= switch for passing arbitrary smbios type #11 strings to vm 2025-02-21 10:04:15 +01:00
Lennart Poettering
dde4c13a7f vmspawn: split out code that appends kernel command line into its own helper 2025-02-21 10:04:15 +01:00
Lennart Poettering
1089d0f89e boot: add new 'uki-url' bls type #1 menu items for booting remote UKIs
Companion BLS spec PR:

https://github.com/uapi-group/specifications/pull/135
2025-02-21 10:04:15 +01:00
Lennart Poettering
e2a3d56218 boot: add new bls type #1 stanza "uki"
This one is between "efi" and "linux": we'll recognize such entries as
linux, but we'll just invoke them as EFI binaries.

This creates a high-level concept for invoking UKIs via indirection of a
bls type #1 entry, for example to permit invocation from a non-standard
path or for giving entries a different name.

Companion BLS spec PR:

https://github.com/uapi-group/specifications/pull/135

(Let's rename LOADER_UNIFIED_LINUX to LOADER_TYPE2_UKI at the same time
to reduce confusion what is what)
2025-02-21 10:04:15 +01:00
Lennart Poettering
06648d4187 boot: move behaviour checks into per-entry-type helpers 2025-02-21 10:04:15 +01:00
Lennart Poettering
149609cfcb boot: be stricter when filtering out invalid bls #1 entries 2025-02-21 10:04:15 +01:00
Lennart Poettering
a6fbfd8db6 boot: bls type #1 with 'efi' stanza are bls type #1 too 2025-02-21 10:04:15 +01:00
Lennart Poettering
f684168050 efi: add strcspn16()/strspn16() to efi libs too 2025-02-21 10:04:15 +01:00
Lennart Poettering
d9d3e9d6c1 efi-string: add new xstr16_to_ascii() helper 2025-02-21 10:04:15 +01:00
Lennart Poettering
e577d7d94a efi: modernize reconnect_all_drivers() a bit 2025-02-21 10:04:15 +01:00
Lennart Poettering
1a95fc870a gpt-auto-generator: if root=gpt-auto is specified on kernel cmdline, always wait for /dev/gpt-auto-root symlink
So far our login in gpt-auto-generator when run in the initrd has been
to generate the units that wait for /dev/gpt-auto-root to show up and
mount them only if we have the loader partition EFI variables set. This
is of course not the case for network boots with a UKI kernel, which
means auto-gpt would not work for mounting the rootfs.

What's nasty is that we don't know for sure whether the "rootdisk"
loopback device will shown up eventually, as it needs explicit
configuration by the user via the kernel cmdline, or could be configured
entirely indepdenently. Hence, let's tweak the logic when we wat for
/dev/gpt-auto-root as device to mount: make the gpt auto root logic a
tristate: if root=gpt-auto is specified on the cmdline *definitely*
enable the logic. If root= is specified and set to anyting else,
*definitely* disable the logic. And if root= is not specified check for
the EFI partition vars – as before – to conditionalized things.

Or in other words, you can now boot the same image either via ESP/local
boot or via netboot with a kernelcmdline image like this:

    rd.systemd.pull=verify=no,machine,blockdev,bootorigin,raw:rootdisk:image.raw root=gpt-auto rootflags=x-systemd.device-timeout=infinity ip=any
2025-02-21 10:04:15 +01:00
Lennart Poettering
f8825c1364 udev-builtin-blkid: use loopback block device 'ref' field fo determining gpt-auto whole block device
So far the gpt-auto logic only looked for the partition table of devices
that the ESP/XBOOTLDR partition used to boot was on. This works great
for local boots, but is more problematic if we boot a UKI via UEFI HTTP
boot, because there is no ESP in play in that case.

Let's introduce an alternative to communicate the intended default root
disk to cover for this situation: any loopback block device whose
backing file field (i.e. the userspace controlled freeform field we use
for /dev/disk/by-loop-ref/ naming) is set to "rootdisk" will be consider
for gpt-auto will be consider for gpt-auto.

With this in place we should have nice automatic behaviour:

1. If we are booted locally we'll get the ESP/XBOOTLDR data, and derive
   the root disk from that.

2. If we are booted via UEFI HTTP boot we expect that the caller makes
   the loopback device appear with the right loop-ref identifier, and
   then will use that.
2025-02-21 10:03:49 +01:00
Lennart Poettering
3d49850096 import-generator: give import services better names
Previously, we'd name the import services numerically. Let's instead use
the local target file name, i.e. the object we are creating with these
services locally. That's useful so that we can robustely order against
these service instances, should we need to one day.
2025-02-21 10:03:32 +01:00
Lennart Poettering
fe72166979 fstab-generator: validate root= and mount.usr= the same way
In both cases, let's check for the same special mount sources. We
already covered some of the same, but let's just make it the same
codepaths.
2025-02-21 10:03:32 +01:00
Lennart Poettering
b4bee5684d fstab-generator: support creating bind mounts via root= kernel cmdline switches
This is useful for bind mounting a freshly downloaded and unpacked tar
disk images to /sysroot to mount into.

Specifically, with a kernel command line like this one:

  rd.systemd.pull=verify=no,machine,tar:root:http://_gateway:8081/image.tar root=bind:/run/machines/root ip=any

The first parameter downloads the root image, the second one then binds
it to /sysroot so that we can boot into it.
2025-02-21 10:03:32 +01:00
Lennart Poettering
8b918a3a38 import-generator: optionally import images into /run/ hierarchy rather than /var/
This is useful in particular in the initrd, as this ensures any
downloaded images are not deleted during the initrd→host transition
(where /var/ does not survive, but /run/ does). Might be useful in other
cases too, for example for transiently deployed confexts and such.
2025-02-21 10:03:32 +01:00
Lennart Poettering
576c97e165 importd: optionally allow clients to specify alternative image root 2025-02-21 10:03:32 +01:00
Lennart Poettering
0c892214f7 import-generator: add new option 'bootorigin' to derive URL from efi boot url 2025-02-21 10:03:32 +01:00
Lennart Poettering
e15d18b4c6 sd-stub: if we are http booted, query source URL and write to EFI variable
This way userspace can read the field, and use it to retrieve more
resources from the same place.
2025-02-21 10:03:32 +01:00
Lennart Poettering
c88fdb1e56 import-generator: optionally create loopback devices after download
This is useful for booting from a freshly downloaded disk image: just
specify

    rd.systemd.pull=verify=no,machine,blockdev,raw:image:https://192.168.100.1:8081/image.raw
    root=/dev/disk/by-loop-ref/image.raw-part2

on the kernel command line, and we'll download that in the initrd and boot from it.

(note the above disables download-time verification, putting trust in
verity and image policy that this won#t do harm)

Here's a more complete example. From a git checkout do:

    ninja -C build && mkosi -f -T serve

and then from another terminal do within the same checkout:

    ./build/systemd-vmspawn \
            --ram=16G \
            --register=no \
            -n \
            -i ./build/mkosi.output/image.raw \
            rd.systemd.pull=verify=no,machine,blockdev,raw:image:http://192.168.100.1:8081/image.raw \
            root=/dev/disk/by-loop-ref/image.raw-part2 \
            rootflags=x-systemd.device-timeout=infinity \
            ip=any

This will then boot via the ESP of the specified image, then download
the image via HTTP from the mkosi instance running in the first
terminal, attach it to a loopback block device, and then use its second
partition as root fs, and boot into it.

(this assumes your host is 192.168.100.1, of course)

Note that downloading the full image takes a bit of time (this downloads
it uncompressed after all), hence we turn off the timeout to wait for
the device.

This also introduces a new "imports.target" unit (and associated
"imports-pre.target") between imports are grouped, and which ensure the
imports actually are ordered correctly both on the host and in the
initrd.
2025-02-21 10:03:32 +01:00
Lennart Poettering
3e6a3341ac man: mention 'rd.' prefix for import-generator kernel cmdline options 2025-02-21 09:57:02 +01:00