Commit Graph
55979 Commits
Author SHA1 Message Date
Lennart Poettering 1462d2451a efi: use assert_se() instead of assert() to guard for OOM issues in EFI code 2022-02-01 15:31:20 +01:00
Lennart Poettering 8890ec82f5 macro: add ASSERT_SE_PTR() macro
ASSERT_SE_PTR() is like ASSERT_PTR() but uses assert_se() instead of
assert() internally.

Code should use ASSERT_SE_PTR() where the check should never be
optimized away, even if NDEBUG is set.

Rationale: assert() is the right choice for validating assumptions about
our own code, i.e. checking conditions that are "impossible" to not
hold, because we ourselves hacked things up the "right" way of course.
assert_se() is the right choice for tests that come with a weaker
guarantee, they encode assumptions over other's API behaviour, i.e.
whether something can fail there or not.

When developing tools that are not oom-safe assert_se() is the right
choice: we know that on Linux OOM doesn't really happen, even though
theoretically the API allows it to happen.

Usecase for ASSERT_SE_PTR() is mostly the fatal memory allocation logic
for EFI memory allocations. So far it used regular assert() i.e. OOM
failurs would be totally ignored if NDEBUG is set. We'd rather have our
EFI program to print an assert message and freeze instead though.
2022-02-01 15:31:05 +01:00
Lennart Poettering 3b23a6c40a fundamental: support assert_se() in EFI mode too 2022-02-01 15:29:21 +01:00
Luca Boccassi 98fd285c28 Merge pull request #22331 from yuwata/network-xfrm-interface-id
network: xfrm: refuse zero interface ID
2022-02-01 13:25:38 +00:00
Yu Watanabe bab29f2ab7 network: dhcp-server: also refuse link local address to use as the server address 2022-02-01 11:18:53 +00:00
Yu Watanabe b0f83c2d82 Merge pull request #22254 from yuwata/dhcp-server-fix-segfault
sd-dhcp-server: remove lease with hashmap_remove_value()
2022-02-01 14:10:11 +09:00
Yu Watanabe a8dfcd2c0f Merge pull request #22319 from yuwata/network-use-reconfigure
network: also use link_reconfigure_impl() to initially assign .network file
2022-02-01 14:09:32 +09:00
Yu Watanabe 020483b248 test-network: set xfrm interface ID
This also unifies two tests for xfrm, and checks the output of
'ip link' command.

