1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-09 01:18:19 +03:00
Commit Graph

64788 Commits

Author SHA1 Message Date
Lennart Poettering
84c61aea0f base-filesystem: mention why we don't carry an entry for /tmp/ for now 2023-05-16 11:45:21 +02:00
Frantisek Sumsal
cd70372b93 nspawn: make sure the device type survives when setting device mode 2023-05-16 11:40:33 +02:00
Lennart Poettering
4d88d83924 base-filesystem: also set up /run/ mount point if missing
We don't support images without, hence create this one too, like we
create all other relevant mount points we definitely require for
booting.
2023-05-16 11:32:56 +02:00
Yu Watanabe
40b6b448bd test: add tests for renaming network interface 2023-05-16 18:28:18 +09:00
Frantisek Sumsal
f00519b5b3 fuzz: update the base JSON for fuzz-nspawn-oci 2023-05-16 11:27:10 +02:00
Frantisek Sumsal
0d5896a949 test: add a couple of tests for nspawn's OCI stuff 2023-05-16 11:27:10 +02:00
Frantisek Sumsal
525c3e3438 nspawn: fix a global-buffer-overflow
Whoopsie.

=================================================================
==3789231==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000051d0b8 at pc 0x7f70850bc904 bp 0x7ffd9bbdf660 sp 0x7ffd9bbdf658
READ of size 8 at 0x00000051d0b8 thread T0
    #0 0x7f70850bc903 in json_dispatch ../src/shared/json.c:4347
    #1 0x4a5b54 in oci_seccomp_syscalls ../src/nspawn/nspawn-oci.c:1838
    #2 0x7f70850bd359 in json_dispatch ../src/shared/json.c:4395
    #3 0x4a668c in oci_seccomp ../src/nspawn/nspawn-oci.c:1905
    #4 0x7f70850bd359 in json_dispatch ../src/shared/json.c:4395
    #5 0x4a7d8c in oci_linux ../src/nspawn/nspawn-oci.c:2030
    #6 0x7f70850bd359 in json_dispatch ../src/shared/json.c:4395
    #7 0x4aa31c in oci_load ../src/nspawn/nspawn-oci.c:2198
    #8 0x446cec in load_oci_bundle ../src/nspawn/nspawn.c:4744
    #9 0x44ffa7 in run ../src/nspawn/nspawn.c:5477
    #10 0x4552fb in main ../src/nspawn/nspawn.c:5920
    #11 0x7f7083a4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
    #12 0x7f7083a4a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
    #13 0x40d284 in _start (/home/fsumsal/repos/@systemd/systemd/build-san/systemd-nspawn+0x40d284)

0x00000051d0b8 is located 40 bytes to the left of global variable 'bus_standard_errors_copy_0' defined in '../src/libsystemd/sd-bus/bus-error.h:57:1' (0x51d0e0) of size 8
0x00000051d0b8 is located 0 bytes to the right of global variable 'table' defined in '../src/nspawn/nspawn-oci.c:1829:43' (0x51d040) of size 120
SUMMARY: AddressSanitizer: global-buffer-overflow ../src/shared/json.c:4347 in json_dispatch
Shadow bytes around the buggy address:
  0x00008009b9c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009b9d0: 00 00 00 00 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x00008009b9e0: 00 00 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x00008009b9f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009ba00: 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
=>0x00008009ba10: 00 00 00 00 00 00 00[f9]f9 f9 f9 f9 00 f9 f9 f9
  0x00008009ba20: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009ba30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009ba40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009ba50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009ba60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==3789231==ABORTING
