Commit Graph
44311 Commits
Author SHA1 Message Date
Yu Watanabe bdb577f545 tree-wide: drop unnecessary inclusion of version.h 2023-07-30 04:56:38 +09:00
Yu Watanabe 4122d68682 boot: always set SBAT_DISTRO_VERSION 2023-07-30 04:54:47 +09:00
Yu Watanabe ae85704760 Merge pull request #28562 from yuwata/ukify-option-length
ukify: check option length
2023-07-29 21:41:27 +09:00
Luca Boccassi e72b28eb7a Merge pull request #28557 from bluca/utils
utils: add serialize_bool_elide() and send/receive helpers for FD array
2023-07-29 12:39:06 +01:00
Luca Boccassi fc3fe92bc8 Merge pull request #28508 from yuwata/network-next-dhcp4
network: several cleanups and fixes for DHCPv4 client
2023-07-29 12:15:38 +01:00
Yu Watanabe e3c04a5c84 test-ukify: add tests for an empty argument 2023-07-29 19:57:35 +09:00
Luca Boccassi 942c40c64c serialize: add serialize_bool_elide() helper
In many case we serialize into objects that have been zero-initialized.
To save some time and resources when there are a lot of booleans, add a
helper that serializes only when the boolean is true.
2023-07-29 11:25:05 +01:00
Luca Boccassi 598d2428e1 socket-util: add send/receive helpers for FD array 2023-07-29 11:25:05 +01:00
Yu Watanabe d8f19e03c0 network,dhcp: drop support of ClientIdentifier=duid-only
The setting has not been never worked, not tested, and should not been
used. As the option is RFC incompliant. Let's drop it.

Closes #25562.
2023-07-29 18:51:09 +09:00
Yu Watanabe f0876c7ab9 ukify: check option length
Follow-up for df4a46733a.
2023-07-29 18:48:32 +09:00
Luca Boccassi b739b46919 Merge pull request #28391 from ssahani/rp-filter
networkd: allow setting rp_filter for an interface
2023-07-28 21:59:04 +01:00
Luca Boccassi dbc69b29b0 Merge pull request #28552 from bluca/test_execute
test-execute: measure, count and log test runs
2023-07-28 20:48:41 +01:00
Luca Boccassi b6349ffdc2 test-execute: count and log the number of individual tests actually executed 2023-07-28 19:35:38 +01:00
Luca Boccassi b0d3095fd6 Drop split-usr and unmerged-usr support
As previously announced, execute order 66:

https://lists.freedesktop.org/archives/systemd-devel/2022-September/048352.html

The meson options split-usr, rootlibdir and rootprefix become no-ops
that print a warning if they are set to anything other than the
default values. We can remove them in a future release.
2023-07-28 19:34:03 +01:00
Luca Boccassi 791a84ad51 test-execute: measure and log time elapsed while running tests
In order to get a good approximation of latencies when starting
services, timestamp before/after running the test cases and print
the difference. This allows to measure while ignoring the setup/shutdown
time for the test harness.
2023-07-28 16:43:13 +01:00
Luca Boccassi 1108285baa Merge pull request #28551 from mrc0mmand/unit-cleanup-set
core: free the strings in the set as well during unit cleanup
2023-07-28 13:57:01 +01:00
Daan De Meyer 7ccb171c4c Merge pull request #28359 from keszybz/ret-gather
Add RET_GATHER macro to make continue-but-remember-first-error functions easier
2023-07-28 14:28:35 +02:00
Frantisek Sumsal 9b412709f2 core: free the strings in the set as well during unit cleanup
Spotted while fuzzing #27890.