Fixes #22329.
2022-02-01 13:26:43 +09:00
Yu Watanabe fd11005951 network: xfrm: refuse zero interface ID
Since kernel 5.17-rc1, 5.16.3, and 5.15.17 (more specifically,
https://github.com/torvalds/linux/commit/8dce43919566f06e865f7e8949f5c10d8c2493f5)
the kernel refuses to create an xfrm interface with zero ID.
2022-02-01 13:15:11 +09:00
James Hilliard 04660b10d3 meson: use full argument names for bpftool gen commands
This should be a purely cosmetic change.
2022-02-01 12:26:30 +09:00
Yu Watanabe a46abf2e34 fuzz-dhcp-server: add static leases 2022-02-01 11:56:22 +09:00
Yu Watanabe 6796c5a9c4 test-dhcp-server: add tests for static lease 2022-02-01 11:56:22 +09:00
Yu Watanabe 7b5445e74e test-dhcp-server: add tests for setting static DHCP lease 2022-02-01 11:56:22 +09:00
Yu Watanabe 99e65b7df3 test-dhcp-server: add usual headers 2022-02-01 11:56:22 +09:00
Yu Watanabe 4f3cb2465a test-dhcp-server: run a test earlier which does not require privilege 2022-02-01 11:56:22 +09:00
Yu Watanabe 4e2319afe4 test-dhcp-server: move sd-event allocation 2022-02-01 11:56:22 +09:00
Yu Watanabe 7e0a8bf1ce test-dhcp-server: use log_tests_skipped_errno() 2022-02-01 11:56:22 +09:00
Yu Watanabe 8b572f7ab2 sd-dhcp-server: split out logic to ACK request 2022-02-01 11:56:22 +09:00
Yu Watanabe bd1a3eb65b sd-dhcp-server: do not assign address reserved for static leases to non-matching clients
This fix the root cause of the issue #22253.
2022-02-01 11:56:22 +09:00
Yu Watanabe 7e98fe05a0 sd-dhcp-server: explicitly refuse when conflicting address is requested 2022-02-01 11:56:22 +09:00
Yu Watanabe e2ba408084 sd-dhcp-server: do not assign an address from pool when a static lease for the client ID exists 2022-02-01 11:56:22 +09:00
Yu Watanabe 5cc8be890d sd-dhcp-server: rename get_pool_offset() -> address_is_in_pool()
As, the value of pool_offset is not used.
2022-02-01 11:56:22 +09:00
Yu Watanabe eb5bff9c9d sd-dhcp-server: rename server_send_nak() -> server_send_nak_or_ignore()
And logs error in the function.
2022-02-01 11:56:01 +09:00
Yu Watanabe 8a7d048d1d sd-dhcp-server: set DHCPLease::server before hashmap_put()
Otherwise, if the second push is failed, then the first hashmap contains
dirty entry.

Also, this makes hashmap_remove_value() used when removing leases to
make not wrong lease is removed from the hashmap.

Note, this just hide the root cause of the issue #22253, which will be
fixed in later commit.

Fixes #22253.
2022-02-01 11:45:51 +09:00
Yu Watanabe 37e219800f sd-dhcp-server: fix indentation 2022-02-01 11:45:51 +09:00
Yu Watanabe 48be485b71 sd-dhcp-server: rename argument and add one missing assertion 2022-02-01 11:45:51 +09:00
Yu Watanabe 6277e48fa9 sd-dhcp-server: do not use implicit cast to boolean from integer 2022-02-01 11:45:51 +09:00
Yu Watanabe a2a801926d sd-dhcp-server: refuse zero length client ID 2022-02-01 11:45:51 +09:00
Yu Watanabe 0a195d4186 sd-dhcp-server: do not log "STOPPED" when already stopped 2022-02-01 11:45:51 +09:00
Yu Watanabe fb96111946 network: also use link_reconfigure_impl() to initially assign .network file 2022-02-01 11:38:01 +09:00
Yu Watanabe bb193d2df2 network: drop tiny wrapper used only one place anymore 2022-02-01 11:37:45 +09:00
Yu Watanabe 3cf58ef316 network: do not free bound_by carrier map on reconfigure
Otherwise, if a link enters unmanaged state, then its carrier state does
not propagated to other interfaces.
2022-02-01 11:37:01 +09:00
Yu Watanabe b69bfa4305 network: do not remove localhost address
Managing loopback interfaces by networkd is not recommended, but supporeted.
Even such spurious situation, do not drop the localhost addresses.
2022-02-01 11:30:37 +09:00
Yu Watanabe 259c65f36c network: move ndisc_flush() to link_stop_engines()
As it is not related to any static configs.
2022-02-01 11:30:37 +09:00
Yu Watanabe a0e99a377a network: remove only managed configs on reconfigure or carrier lost
Otherwise, if the carrir of the non-managed interface is lost, the
configs such as addresses or routes on the interface will be removed by
networkd.
2022-02-01 11:30:37 +09:00
Luca Boccassi 9d67fb0e33 Merge pull request #22175 from keszybz/kernel-install-mkosi-initrd
kernel-install: add support for KERNEL_INSTALL_INITRD_GENERATOR and KERNEL_INSTALL_STAGING_AREA
2022-01-31 23:09:46 +00:00
Frantisek Sumsal e3d1ffcc48 network: s/confiured/configured/
A quick typo fix I noticed whilst debugging.
2022-01-31 23:07:41 +00:00
Lennart Poettering 69339ae9f7 tree-wide: some additional checks to avoid CVE-2021-4034 style weaknesses 2022-01-31 23:07:19 +00:00
Lennart Poettering e5b90b30c2 random-seed: add missing %m in error message 2022-01-31 21:07:13 +00:00
Frantisek Sumsal caeaca1b8f Merge pull request #22323 from mrc0mmand/fix-TEST-69-on-C8S
test: use ~/.bashrc instead of /etc/bash.bashrc
2022-01-31 19:04:02 +00:00
Lennart Poettering 594f64f466 update TODO 2022-01-31 18:14:34 +01:00
Frantisek Sumsal 6f73ef8b30 test: copy portable profiles into the image if they don't exist there
If we're built with `-Dportable=false`, the portable profiles won't get
installed into the image. Since we need only the profile files and
nothing else, let's copy them into the image explicitly in such case.
2022-01-31 17:09:30 +00:00
Frantisek Sumsal 1f450a680f test: use ~/.bashrc instead of /etc/bash.bashrc
/etc/bash.bashrc appears to be Debian-specific[0] (or specific to bash
versions compiled with -DSYS_BASHRC), which doesn't seem to be the case
for C8S. Let's use ~/.bashrc instead to make the CIs happy again.

[0] https://sources.debian.org/src/bash/5.1-6/debian/README/#L50-L56
2022-01-31 17:47:01 +01:00
Frantisek Sumsal db357e9a89 test: make the code less error-prone 2022-01-31 16:49:09 +01:00
Luca Boccassi 187df3dd91 Merge pull request #22316 from yuwata/network-mac-address-length
network: several cleanups related to MAC address length
2022-01-31 14:21:28 +00:00
Luca Boccassi 0ec3af43f2 Merge pull request #22300 from yuwata/bus-fix-error-handling
tree-wide: fix bus method error handling
2022-01-31 14:03:00 +00:00
Daan De Meyer 17e2e8073f boot: Don't require a machine ID to be available
Regression introduced in https://github.com/systemd/systemd/pull/21807.

Fixes #22224
2022-01-31 13:58:06 +00:00
Luca Boccassi 06d4d83fa7 Merge pull request #22274 from yuwata/resolve-comment
resolve: cleanups for on_stream_io()
2022-01-31 13:56:04 +00:00
Luca Boccassi 9d6d4c305a core: don't fail on EEXIST when creating mount point
systemd[1016]: Failed to mount /tmp/app1 (type n/a) on /run/systemd/unit-extensions/1 (MS_BIND ): No such file or directory
systemd[1016]: Failed to create destination mount point node '/run/systemd/unit-extensions/1': File exists
2022-01-31 13:53:47 +01:00
Frantisek Sumsal 61b9769bda core: check argc/argv uncoditionally
as `assert()` might be dropped with `-DNDEBUG`.

Follow-up to cf3095a and 1637e75.
2022-01-31 20:00:40 +09:00