2023-05-16 11:27:10 +02:00
Frantisek Sumsal
fc83296547 nspawn: fix inverted condition 2023-05-16 11:27:10 +02:00
Frantisek Sumsal
f4e5c042c9 nspawn: call json_dispatch() with a correct pointer
Otherwise hilarity ensues:

 AddressSanitizer:DEADLYSIGNAL
 =================================================================
 ==722==ERROR: AddressSanitizer: SEGV on unknown address 0xffffffff00000000 (pc 0x7f8d50ca9ffb bp 0x7fff11b0d4a0 sp 0x7fff11b0cc30 T0)
 ==722==The signal is caused by a READ memory access.
     #0 0x7f8d50ca9ffb in __interceptor_strcmp.part.0 (/lib64/libasan.so.8+0xa9ffb)
     #1 0x7f8d4f9cf5a1 in strcmp_ptr ../src/fundamental/string-util-fundamental.h:33
     #2 0x7f8d4f9cf5f8 in streq_ptr ../src/fundamental/string-util-fundamental.h:46
     #3 0x7f8d4f9d74d2 in free_and_strdup ../src/basic/string-util.c:948
     #4 0x49139a in free_and_strdup_warn ../src/basic/string-util.h:197
     #5 0x4923eb in oci_absolute_path ../src/nspawn/nspawn-oci.c:139
     #6 0x7f8d4f6bd359 in json_dispatch ../src/shared/json.c:4395
     #7 0x4a8831 in oci_hooks_array ../src/nspawn/nspawn-oci.c:2089
     #8 0x7f8d4f6bd359 in json_dispatch ../src/shared/json.c:4395
     #9 0x4a8b56 in oci_hooks ../src/nspawn/nspawn-oci.c:2112
     #10 0x7f8d4f6bd359 in json_dispatch ../src/shared/json.c:4395
     #11 0x4aa298 in oci_load ../src/nspawn/nspawn-oci.c:2197
     #12 0x446cec in load_oci_bundle ../src/nspawn/nspawn.c:4744
     #13 0x44ffa7 in run ../src/nspawn/nspawn.c:5477
     #14 0x4552fb in main ../src/nspawn/nspawn.c:5920
     #15 0x7f8d4e04a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
     #16 0x7f8d4e04a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
     #17 0x40d284 in _start (/usr/bin/systemd-nspawn+0x40d284)
 AddressSanitizer can not provide additional info.
 SUMMARY: AddressSanitizer: SEGV (/lib64/libasan.so.8+0xa9ffb) in __interceptor_strcmp.part.0
 ==722==ABORTING
2023-05-16 11:27:10 +02:00
Frantisek Sumsal
3590d95b2b nspawn: all hooks should be arrays of objects, not just objects
See: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#posix-platform-hooks
2023-05-16 11:27:10 +02:00
Frantisek Sumsal
e5c275fedc nspawn: use the just returned errno in the log message
Use the returned errno even though we are going to ignore it, otherwise
the log message is just confusing:

config.json:119:13: Failed to resolve device node 4:2, ignoring: Success
2023-05-16 11:27:10 +02:00
Frantisek Sumsal
ec0d7e0dd5 nspawn: disableOOMKiller should be boolean, not int
See: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config-linux.md#memory
2023-05-16 11:27:10 +02:00
Frantisek Sumsal
53ac7f1d54 nspawn: modernize the cleanup functions a bit 2023-05-16 11:27:10 +02:00
Frantisek Sumsal
825210d4e5 nspawn: avoid NULL pointer dereference
When merging the settings we take the pointer to the array of extra
devices, but don't reset the array counter to zero. This later leads to
a NULL pointer dereference, where device_node_array_free() attempts to
loop over a NULL pointer:

+ systemd-nspawn --oci-bundle=/var/lib/machines/testsuite-13.oci-bundle.Npo
 ../src/nspawn/nspawn-settings.c:118:29: runtime error: member access within null pointer of type 'struct DeviceNode'
     #0 0x4b91ee in device_node_array_free ../src/nspawn/nspawn-settings.c:118
     #1 0x4ba42a in settings_free ../src/nspawn/nspawn-settings.c:161
     #2 0x410b79 in settings_freep ../src/nspawn/nspawn-settings.h:249
     #3 0x446ce8 in load_oci_bundle ../src/nspawn/nspawn.c:4733
     #4 0x44ff42 in run ../src/nspawn/nspawn.c:5476
     #5 0x455296 in main ../src/nspawn/nspawn.c:5919
     #6 0x7f0cb7a4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
     #7 0x7f0cb7a4a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
     #8 0x40d284 in _start (/usr/bin/systemd-nspawn+0x40d284)
 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nspawn/nspawn-settings.c:118:29 in

Also, add an appropriate assert to catch such issues in the future.
2023-05-16 11:27:10 +02:00
Lennart Poettering
a0cb335816 sd-bus: bind outgoing AF_UNIX sockets to abstract addresses conveying client comm + bus description string
Let's pass some additional meta information along bus connections
without actually altering the communication protocol.