=================================================================
==908098==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7f4efe6d81f5 in __interceptor_realloc.part.0 (/lib64/libasan.so.8+0xd81f5) (BuildId: dc689b05ca2577037af24700212bb5cce1f91c8a)
    #1 0x7f4efb8e3ace in greedy_realloc ../src/basic/alloc-util.c:70
    #2 0x7f4efb93b713 in extract_first_word ../src/basic/extract-word.c:62
    #3 0x7f4efb970d50 in set_put_strsplit ../src/basic/hashmap.c:1902
    #4 0x7f4efd76c27e in exec_context_deserialize ../src/core/execute-serialize.c:3341
    #5 0x7f4efd778dcb in exec_deserialize ../src/core/execute-serialize.c:4122
    #6 0x4032c0 in LLVMFuzzerTestOneInput ../src/core/fuzz-execute-serialize.c:60
    #7 0x403c58 in main ../src/fuzz/fuzz-main.c:50
    #8 0x7f4efecccb49 in __libc_start_call_main (/lib64/libc.so.6+0x27b49) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #9 0x7f4efecccc0a in __libc_start_main_alias_2 (/lib64/libc.so.6+0x27c0a) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #10 0x402344 in _start (/home/mrc0mmand/repos/@systemd/systemd/build-san/fuzz-execute-serialize+0x402344) (BuildId: 195f382cf1e39b9ba48d6dcf5a90f786d72837a8)

SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).
Aborted (core dumped)

==911550==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 17 byte(s) in 1 object(s) allocated from:
    #0 0x4df281 in strdup (/home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/fuzz-execute-serialize+0x4df281) (BuildId: 4e58706e607b8be7972d83c421bc0b625d509ec6)
    #1 0x7fe4ae2b38fc in _set_put_strndup_full /home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/../src/basic/hashmap.c:1868:21
    #2 0x7fe4b0bad897 in exec_context_deserialize /home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/../src/core/execute-serialize.c:3914:29
    #3 0x7fe4b0b80592 in exec_deserialize /home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/../src/core/execute-serialize.c:4109:13
    #4 0x531d0f in LLVMFuzzerTestOneInput /home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/../src/core/fuzz-execute-serialize.c:59:16
    #5 0x440594 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/fuzz-execute-serialize+0x440594) (BuildId: 4e58706e607b8be7972d83c421bc0b625d509ec6)
    #6 0x43f9b9 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) (/home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/fuzz-execute-serialize+0x43f9b9) (BuildId: 4e58706e607b8be7972d83c421bc0b625d509ec6)
    #7 0x440fd5 in fuzzer::Fuzzer::MutateAndTestOne() (/home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/fuzz-execute-serialize+0x440fd5) (BuildId: 4e58706e607b8be7972d83c421bc0b625d509ec6)
    #8 0x441955 in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/fuzz-execute-serialize+0x441955) (BuildId: 4e58706e607b8be7972d83c421bc0b625d509ec6)
    #9 0x42e151 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/fuzz-execute-serialize+0x42e151) (BuildId: 4e58706e607b8be7972d83c421bc0b625d509ec6)
    #10 0x45a916 in main (/home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/fuzz-execute-serialize+0x45a916) (BuildId: 4e58706e607b8be7972d83c421bc0b625d509ec6)
    #11 0x7fe4ac449b49 in __libc_start_call_main (/lib64/libc.so.6+0x27b49) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #12 0x7fe4ac449c0a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x27c0a) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #13 0x422b74 in _start (/home/mrc0mmand/repos/@systemd/systemd/build-libfuzz/fuzz-execute-serialize+0x422b74) (BuildId: 4e58706e607b8be7972d83c421bc0b625d509ec6)
