Commit graph

60252 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek c76691d708
Merge pull request #24511 from martinetd/bpf1
libbpf: Add libbpf 1.0.0 compat
2022-10-06 19:01:33 +02:00
Arnaud Ferraris 5113436b05 repart: always honour --discard=no
Currently, even if `--discard=no` is passed to `systemd-repart`, the
`context_discard_gap_after()` function still runs normally, discarding
e.g. all blocks between the GPT and the start of the first partition.

This can lead to issues on some embedded devices, where this space
holds the bootloader and shouldn't be modified (creating a protective
partition there is not always possible due to the specifics of the boot
process of some ARM-based SoC's).

This commit ensures passing `--discard=no` would be enough to ensure
the bootloader isn't wiped in such cases.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@gmail.com>
2022-10-06 17:27:47 +02:00
Michal Koutný 3286770daa meson: Require TPM2 for measuring utilities
I happened to run build with openssl but no tpm2 and ran into issues
like:

        [313/1382] Compiling C object systemd-measure.p/src_boot_measure.c.o
        FAILED: systemd-measure.p/src_boot_measure.c.o
        cc -Isystemd-measure.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=format-signedness -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -fno-omit-frame-pointer -Werror=shadow -include config.h -DOPENSSL_LOAD_CONF -MD -MQ systemd-measure.p/src_boot_measure.c.o -MF systemd-measure.p/src_boot_measure.c.o.d -o systemd-measure.p/src_boot_measure.c.o -c ../src/boot/measure.c
        ../src/boot/measure.c: In function ‘verb_sign’:
        ../src/boot/measure.c:710:48: error: variable ‘c’ has initializer but incomplete type
          710 |         _cleanup_(tpm2_context_destroy) struct tpm2_context c = {};

        [308/1382] Compiling C object systemd-pcrphase.p/src_boot_pcrphase.c.o
        FAILED: systemd-pcrphase.p/src_boot_pcrphase.c.o
        cc -Isystemd-pcrphase.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=format-signedness -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -fno-omit-frame-pointer -Werror=shadow -include config.h -DOPENSSL_LOAD_CONF -MD -MQ systemd-pcrphase.p/src_boot_pcrphase.c.o -MF systemd-pcrphase.p/src_boot_pcrphase.c.o.d -o systemd-pcrphase.p/src_boot_pcrphase.c.o -c ../src/boot/pcrphase.c
        ../src/boot/pcrphase.c: In function ‘determine_banks’:
        ../src/boot/pcrphase.c:117:24: error: unknown type name ‘TPMI_ALG_HASH’
          117 |         _cleanup_free_ TPMI_ALG_HASH *algs = NULL;

Guarding the utilites with HAVE_TPM2 fixes the issue for me.