Pass the client comm and client description string of the bus via
including it in the abstract namespace client socket address we connect
to. This is purely informational (and entirely user controlled), but has
the benefit that servers can make use of the information if they want,
but really don't have to. It works entirely transparently.

This takes inspiration from how we convey similar information via
credential socket connections.
2023-05-16 10:17:49 +02:00
Lennart Poettering
f7794e423a test-bus-server: minor modernizations 2023-05-16 10:09:05 +02:00
Lennart Poettering
4b7604af31 test-bus-chat: modernize a few things 2023-05-16 10:09:05 +02:00
Lennart Poettering
04dc2db08a mount-setup: minor modernization 2023-05-16 10:01:28 +02:00
Lennart Poettering
ce6fa09567 mount-setup: minor log improvement 2023-05-16 10:00:04 +02:00
Lennart Poettering
4900c3e5b1 mount-setup: port to logging about mount attempts via mount_*follow_verbose() 2023-05-16 10:00:04 +02:00
Yu Watanabe
9094ae52ca udev/net: assign alternative names only on add uevent
Previously, we first assign alternative names to a network interface,
then later change its main name if requested. So, we could not assign
the name that currently assigned as the main name of an interface as an
alternative name. So, we retry to assign the previous main name as an
alternative name on later move uevent.

However, that causes some confusing situation. E.g. if a .link file has
```
Name=foo
AlternativeNames=foo baz
```
then even if the interface is renamed by a user e.g. by invoking 'ip link'
command manually, the interface can be still referenced as 'foo', as the
name is now assigned as an alternative name.

This makes the order of name assignment inverse: the main name is first
changed, and then the requested alternative names are assigned. And
udevd do not assign alternative names on move uevent.

Replaces #27506.
2023-05-16 16:37:31 +09:00
Yu Watanabe
8182445500 sd-netlink: make rtnl_set_link_name() optionally append alternative names 2023-05-16 16:37:31 +09:00
Yu Watanabe
cd941e6596 udev/net: generate new network interface name only on add uevent
On other uevents, the name will be anyway ignored in rename_netif() in
udev-event.c.
2023-05-16 16:37:31 +09:00
Yu Watanabe
e65c6c1baa udev/net: verify ID_NET_XYZ before trying to assign it as an alternative name 2023-05-16 16:37:31 +09:00
Yu Watanabe
5668f3a7cf udev: make udev_builtin_run() take UdevEvent*
No functional change, preparation for later commits.
2023-05-16 16:37:31 +09:00
Yu Watanabe
b3cfe59001 udev: use SYNTHETIC_ERRNO() at one more place 2023-05-16 16:37:28 +09:00
Lennart Poettering
a4b3e94236 dissect-image: port mount_image_privately_interactively() to use /run/systemd/mount-rootfs/ too
Let's use the same common directory as the unit logic uses.

This means we have less to clean up, and opens the door to eventually
allow unprivileged operation of the
mount_image_privately_interactively() logic.
2023-05-16 09:26:17 +02:00
Lennart Poettering
be79c23569 pid1: port unit namespacing to new /run/systemd/mount-rootfs dir 2023-05-16 09:24:45 +02:00
Lennart Poettering
3690bfb5b2 namespace: introduce a common dir in /run/ that we can use to see new root fs up on
This creates a new dir /run/systemd/mount-rootfs/ early in PID 1 that
thus always exists. It's supposed to be used by any code that creates
its own mount namespace and then sets up a new root dir to switch into.
So far in many cases we used a temporary dir (which needed explicit
clean-up) or a purpose-specific fixed dir.

Let's create a common dir instead, that always exists (as it is created
in PID 1 early on, always).

Besides making things more robust, as manual clean-up of the inode is
not necessary anymore this also opens the door for unprivileged programs
to use the same dir, since it now always exists.

Set the access mode to 555 (instead of the otherwise previously used
0755, 0700 or similar), so that unprivileged programs can access it, but
we make clear it's not supposed to be written directly to, by anyone,
not even root.
2023-05-16 09:24:45 +02:00
Lennart Poettering
a789f72ed2 mount-util: add umount_and_free() helper 2023-05-16 09:24:45 +02:00
Zbigniew Jędrzejewski-Szmek
f44744ff51
Merge pull request #27652 from keszybz/readme-more
Add man page for libsystemd, extend readme and stability promise
2023-05-16 08:51:19 +02:00
Zbigniew Jędrzejewski-Szmek
7ecce0e571 docs: list all public headers in stability promise
We provide the same stability for all the headers that are public.

