Commit Graph

64902 Commits

Author SHA1 Message Date
Yu Watanabe
998db5871f udev: introduce .PART_SUFFIX internal property
To make unify rules for disk and partition.
2023-05-26 16:38:09 +02:00
Zbigniew Jędrzejewski-Szmek
5287b3a87a Merge pull request #27746 from yuwata/unit-bidirectional-dep
core/unit: make unit dependency always bidirectional
2023-05-26 16:20:48 +02:00
Zbigniew Jędrzejewski-Szmek
c4f521a91b Merge pull request #27554 from ElvishJerricco/tmpfiles-c-escapes
tmpfiles: Allow C escapes
2023-05-26 15:42:48 +02:00
Frantisek Sumsal
3aed259328 fstab-generator: use correct swap name var
Follow-up to 9445623363.
2023-05-26 13:47:51 +01:00
Lennart Poettering
0706718c07 Merge pull request #27563 from yuwata/fstab-generator
fstab-generator: support defining mount units through kernel command line
2023-05-26 02:52:19 -07:00
Jordan Rome
b58feca65c core: change 'basename' to 'path_extract_filename'
This is part of a cleanup effort in the TODO doc.

Tested locally: `meson compile -C build && meson test -C build`
2023-05-26 15:45:58 +09:00
Yu Watanabe
831108245e core/unit: update bidirectional dependency simultaneously
Previously, if unit_add_dependency_hashmap() failed, then a
one-directional unit dependency reference might be created, and
triggeres use-after-free. See issue #27742 for more details.

This makes unit dependency always bidirectional, and cleanly revert
partial update on failure.

Fixes #27742.
2023-05-26 15:24:09 +09:00
Yu Watanabe
83123a4498 core/unit: search shared namespace in transitive relation of JoinsNamespaceOf=
Previously, dependency chain of JoinsNamespaceOf= did not work, e.g.
- a.service has JoinsNamespaceOf=b.service
- b.service has JoinsNamespaceOf=c.service
if, first c.service, next a.service, finally b.service is started,
then a.service is not joined to the namespace of c.service. And, as
mentioned in the document, the namespace used by b.service is not
deterministic.

This makes when searching exsiting namespace to be joined, all units in
the transitive dependency of JoinsNamespaceOf= are checked.
2023-05-26 15:23:57 +09:00
Will Fancher
4b6621fef3 tmpfiles: Allow C escapes
Fixes #26955
2023-05-26 00:45:54 -04:00
Will Fancher
5f0ee1b635 tmpfiles: Test C-style escape sequences 2023-05-26 00:45:15 -04:00
Frantisek Sumsal
ba79e8c2cc test: split the ASan wrapper into smaller blocks and tidy it up a bit
No functional change (hopefully), just making it easier on the eyes.
2023-05-26 13:43:07 +09:00
Yu Watanabe
a60f96fcf5 core/unit: make JoinsNamespaceOf= implies the inverse dependency
Previously, even if a.service has JoinsNamespaceOf=b.service, the
inverse direction of reference was not introduced.
Hence, a.service is started earlier than b.service, the namespace will
not shared with b.service.
Also, even if a.service had the reference to b.service, b.service did not.
If b.service is freed earlier, then unit_clear_dependencies() does not clear
the reference from a to b, and will cause use-after-free on unit_free() for
a.service.

Let's make JoinsNamespaceOf=b.service in a.service implies the inverse
dependency, i.e. JoinsNamespaceOf=a.service for b.service. Then, we can safely
free b.service.
2023-05-26 11:50:08 +09:00
Yu Watanabe
512df9de23 core/unit: drop doubled empty line 2023-05-26 11:50:08 +09:00
Yu Watanabe
8493a82d0b test: add tests for JoinsNamespaceOf=
To illustrate the current behavior of the dependency.
2023-05-26 11:50:05 +09:00
Daan De Meyer
75efd16fb0 units: Shut down networkd and resolved on switch-root
Let's explicitly order these against initrd-switch-root.target, so
that they are properly shut down before we switch root. Otherwise,
there's a race condition where networkd might only shut down after
switching root and after we've already we've loaded the unit graph,
meaning it won't be restarted in the rootfs.