This complements #24811.
2022-10-06 22:57:45 +09:00
Dominique Martinet 87e462f713 libbpf: add compat helpers for libbpf down to 0.1.0
- new symbols are available from libbpf 0.6.0 so could be used with
libbpf.so.0, but we're sure the old symbols will be there and this
simplifies code
- detection at runtime should always work, regardless of whether systemd
has been compiled with older or newer libbpf and runs with older or newer
libbpf
2022-10-06 21:33:55 +09:00
drosdeck cbf8fad440 Fix key toggle touchpad and programmable buttom for Positivo N14 2022-10-06 13:50:44 +09:00
Aleksey Vasenev 2be1ae54ba ata_id: Fixed getting Response Code from SCSI Sense Data (#24921)
The Response Code is contained in the first byte of the SCSI Sense Data.
Bit number 7 is reserved or has a different meaning for some Response Codes
and is set to 1 for some drives.
2022-10-06 13:50:30 +09:00
Daan De Meyer 5a967e2887 Try to load libbpf.so.1 as well
libbpf had a soname bump. Our usage of libbpf is compatible with
both libbpf.so.0 and libbpf.so.1, so let's try to load from both.
2022-10-06 07:31:23 +09:00
Daan De Meyer 6b8085db68 libbpf: Remove use of deprecated APIs 2022-10-06 07:31:23 +09:00
Daan De Meyer e2490f7384 Bump libbpf version to 0.7
We already depend on the skeleton APIs introduced in libbpf 0.7 so
let's bump our minimum version to reflect that.

We don't enforce bpf compilation on mkosi anymore since not all
distros have sufficiently up-to-date libbpf available.
2022-10-06 07:31:20 +09:00
Frantisek Sumsal 4163c87731 test: configure ldconfig's cache in the minimal verity images
The glibc stuff on ppc64le C8S is a little bit wild, as there are two
versions:

```
$ ldconfig -p | grep libc.so
        libc.so.6 (libc6,64bit, hwcap: "power9", OS ABI: Linux 3.10.0) => /lib64/glibc-hwcaps/power9/libc-2.28.so
        libc.so.6 (libc6,64bit, OS ABI: Linux 3.10.0) => /lib64/libc.so.6
```

and with `/etc/ld.so.cache` present all binaries use the first one:

```
$ ldd /bin/cat
        linux-vdso64.so.1 (0x00007fffa8070000)
        libc.so.6 => /lib64/glibc-hwcaps/power9/libc-2.28.so (0x00007fffa7e20000)
        /lib64/ld64.so.2 (0x00007fffa8090000)
```

However, without the cache the binaries will fall back to `/lib64/libc.so.6`
which breaks tests that use the minimal verity images (like TEST-29),
because we install only the first version (that's shown by `ldd` at
the time the images are created):

```
[   91.595343] testsuite-29.sh[747]: + portablectl --profile=trusted attach --now --runtime /usr/share/minimal_0.raw minimal-app0
         Starting systemd-portabled.service...
[  OK  ] Started systemd-portabled.service.
         Starting minimal-app0-foo.service...
         Starting minimal-app0.service...
[  104.432217] cat[858]: cat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[  104.435080] cat[857]: cat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[FAILED] Failed to start minimal-app0.service.
See 'systemctl status minimal-app0.service' for details.
```

```
$ chroot /var/tmp/systemd-test.nMHPfc/minimal/
/bin/bash: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
```

With the ldconfig's cache it seems to work as expected:
```
$ chroot /var/tmp/systemd-test.gVtYLg/minimal
bash-4.4# cat --version
cat (GNU coreutils) 8.30
...
```
2022-10-06 02:35:22 +09:00
Luca Boccassi e96180a88d
Merge pull request #24877 from brauner/namespace_utils
namespace-util: add an initial set of tweaks
2022-10-04 21:59:48 +01:00
Daan De Meyer fd1ca01a86 repart: Drop usage of CHASE_WARN
CHASE_WARN only makes sense when CHASE_SAFE or CHASE_NO_AUTOFS are
used. repart uses neither so let's drop usage of CHASE_WARN.
2022-10-04 21:48:06 +01:00
Luca Boccassi 46c41ade20 NEWS: even more news 2022-10-04 20:12:50 +02:00
Christian Brauner 4b00e738d5
mount-util: use in_same_namespace()
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
2022-10-04 18:51:30 +02:00
Christian Brauner f7a2dc3dd5
nspawn: use in_same_namespace() helper 2022-10-04 18:51:30 +02:00
Christian Brauner 2fe299a320
namespace-util: add in_same_namespace()
Add a helper for the canonical way to determine whether two namespaces
are identical.
2022-10-04 18:51:28 +02:00
Christian Brauner 241b15779b
nsflags: replace namespace_flag_map with general namespace_info introduced earlier 2022-10-04 18:51:04 +02:00
Christian Brauner c3b9c418c0
namespace-util: add namespace_info 2022-10-04 18:46:27 +02:00
Lennart Poettering edcb46fcd7
Merge pull request #24900 from yuwata/network-ndisc-drop-outdated
network: ndisc: fix zero lifetime handling
2022-10-04 18:03:25 +02:00
Marius Vollmer 4e2baf2f0a bus: Process authentication after write
Once everything has been written, a server bus might now process a
pending "BEGIN" and start the bus.
2022-10-04 17:52:50 +02:00
Luca Boccassi 043ba6a1ee NEWS: more news 2022-10-04 15:00:55 +02:00
Luca Boccassi 3af9dc7730 NEWS: typos 2022-10-04 13:51:39 +01:00
Lennart Poettering 598f1d5377
Merge pull request #24913 from keszybz/hwdb-252-2
hwdb update
2022-10-04 13:43:48 +02:00
Yu Watanabe e6766c538a udev-builtin-net_id: reading phys_port_name may be refused with EOPNOTSUPP
If reading the sysattr failed with such error, the whole operation in
net_id builtin command will fail, and the interface will not be renamed.

Fixes a bug introduced by 5bbcfbaa11.
2022-10-04 20:29:41 +09:00
Luca Boccassi f77c0840d5 Update NEWS 2022-10-04 11:33:50 +01:00
Lennart Poettering feffee70d9 update TODO 2022-10-04 11:55:33 +02:00
Zbigniew Jędrzejewski-Szmek 4239a9ec3d hwdb: run "update-hwdb-autosuspend" 2022-10-04 10:43:47 +02:00
Zbigniew Jędrzejewski-Szmek 2b7eccd95e hwdb: run "update-hwdb"
As usual, it seems to be mostly additions and corrections.
2022-10-04 10:43:12 +02:00
drosdeck 9cc48b8175 Fix key toggle touchpad and programmable buttom for Positivo Motion CW14Q01P #24909 2022-10-03 23:06:16 +01:00
Topi Miettinen a8ec0abe5a tmpfiles: fix assert
Oct 03 17:33:20 systemd-tmpfiles[872]: Assertion 'IN_SET(i->type, CREATE_BLOCK_DEVICE|CREATE_CHAR_DEVICE)' failed at src/tmpfiles/tmpfiles.c:1837, function create_device(). Aborting.

I think this is caused by the line:
b! /dev/private/smartmontools-dev/sda 0660 root disk - 8:0
2022-10-03 22:13:29 +01:00
Yu Watanabe 8aba7b839b network: ndisc: do not accept too many DNS servers or domains
If there exists multiple routers, then the previous logic may introduce
too many DNS servers or domains.
2022-10-04 02:52:49 +09:00
Yu Watanabe af2aea8bb6 network: ndisc: drop addresses and friends when RA with zero lifetime is received
Routers may send options with zero lifetime if previously announced
information is outdated. Hence, if we receive such messages, then we
need to drop relevant addresses or friends.

See e.g. https://www.rfc-editor.org/rfc/rfc4861#section-12.

Follow-up for 2ccada8dc4.
2022-10-04 02:52:46 +09:00
Yu Watanabe 0cf1fe8888 network: make sec_to_usec() map 0sec -> 0usec
Zero lifetime in RA is special, and we should not assign possibly very
short lifetime addresses or friends.

This should not change anything at least now, preparation for later
commits. Note, DHCPv4 and v6 code also uses it, but sd-dhcp-client and
sd-dhcp6-client already filtered messages with zero lifetime. Hence,
the change should not affect DHCP code.
2022-10-04 00:25:14 +09:00
Yu Watanabe 773024685b network: ndisc: also introduce timer event source to drop outdated settings
Otherwise, settings based on previously received RA messages will never
removed without receiving a new RA message.
2022-10-04 00:25:14 +09:00
Yu Watanabe 94e6d37c2b network: ndisc: drop outdated settings before processing RA message
Otherwise, e.g. if a router is replaced, then the previously received
settings may never dropped.

Follow-up for 2ccada8dc4.
2022-10-04 00:25:14 +09:00
Yu Watanabe 8d1babc51d network: ndisc: address_get() returns 0 on success
After the commit 3b6a3bdebf, address_get()
does not return 1.
2022-10-04 00:25:14 +09:00
Yu Watanabe d4b7631468 network: introduce {address,route}_remove_and_drop()
Preparation for later commits.
2022-10-04 00:25:14 +09:00
Yu Watanabe a115c60e0d network: ndisc: ignore prefix option with link-local prefix
See https://www.rfc-editor.org/rfc/rfc4861#section-4.6.2.
2022-10-04 00:25:14 +09:00
Yu Watanabe 167c7ae511 network: ndisc: read prefix earlier
No functional changes.
2022-10-04 00:25:14 +09:00
Luca Boccassi a9b0d0a2d0 TODO: tmpfiles.d m/M 2022-10-03 15:28:11 +01:00
Daan De Meyer 898db9f3cf repart: Use chase_symlinks() instead of path_join()
Let's properly resolve symlinks and check if the source actually
exists.
2022-10-03 14:16:13 +01:00
Luca Boccassi 8bd1dcc6e8
Merge pull request #23213 from bluca/jammy
Fixes for Jammy CI
2022-10-03 13:58:09 +01:00
Luca Boccassi 8e3b2ec5a5 test-70: check if LUKS2 plugins are actually installed, not just supported
We don't build them in Debian/Ubuntu yet, even though cryptsetup supports them
2022-10-03 10:26:31 +01:00
Luca Boccassi 419f2742e7 repart: workaround spurious maybe-uninitialized warning
Build fails on Ubuntu Jammy
2022-10-03 10:26:31 +01:00
Yu Watanabe 0a8720c7f0 network: fix use-after-free
If the lifetime of the route is already expired, do not try to
configure it.

Fixes a use-after-free, as the Request object is already freed, thus, we
cannot use Route or Link stored in Request object.
2022-10-03 09:15:10 +02:00
Yu Watanabe 2ff7862bf2 resolve: drop remaining references for Monitor=
Follow-up for b25d819aee.
2022-10-03 08:26:05 +02:00
Thomas Hebb 2ccada8dc4 network: don't forget old RAs when a new one arrives
IPv6 Neighbor Discovery lets us autoconfigure a link's IPv6 addresses,
routes, DNS servers, and DNS search domains by listening for Router
Advertisement (RA) packets broadcast by one or more routers on the link.
Each RA can contain zero or more "options," each describing one piece of
configuration (e.g. a single route).

Currently, when we receive an RA from a router, we delete any addresses,
routes, etc. that originated from that router's previous RAs unless
they're also present as options in the new RA.

That behavior is a violation of RFC 4861[1]. In Section 9, the RFC
states that

    Senders MAY send a subset of options in different packets. ... Thus,
    a receiver MUST NOT associate any action with the absence of an
    option in a particular packet. This protocol specifies that
    receivers should only act on the expiration of timers and on the
    information that is received in the packets.

Several other passages in the RFC reiterate this. Section 6.2.3:

    A router MAY choose not to include some or all options when sending
    unsolicited Router Advertisements.

Section 6.3.4:

    Hosts accept the union of all received information; the receipt of a
    Router Advertisement MUST NOT invalidate all information received in
    a previous advertisement or from another source.

At least one consumer router in production today, the Google Nest Wifi,
often sends RAs that omit its global IPv6 prefix. When current versions
of systemd-networkd receive those RAs, they immediately delete the
interface's global IPv6 address, which breaks IPv6 connectivity.

Fix the issue by removing the invalidation logic entirely. It's not
needed at all, since we already invalidate addresses, routes, and DNS
configuration when the interface goes down or their lifetimes expire.

This fix does have the side effect of preventing changes to the .network
file (e.g. denylisted prefixes, whether to add routes from RAs) from
taking effect as soon as a new RA arrives. Instead, a full interface
reconfiguration is needed. But triggering those changes on RA receipt
was already rather arbitrary and out of the administrator's control, so
I think this change is fine.

commit 69203fba70 ("network: ndisc: remove old addresses and routes
after at least one SLAAC address becomes ready") introduced this
behavior. commit 50550722e3 fixed it partially, by preventing one
router's RAs from invalidating another router's configuration.

[1] https://www.rfc-editor.org/rfc/rfc4861

Fixes: 69203fba70 ("network: ndisc: remove old addresses and routes after at least one SLAAC address becomes ready")
2022-10-03 09:59:37 +09:00
Yu Watanabe 64ebc0da03 resolve: fix typo 2022-10-03 09:23:37 +09:00
Daan De Meyer f0e6cb196e repart: Take --root into account in read only filesystems shortcut 2022-10-03 08:00:07 +09:00
Yu Watanabe 59fde24c60
Merge pull request #24897 from mrc0mmand/TEST-64-sanitiers-open-scsi
test: pre-load ASan's DSO for iscsi-init.service
2022-10-03 07:51:50 +09:00