SUMMARY: AddressSanitizer: 17 byte(s) leaked in 1 allocation(s).
2023-07-28 12:59:11 +02:00
Susant Sahani 9c72e8f8bc networkd: allow setting rp_filter for an interface 2023-07-28 14:38:27 +05:30
Luca Boccassi afe7026511 Merge pull request #28335 from ssahani/dhcp4-route-option
network: DHCP4 allow to set InitialCongestionWindow and InitialAdvert…
2023-07-28 09:57:19 +01:00
Luca Boccassi 80256e8c54 Merge pull request #28527 from medhefgo/boot-stack-guard
boot: Fall back to using image load address for stack guard
2023-07-28 09:56:41 +01:00
Luca Boccassi de06b9a1b9 Merge pull request #28430 from keszybz/cleanups
Various small cleanups
2023-07-28 09:56:28 +01:00
Luca Boccassi 46021aaaa6 Merge pull request #28417 from bluca/coverity
Some coverity fixes
2023-07-28 09:56:08 +01:00
Luca Boccassi 1a1a691ba7 Merge pull request #27621 from esposem/ukify_read
ukify: add an option to read the PE sections
2023-07-28 09:55:03 +01:00
Zbigniew Jędrzejewski-Szmek be13eeb82f Merge pull request #28544 from yuwata/fstab-generator-fsck
fstab-generator: enable fsck for block device mounts specified in sys…
2023-07-28 08:49:40 +02:00
Yu Watanabe 6fa5102aa8 meson: do not create dead systemd-confext symlink if sysext is disabled 2023-07-28 12:15:47 +09:00
Yu Watanabe 239cce3870 fstab-generator: enable fsck for block device mounts specified in systemd.mount-extra=
Like we do for root= or so.

Another possible option is adding support of fifth (sixth?) field in
systemd.mount-extra=. But that may be overkill, hence let's do that
later if someone request that.

Fixes fsck part of issue #28541.
2023-07-28 09:28:26 +09:00
Yu Watanabe 905a56d5c4 test: fix typo 2023-07-28 05:55:42 +09:00
Yu Watanabe a56347db7d network/dhcp4: drop unused logic of finding default gateway 2023-07-28 05:51:36 +09:00
Yu Watanabe 4001653ddb network/dhcp4: always honor specified gateway address
Follow-up for 77451f654a.

Now, gateway for routes to DNS or NTP servers should be correctly picked,
hence it is not necessary to adjust the gateway address in
dhcp4_request_route_auto() again.

Also, similar for classless static routes, let's always honor
gateway address specified in (non-classless) static routes.
2023-07-28 05:47:11 +09:00
Yu Watanabe 0ce86f5eeb network/dhcp4: always find suitable gateway for destination address
And if not found, refuse to configure the route.

If a DHCP server provides classless static or static routes, then we
should use the gateway for accessing a node in the range specified in
the route. E.g. if a DHCP server provides the default gateway is
192.168.0.1, and classless static route for 8.0.0.0/8 with gateway
192.168.0.2, then we should access 8.8.8.8 through 192.168.0.2 rather
than 192.168.0.1, but should use 192.168.0.1 for 9.9.9.9.

Fixes #28358.
2023-07-28 05:45:51 +09:00
Yu Watanabe 0bc8b6e265 network/dhcp4: introduce dhcp4_prefix_covers() helper function
No functional change, just refactoring.
2023-07-28 05:39:19 +09:00
Yu Watanabe 15aa7a5c3d network/dhcp4: introduce dhcp4_get_router() helper function
Previously, we use the first router address, and if it is null, we
ignore the address. Now, we use the first non-null address. That is, if
the first router address is null, but the second is not, then we use the
second one.

That should not cause functional change in most cases, except for the case
when a DHCP server provides such spurious reply.

This is mostly for refactoring and preparation for later commits.
2023-07-28 05:18:24 +09:00
Yu Watanabe d52c5a72fe network/dhcp4: introduce dhcp4_get_classless_static_or_static_routes() helper
No functional changes, just refactoring and preparation for later
commits.
2023-07-28 05:17:31 +09:00
Yu Watanabe 5e6dad11b7 network/dhcp4: drop unnecessary assignment
It will be set in dhcp4_request_route_auto().
2023-07-28 05:15:11 +09:00
Yu Watanabe 1953bcd14a network/dhcp4: use FOREACH_ARRAY() macro 2023-07-28 05:15:11 +09:00
Yu Watanabe a49cf370ac network/dhcp4: honor received broadcast address 2023-07-28 05:15:11 +09:00
Yu Watanabe 2faf2e2a42 network/dhcp4: use sd_dhcp_lease_get_prefix() 2023-07-28 05:15:11 +09:00
Yu Watanabe 33acdc511c sd-dhcp: introduce sd_dhcp_lease_get_prefix() 2023-07-28 05:15:11 +09:00
Yu Watanabe 45e76094ab in-addr-util: introduce in_addr_prefix_covers_full() and friends 2023-07-28 05:15:11 +09:00
Luca Boccassi 22c5593c90 Merge pull request #28518 from yuwata/fstab-generator-fixes
fstab-generator: fixes for systemd.mount-extra=
2023-07-27 18:47:41 +01:00
Franck Bui f1f331a252 sleep: don't init /sys/power/resume if 'resume=' option is missing and EFI is disabled
Otherwise in such case a first `systemctl hibernate` would fail but would still
initialize /sys/power/resume fooling a second `systemctl hibernate` into
believing that 'resume=' is correctly set and can be used by the resume process
to find the swap device to resume from.