Fixes #27718
2023-05-26 06:54:56 +08:00
Stanislaw Gruszka
3d1e78e362 rules: add rule for accel devices
Accel (Compute Acceleration) are new devices for AI/ML computation:
https://docs.kernel.org/accel/introduction.html

They are part of DRM subsystem. Add them to 'render' group since
no other appropriate group in standard linux systems exist. This
can be changed when proper common user-space components will emerge,
and new group for acceleration devices access will be established.

Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
2023-05-26 04:17:22 +09:00
David Tardon
9a2982b687 gpt-auto-generator: also honor systemd.swap=no 2023-05-25 19:30:32 +02:00
David Tardon
30765fcb16 man: add trailing = 2023-05-25 19:30:32 +02:00
Daan De Meyer
24039e1207 meson: Create credstore directories
Let's make the creds directories a bit more discoverable and make it
easier for users to use them. This also allows us to fix the
mode to 0700 for /etc instead of the usual 0755 which is what probably
would happen if users had to create this directory themselves.
2023-05-25 19:07:50 +02:00
David Tardon
19038903e1 resolved-dns-rr: use automatic cleanup
Follow-up for #27770.
2023-05-26 00:17:59 +08:00
Lennart Poettering
9c9b9b8915 update TODO 2023-05-25 14:33:45 +02:00
Lennart Poettering
be2e63159f Merge pull request #27358 from bluca/pe_mule
stub: allow loading and verifying kernel command line addons
2023-05-25 03:56:06 -07:00
Daan De Meyer
62c505e1c7 mount-util: Downgrade log message to trace
This debug log message is extremely noisy so let's downgrade it to
trace.
2023-05-25 12:48:14 +02:00
Daan De Meyer
a27f253276 mkosi: Bump default timeout to 180s
Hopefully fixes #27778 where waiting for the root device to appear
times out before systemd-repart has a chance to run and create it.
2023-05-25 12:09:13 +02:00
Lennart Poettering
0f50da0f6b Merge pull request #26959 from poettering/creds-mount-dep-fix
credential ramfs mount order fixes
2023-05-25 02:06:47 -07:00
Zbigniew Jędrzejewski-Szmek
21392bcb1c Merge pull request #27483 from yuwata/udev-id-path-usb-revision
udev: include USB revision in ID_PATH
2023-05-25 10:24:45 +02:00
Yu Watanabe
cd8910f053 Merge pull request #27770 from mrc0mmand/more-nallocfuzz-shenanigans
A couple of fixes for potential issues during OOM situations
2023-05-25 17:15:37 +09:00
Yu Watanabe
9e7b922c8f Merge pull request #27769 from YHNdnzj/loginctl-followup
loginctl: some follow-ups
2023-05-25 05:52:06 +09:00
Yu Watanabe
1f74369c2e Merge pull request #27723 from YHNdnzj/service-restart-cleanup
core: get rid of unused Service.will_auto_restart logic
2023-05-25 05:14:52 +09:00
Frantisek Sumsal
f392dfb5a1 tree-wide: check memstream buffer after closing the handle
When closing the FILE handle attached to a memstream, it may attempt to
do a realloc() that may fail during OOM situations, in which case we are
left with the buffer pointer pointing to NULL and buffer size > 0. For
example:

```
    #include <errno.h>
    #include <stdio.h>
    #include <stdlib.h>

    void *realloc(void *ptr, size_t size) {
        return NULL;
    }

    int main(int argc, char *argv[])
    {
        FILE *f;
        char *buf;
        size_t sz = 0;

        f = open_memstream(&buf, &sz);
        if (!f)
            return -ENOMEM;

        fputs("Hello", f);

        fflush(f);
        printf("buf: 0x%lx, sz: %lu, errno: %d\n",
                    (unsigned long) buf, sz, errno);
        fclose(f);
        printf("buf: 0x%lx, sz: %lu, errno: %d\n",
                    (unsigned long) buf, sz, errno);

        return 0;
    }
```

```
$ gcc -o main main.c
$ ./main
buf: 0x74d4a0, sz: 5, errno: 0
buf: 0x0, sz: 5, errno: 0
```

This might do unexpected things if the underlying code expects a valid
pointer to the memstream buffer after closing the handle.