Also, mark id128 as portable to other systems. There is really nothing in the
code that would make it hard. It would probably work out-of-the-box.
2023-05-16 08:50:11 +02:00
Zbigniew Jędrzejewski-Szmek
522c108de1 README: describe how our libraries are linked
In https://github.com/systemd/systemd/pull/27637#issuecomment-1547517316
we discussed disclaiming warranty when distros do version mixing.
But to make this disclaimer meaningful, we need to document what options are
available.
2023-05-16 08:50:11 +02:00
Yu Watanabe
5571048919 meson: fix description for link-udev-shared option 2023-05-16 14:14:06 +08:00
nikstur
916db27f16 man: use correct name for --bank option 2023-05-15 23:15:15 +01:00
saikat0511
738a195bd5
hwdb: fix keyboard entry for IdeapadFlex5 (#27643)
Fixes a bug caused by 19db450f3a (#27211).

Also this makes the model more specific.
2023-05-16 05:58:50 +09:00
Zbigniew Jędrzejewski-Szmek
4bc96dc162 man: add libsystemd(3)
Before libsystemd-daemon, libsystemd-journal, libsystemd-id128, etc., were
merged into libsystemd, it was enough to have individual man pages for them.
But they have been delivered as one thing for many years, so it's better to
have a landing page for libsystemd. It mostly directs to individual pages
anyway.
2023-05-15 22:53:22 +02:00
Zbigniew Jędrzejewski-Szmek
778816f4c8 meson: add sd_pid_notify_barrier link
Fixup for 0de3431871.
2023-05-15 22:51:49 +02:00
Lennart Poettering
f81048f8f5 watchdog: always disarm watchdog properly before closing it
If we change the watchdog device we should disarm the old one first.

Similar, if we open the watchdog, but then fail setting it up, disarm it
before closing it again.
2023-05-15 21:55:19 +08:00
Daan De Meyer
4340e5b6df Revert "units: Add missing dependencies on initrd-switch-root.target"
This reverts commit f0ad3e6b96.
2023-05-15 15:42:21 +02:00
Daan De Meyer
78c49d012c mkosi: Always pull in network-online.target
Let's always pull this in so that we always activate
systemd-networkd-wait-online for extra coverage.
2023-05-15 15:41:53 +02:00
Daan De Meyer
1fb59099f6 mkosi: Drop squashfs dropin
This accidentally got pulled into a commit even though it was only
for local testing, let's drop it again so we correctly use erofs
when building local images.
2023-05-15 15:41:53 +02:00
Frantisek Sumsal
3426ec8efb nspawn: file system namespace -> mount namespace 2023-05-15 14:05:15 +02:00
Frantisek Sumsal
55d3c136d9 nspawn: fix a typo in an error message 2023-05-15 14:01:58 +02:00
Robert Scheck
c06d2e440c portable, meson: allow statically linked build
Build option "link-portabled-shared" to build a statically linked
systemd-portabled by using

  -Dlink-portabled-shared=false

on systems with full systemd stack except systemd-portabled, such
as CentOS/RHEL 9.
2023-05-15 13:30:04 +02:00
Daan De Meyer
3dca0b3661 mkosi: Install tmux in the final image
We currently have to resort to SSH to get more than one interactive
terminal in a mkosi qemu VM. Let's increase our options by installing
tmux in the final image, which can multiplex the serial console into
many unique terminal sessions.
2023-05-15 11:45:58 +01:00
Luca Boccassi
f9c91eea78
Merge pull request #27644 from mrc0mmand/fuzz-nspawn
test: update nspawn's basic config file used for fuzzing
2023-05-15 11:45:15 +01:00
Frantisek Sumsal
806b18240a test: make $BUILD_DIR writable when rootfs is mounted read-only
Adjust two systemd-nspawn invocations where rootfs is mounted read-only,
to avoid gcov complaining.
2023-05-15 10:15:24 +02:00
Frantisek Sumsal
786f6d81f7 test: pass $BUILD_DIR as $COVERAGE_BUILD_DIR to the system manager
To make additional coverage-related tweaks slightly easier.
2023-05-15 10:06:54 +02:00
Mike Yuan
b5b1351317
test: add tests for UpheldBy= in [Install] section 2023-05-15 15:04:38 +08:00