Follow-up for #27330.
2023-07-27 12:30:40 +01:00
Frantisek Sumsal 8f766afe98 network: don't log non-negative errno
Otherwise bad things happen:

systemd-networkd[3140]: wlan0: Saved new link: ifindex=5, iftype=ETHER(1), kind=n/a
systemd-networkd[3140]: Assertion '(_error) != 0' failed at src/network/networkd-wifi.c:119, function manager_genl_process_nl80211_config(). Aborting.

Resolves: #28534
2023-07-27 12:29:05 +01:00
Yu Watanabe bb2e3c90fc missing: include linux/types.h for __s64 and __u64
Fixes #28529.
2023-07-26 21:39:56 +01:00
Luca Boccassi eff91e2f38 efi: link with -z nopack-relative-relocs
elf2efi.py cannot handle DT_RELR relocations, so disable it
if we can

Fixes https://github.com/systemd/systemd/issues/28520
2023-07-26 18:47:53 +01:00
Yu Watanabe 22f5a825e4 fstab-generator: add a flag to accept entry for "/" in initrd
When both prefix_sysroot and accept_root is true, the entry for "/" will
be accepted and converted to "/sysroot/".

Why? If the entry is read from the main system's fstab, then we already
mounted /sysroot/, hence it is not and should not re-add the .mount unit
for /sysroot/. However, if we want to specify the root mount through the
kernel command line or credential, without this change, we need to
specify the same entry in the two options. E.g.
===
systemd.mount-extra=/dev/sda1:/:auto:defaults
rd.systemd.mount-extra=/dev/sda1:/sysroot:auto:defaults
===
That's inconvenient. Of course, we can dedup that by using traditional
options, but cannot when defined in credential.
2023-07-27 00:50:15 +09:00
Yu Watanabe dfd10549ac fstab-generator: read both credentials in initrd
This makes the behavior consistent with the way we already do for
fstab and command line options.
In initrd, entries read from fstab.extra are mounted under /sysroot.
2023-07-27 00:50:15 +09:00
Yu Watanabe 45c535ddb0 fstab-generator: add rd.systemd.mount-extra= and friends
Previously, mounts specified in systemd.mount-extra= are equally handled
both in initrd and the main system. So, the mounts for the main system
are also mounted in initrd.

This introduces rd.systemd.mount-extra=, which specifies mounts in initrd.
Then, mounts specified in systemd.mount-extra= are still mounted both in
initrd and the main system, but prefixed with /sysroot/ when running in
initrd.

Fixes #28516.
2023-07-27 00:50:01 +09:00
Yu Watanabe b93d9e06fc fstab-generator: fix target of /sysroot/usr
If /usr mount is picked from the main system's fstab file (prefix_sysroot
is true, and the path is prefixed as /sysroot/usr), then previously it
was installed in the wrong target unit.
2023-07-26 23:59:56 +09:00
Jan Janssen bc32a9fdfd boot: Fall back to using image load address for stack guard
If we cannot get random data from the RNG protocol we can still use our
load address to make the stack guard a little less static.
2023-07-26 15:11:08 +02:00