Found by Nallocfuzz.
2023-05-24 21:59:10 +02:00
David Tardon
6de77384e0 system-update-generator: drop pointless goto 2023-05-25 04:01:31 +09:00
Yu Watanabe
290c4a4b34 Merge pull request #27173 from yuwata/update-utmp
update-utmp: do not fail when PID1 is reexecuting
2023-05-25 04:00:58 +09:00
Yu Watanabe
65d9bd5626 Merge pull request #27773 from dtardon/timestamp-cleanup
Use *timestamp_is_set() at more places
2023-05-25 03:27:15 +09:00
Yu Watanabe
3aa53842fd Merge pull request #27774 from dtardon/free-cleanup
Use free_and_*() more
2023-05-25 03:06:51 +09:00
Mike Yuan
82449055af loginctl: also show idle hint in session-status 2023-05-25 01:42:56 +08:00
Mike Yuan
8b0da9971a loginctl: list-users: use bus_map_all_properties 2023-05-25 01:42:56 +08:00
Mike Yuan
be88af3d96 loginctl: list-sessions: fix timestamp for idle hint
Follow-up for 556723e738

TABLE_TIMESTAMP_RELATIVE takes a realtime timestamp.
2023-05-25 01:42:56 +08:00
Mike Yuan
c9443393b5 loginctl: some modernizations 2023-05-25 01:42:55 +08:00
Malte Poll
8d89d66ce8 ukify: fix handling signed kernel as file
The .linux section would contain the path to the signed kernel (instead of the signed kernel itself), since the python type of the variable is used to determine how it is handled when adding the pe sections.

Co-authored-by: Otto Bittner <cobittner@posteo.net>
2023-05-24 18:07:51 +01:00
Frantisek Sumsal
08a8fd6e8d sd-journal: propagate errors from ordered_hashmap_*()
Instead of masking them with -ENOMEM.
2023-05-24 18:45:06 +02:00
David Tardon
eba1cf5638 timer: use dual_timestamp_is_set() at one more place 2023-05-24 16:41:41 +02:00
David Tardon
7bbfcf64b3 tree-wide: use timestamp_is_set() at more places 2023-05-24 16:41:37 +02:00
Luca Boccassi
f19b627560 TODO: remove fixed item 2023-05-24 15:02:36 +01:00
Luca Boccassi
05c9f9c251 stub: allow loading and verifying cmdline addons
Files placed in /EFI/Linux/UKI.efi.extra.d/ and /loader/addons/ are
opened and verified using the LoadImage protocol, and will thus get
verified via shim/firmware.
If they are valid signed PE files, the .cmdline section will be
extracted and appended. If there are multiple addons in each directory,
they will be parsed in alphanumerical order.

Optionally the .uname sections are also matched if present, so
that they can be used to filter out addons as well if needed, and only
addons that correspond exactly to the UKI being loaded are used.
It is recommended to also always add a .sbat section to addons, so
that they can be mass-revoked with just a policy update.

The files must have a .addon.efi suffix.

Files in the per-UKI directory are parsed, sorted, measured and
appended first. Then, files in the generic directory are processed.
2023-05-24 15:02:36 +01:00
Mike Yuan
96b09de500 core: drop UnitNotifyFlags
This essentially reverts 2ad2e41a72.

No longer needed after dropping UNIT_NOTIFY_WILL_AUTO_RESTART.
2023-05-24 21:37:02 +08:00
Mike Yuan
49b34f75e7 core: get rid of unused Service.will_auto_restart logic
The announced new behavior for OnFailure= never worked properly,
and we've fixed the document instead in #27675.
Therefore, let's get rid of the unused logic completely. More at #27594.

The to-be-added RestartMode= option should cover the use case hopefully.

Closes #27594
2023-05-24 21:37:02 +08:00
David Tardon
5bcd12cae0 journal-upload: use mfree() 2023-05-24 15:04:22 +02:00
David Tardon
a73e5eb94c tree-wide: use free_and_str*dup() more 2023-05-24 15:03:55 +02:00
David Tardon
d6f2cd671c tree-wide: use free_and_replace() more 2023-05-24 14:59:07 +02:00
Daan De Meyer
0de4bf409c Merge pull request #27752 from DaanDeMeyer/timer-oncalendar-fix
core/timer: Always use inactive_exit_timestamp if it is set
2023-05-24 14:39:32 +02:00