1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-20 14:03:39 +03:00

55711 Commits

Author SHA1 Message Date
Yu Watanabe
084c88983e resolve: refuse AF_UNSPEC when resolving address
Fixes #22480.

(cherry picked from commit 0234f0c0531682e7f28a4ef51852c102c6e97267)
2022-02-22 21:47:38 +00:00
Yu Watanabe
d026bd21ea udev-util: add parentheses to make coverity silent
Fixes CID#1474365.

(cherry picked from commit 9fa31df62dd504e8f3e43710df504a467ed430fa)
2022-02-22 21:47:38 +00:00
Yu Watanabe
a7cf77914b network: call ethtool after link is initialized by udevd
Fixes #22538.

(cherry picked from commit e1658632aefc963c4a651de433cceb3a9512afd6)
2022-02-22 21:47:38 +00:00
Yu Watanabe
7b121ab288 network: use udev_available() where applicable
(cherry picked from commit 82f52245baa2fe26f1de7b50a036d3746deb7df1)
2022-02-22 21:47:38 +00:00
Yu Watanabe
c809c046be udev-util: introduce udev_available() helper function
(cherry picked from commit f92c5bb18cee41d48b95d61a2a2dc613203844ca)
2022-02-22 21:47:38 +00:00
Richard Neill
160eeab224 virt: Fix Xen Dom0 detection logic to no longer report as VM
Fixes regression introduced in 599be274c13c503806c85073d7beb1a155ac27bd

Moving the Xen check before the CPUID check, in order to handle the case where
a Xen domain is nested within a hypervisor which can be detected by via the
CPUID check, had an unintended consequence of causing Dom0 to report as a Xen
VM when it is not nested.

This patch stops further checks once it has been determined that Dom0 is not
nested within another hypervisor, meaning that the non-nested case matches its
previous logic (where it does not report as a VM).

Also, tidy the conditionals for the Xen and UML checks by removing handling of
a VIRTUALIZATION_VM_OTHER result, which has no code path.

Fixes #22511

(cherry picked from commit ea583ed5a366cf51b80bd363db95e828a25ec27e)
2022-02-22 21:47:38 +00:00
Luca Boccassi
e69b2a3a69 Partially revert "sd-dhcp-server: refuse too large packet to send"
This test fails on this branch:

 949/1228 fuzz-dhcp-server-relay-message_clusterfuzz-testcase-minimized-fuzz-dhcp-server-relay-message-4972399731277824_address,undefined FAIL           0.00s (exit status 127)12:43
--- command ---12:43
01:47:36 UBSAN_OPTIONS='print_stacktrace=1:print_summary=1:halt_on_error=1' /usr/bin/env /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-server-relay-message:address,undefined /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/test/fuzz/fuzz-dhcp-server-relay-message/clusterfuzz-testcase-minimized-fuzz-dhcp-server-relay-message-497239973127782412:43
--- stderr ---12:43
/usr/bin/env: ‘/tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-server-relay-message:address,undefined’: No such file or directory

This partially reverts commit 76bcd1d6d26ebe0424e2c5edc7f5a31a82ae3a7c.
2022-02-15 14:17:47 +00:00
Luca Boccassi
2614461383 Revert "tests: add a file triggering a memory leak in dhcp_lease_parse_search_domains"
The test fails on this branch:

 948/1228 fuzz-dhcp-client_minimized-from-555a2b073b8d208655b68c294f8dfd592a11e50a_address,undefined                                      FAIL           0.00s (exit status 127)12:43
--- command ---12:43
01:47:36 UBSAN_OPTIONS='print_stacktrace=1:print_summary=1:halt_on_error=1' /usr/bin/env /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-client:address,undefined /tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/test/fuzz/fuzz-dhcp-client/minimized-from-555a2b073b8d208655b68c294f8dfd592a11e50a12:43
--- stderr ---12:43
/usr/bin/env: ‘/tmp/autopkgtest-lxc.cl7c6fs0/downtmp/build.X6Z/src/build-deb/fuzz-dhcp-client:address,undefined’: No such file or directory

This reverts commit 87728a590ad82391e76a275024c9039625ff2b67.
2022-02-15 14:17:47 +00:00
Luca Boccassi
2e323d198d meson: disable export-dbus-interfaces target when cross-compiling
ERROR:
Cannot use target systemd as a generator because it is built for the
host machine and no exe wrapper is defined or needs_exe_wrapper is
true. You might want to set `native: true` instead to build it for
the build machine.

(cherry picked from commit 0628d48ec2af1c25bede6d94ae49107b17651b68)

Conflicts:
	meson.build
2022-02-14 22:14:08 +00:00
Jan Janssen
5a9113cb0b boot: Correctly check the return value of CheckEvent
Fixes: #22428
(cherry picked from commit ac3979abd7a38725b66c1ce0607fa905b3a3d782)
2022-02-14 22:04:02 +00:00
Yu Watanabe
ab30fe12ed test-network: add missing tests for bridge properties
(cherry picked from commit b6d5dab7bbb8ecf4ce1229840085daa15ab4cf57)
2022-02-14 22:03:45 +00:00
Yu Watanabe
514a4c051c network: bridge: fix endian of vlan protocol
Fixes #22469.

(cherry picked from commit 6eb35be8e0fa5f1f00dddd558cf4dc3642d9e53e)
2022-02-14 22:03:45 +00:00
Daan De Meyer
ea4a694876 journal: Improve handling of corruption during upwards entry iteration
If we're going upwards in the journal file during entry iteration and we
can't reach the current entry due to corruption, start iterating upwards
from the last reachable entry array. This is equivalent to skipping
all entries in the array that can't be reached anymore.

Fixes #22431

(cherry picked from commit 952d1e784a0ad47e0c2c832d28299987c3c25529)
2022-02-14 22:03:20 +00:00
Daan De Meyer
88c711885f journal: Fix upwards iteration of entry items in case of corruption
8d801e35cb155faa08235a5af8b4d6ad60715837 didn't take into account
upwards iteration of entry items when we're working on a corrupted
journal file. Instead of moving to the previous entry array, we'd
always move to the next array, regardless of the iteration direction.

To fix this, we introduce bump_entry_array() that moves to the next
or previous entry array depending on the given direction. Since the
entry array chains are singly linked lists, we have to start iterating
from the front to find the previous array. We only reach this logic
if we're working on a corrupted journal file so being slow here shouldn't
matter too much.

(cherry picked from commit aa00163d79309f9873512a4cc14a48c05fee7c65)
2022-02-14 22:03:20 +00:00
Yu Watanabe
1c37ac98d6 resolve: reuse timer event source for DnsQuery
If the query get CNAME or DNAME, then the query will be restarted.
Even in that case, previously, the event source was freed and allocated
again. Let's slightly optimize it.

(cherry picked from commit ecdfb9a1ae0a09d22a976e2ca0dc99aacc6b9d1f)
2022-02-14 22:03:07 +00:00
Yu Watanabe
0533d1aab6 resolve: use _cleanup_ attribute for freeing DnsQuery
(cherry picked from commit c704288c473fa08820566fdb16c38726d24db026)
2022-02-14 22:03:07 +00:00
Yu Watanabe
4dbc210124 resolve: fix possible memleak
Fortunately, unlike the issue fixed in the previous commit, the memleak
should be superficial and not become apparent, as the queries handled
here are managed by the stub stream, and will be freed when the stream
is closed.

Just for safety, and slightly reducing the runtime memory usage by the
stub stream.

(cherry picked from commit fe8c5ce615ee2123f17b1f0b3728c439e19e4b5b)
2022-02-14 22:03:07 +00:00
Yu Watanabe
d82bd80cf4 resolve: fix potential memleak and use-after-free
When stub stream is closed early, then queries associated to the stream
are freed. Previously, the timer event source for queries may not be
disabled, hence may be triggered with already freed query.
See also dns_stub_stream_complete().

Note that we usually not set NULL or zero when freeing simple objects.
But, here DnsQuery is large and complicated object, and the element may
be referenced in subsequent freeing process in the future. Hence, for
safety, let's set NULL to the pointer.

(cherry picked from commit 73bfd7be042cc63e7649242b377ad494bf74ea4b)
2022-02-14 22:03:07 +00:00
Lennart Poettering
dcba78244e util: another set of CVE-2021-4034 assert()s
It's a good idea that we validate argc/argv when we are supposed to
store them away.

(cherry picked from commit 007e03b284e8ffc0b92edb2122cd9d2d16f049ef)
2022-02-14 22:02:47 +00:00
Luca Boccassi
cd740bdeaf core: do not attempt to add 'private' symlinks when RootImage/RootDirectory are used
A bind mount is added directly from private on the host to the actual
destination directory, no need for the symlinks (which cannot be created
as the bind mount happens first and creates the target as an actual directory)

Fixes https://github.com/systemd/systemd/issues/22264

(cherry picked from commit 3fa80e5e75a98ef6f9a84b01770b71a1774478dc)

Conflicts:
	test/units/testsuite-50.sh
2022-02-14 22:02:31 +00:00
Luca Boccassi
3f721fd803 core: add clearer debug log when setting up ExecDirectories symlinks fails
(cherry picked from commit 6d7c999ab5958d6f1f192e7d0a63b8c330a077cb)
2022-02-14 22:01:13 +00:00
Luca Boccassi
44c4116557 test: use mksquashfs -noappend
Makes the setup idempotent, as mksquashfs by default attempts to
append to an existing image

(cherry picked from commit 392d46d7a8f78169ff6b0d2740f82924e6fdc878)
2022-02-14 22:01:13 +00:00
Luca Boccassi
7784d3dde0 test: rename service used in TEST-29-PORTABLE to avoid conflict
There's an app0.service in the extension app0.raw, so don't use the same
name for a unit in minimal.raw

(cherry picked from commit d76f0de746f4ee7c9014f42b531ba0449b834214)
2022-02-14 22:01:13 +00:00
Thomas Haller
74dfb51f70 sd-dhcp6-client: fix sending prefix delegation request during rebind
Fixes an assertion failure "pd->type == SD_DHCP6_OPTION_IA_PD" in dhcp6_option_append_pd().

Something similar was done in commit 26a63b81322a ('sd-dhcp6-client: Fix
sending prefix delegation request (#17136)'). The justification is
probably the same.

(cherry picked from commit 58da18251f468de9de4cc7b36804c924e2fd4421)
2022-02-14 22:00:56 +00:00
Yu Watanabe
3a125c762f test: add a test for mkdir_p()
(cherry picked from commit 6f6b017b9bc69df3f3e308c36c95597002ce6e29)

Conflicts:
	src/test/meson.build
2022-02-14 22:00:21 +00:00
Yu Watanabe
df59c65a23 mkdir: allow to create directory whose path contains symlink
Fixes a regression caused by 3008a6f21c1c42efe852d69798a2fdd63fe657ec.

Before the commit, when `mkdir_parents_internal()` is called from `mkdir_p()`,
it uses `_mkdir()` as `flag` is zero. But after the commit, `mkdir_safe_internal()`
is always used. Hence, if the path contains a symlink, it fails with -ENOTDIR.

To fix the issue, this makes `mkdir_p()` calls `mkdir_parents_internal()` with
MKDIR_FOLLOW_SYMLINK flag.

Fixes #22334.

(cherry picked from commit 5117059ee9f84ed2fd37801ec0b90473db475422)
2022-02-14 21:58:58 +00:00
Yu Watanabe
5e672ed8fc mkdir: CHASE_NONEXISTENT cannot used in chase_symlinks_and_stat()
(cherry picked from commit e22916e61d1fdb7b46918b605ebf783d9017f9d8)
2022-02-14 21:58:58 +00:00
Yu Watanabe
1d7e0b6804 core/mount: fail early if directory cannot be created
Prompted by #22334.

(cherry picked from commit e4de58c8231e47509ffeb3aa47620ca42f22d7f6)
2022-02-14 21:58:58 +00:00
Lennart Poettering
9793254248 units: we need systemd-journald.service from systemd-journal-flush.service
This is a follow-up for d5ee050ffc9d413253932d9340ade8c8fb111092, and
reintroduces a requirement dep from systemd-journal-flush.service onto
systemd-journald.service, but a weaker one than originally: a Wants= one
instead of a Requires= one.

Why? Simply because the service issues an IPC call to the journald,
hence it should pull it in. (Note that socket activation doesn't happen
for the Varlink socket it uses, hence we should pull in the service
itself.)

(cherry picked from commit 23b1e8d087c9e8c5a2cdcc6a91510a4e7ca8f72f)
2022-02-14 21:58:39 +00:00
Yu Watanabe
ae95ca27be sd-dhcp-lease: fix memleak
Fixes https://github.com/systemd/systemd/pull/22294#issuecomment-1024840811.

(cherry picked from commit 06cf04dff4dd6c69e527913ad137616c23861270)
2022-02-14 21:58:27 +00:00
Yu Watanabe
2b04d3b3fc sd-dhcp-lease: fix reading unaligned memory
The destination address was read twice, one is for prefixlen, and
other is for destination address itself. And for prefixlen, the address
might be read from unaligned buffer.

This also modernizes the code.

(cherry picked from commit 7b868543072bb9073174a4ae46032fdb6eb24c92)
2022-02-14 21:58:27 +00:00
Yu Watanabe
a5fc827b3a test-network: set xfrm interface ID
This also unifies two tests for xfrm, and checks the output of
'ip link' command.

Fixes #22329.

(cherry picked from commit 020483b248b45b15eb93d2ae322d7f211c61e44d)
2022-02-14 21:58:16 +00:00
Yu Watanabe
1ef56ad928 network: xfrm: refuse zero interface ID
Since kernel 5.17-rc1, 5.16.3, and 5.15.17 (more specifically,
8dce439195)
the kernel refuses to create an xfrm interface with zero ID.

(cherry picked from commit fd11005951920a0cee96f0c56f36d9ff8bc66a41)
2022-02-14 21:58:16 +00:00
Lennart Poettering
c4357f31da execute: document that the 'env' param is input *and* output
(cherry picked from commit 421bb42d1b366c00392ef5bbab6a67412295b6dc)
2022-02-14 21:58:04 +00:00
Lennart Poettering
14567dc93d execute: line break comments a bit less aggressively
(cherry picked from commit cafc5ca147cb05b90bd731661d8594c299601f79)
2022-02-14 21:58:04 +00:00
Lennart Poettering
9b2954b794 execute: use _cleanup_ logic where appropriate
(cherry picked from commit 46e5bbab5895b7137b03453dee08bd1c89c710e9)
2022-02-14 21:58:04 +00:00
Lennart Poettering
9c560d2015 pid1: pass PAM_DATA_SILENT to pam_end() in child
Fixes: #22318
(cherry picked from commit 7feb2b5737ad110eb3985e8e9d8189f18d1c5147)
2022-02-14 21:58:04 +00:00
Yu Watanabe
048487c094 login: use bus_error_message() at one more place
(cherry picked from commit 80c8c786a314bceba180fac5506e72aa48c0764a)
2022-02-14 21:56:48 +00:00
Yu Watanabe
81e5941116 core/unit: use bus_error_message() at one more place
(cherry picked from commit 33322185554799b08e94aca036dd109aaee52408)
2022-02-14 21:56:48 +00:00
Yu Watanabe
b9e144629b bus-util: retrieve bus error from message
The error in argument is not input, but used for output.

(cherry picked from commit 853b94863cf26d084454edd63ce987cc7ab0505a)
2022-02-14 21:56:48 +00:00
Daan De Meyer
47da2d8e29 boot: Don't require a machine ID to be available
Regression introduced in https://github.com/systemd/systemd/pull/21807.

Fixes #22224

(cherry picked from commit 17e2e8073f3d387035595fcf6c3aa27acb24e2dc)
2022-02-14 21:56:48 +00:00
Luca Boccassi
ae8bc570a8 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

(cherry picked from commit 9d6d4c305ab8d65aab7f546450d7331f760b7259)
2022-02-14 21:56:48 +00:00
Frantisek Sumsal
e697fa6007 basic: update CIFS magic
Kernel commit dea2903719283c156b53741126228c4a1b40440f exposed (and
renamed) CIFS_MAGIC_NUMBER as CIFS_SUPER_MAGIC along with
SMB2_SUPER_MAGIC.

This fixes the following build fail on current Fedora Rawhide:
```
../src/basic/meson.build:389:8: ERROR: Problem encountered: found unknown filesystem(s) defined in kernel headers:

Filesystem found in kernel header but not in filesystems-gperf.gperf: CIFS_SUPER_MAGIC
Filesystem found in kernel header but not in filesystems-gperf.gperf: SMB2_SUPER_MAGIC
```

(cherry picked from commit bbe53713455be38c0a587626439fd171f28c77fc)
2022-02-14 21:56:48 +00:00
Evgeny Vereshchagin
7dc0f80588 sd-dhcp-lease: fix a memory leak in dhcp_lease_parse_search_domains
=================================================================
==81071==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x51245c in __interceptor_reallocarray (/home/vagrant/systemd/build/fuzz-dhcp-client+0x51245c)
    #1 0x7f01440c67e6 in strv_push /home/vagrant/systemd/build/../src/basic/strv.c:435:13
    #2 0x7f01440ca9e1 in strv_consume /home/vagrant/systemd/build/../src/basic/strv.c:506:13
    #3 0x7f01440ca9e1 in strv_extend /home/vagrant/systemd/build/../src/basic/strv.c:558:16
    #4 0x5806e3 in dhcp_lease_parse_search_domains /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:900:21
    #5 0x57c1be in dhcp_lease_parse_options /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:727:21
    #6 0x572450 in parse_options /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:348:33
    #7 0x571c6a in dhcp_option_parse /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:376:13
    #8 0x559a01 in client_handle_offer /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-client.c:1543:13
    #9 0x5592bd in LLVMFuzzerTestOneInput /home/vagrant/systemd/build/../src/libsystemd-network/fuzz-dhcp-client.c:74:16
    #10 0x44a379 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x44a379)
    #11 0x42ae1f in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x42ae1f)
    #12 0x432ade in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x432ade)
    #13 0x421f86 in main (/home/vagrant/systemd/build/fuzz-dhcp-client+0x421f86)
    #14 0x7f0142fff55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)

(cherry picked from commit 9591c0a8b3496d0e5cbbfe7c75161ba80089c143)
2022-02-14 21:56:48 +00:00
Evgeny Vereshchagin
ba335f6f40 tests: add a file triggering a memory leak in dhcp_lease_parse_search_domains
(cherry picked from commit 998ec39b1d20a40453a3b47f7eb68feacefd65d9)
2022-02-14 21:56:48 +00:00
Evgeny Vereshchagin
426807c54b sd-dhcp-lease: fix an infinite loop found by the fuzzer
(cherry picked from commit 86b06c666be8b7afb45541d35aa4d0ecb38056d1)
2022-02-14 21:56:48 +00:00
Donald Chan
9f596964f6 basic: mac_[selinux,smack]_apply_fd does not work when applying labels
Commit a7fdc6c introduced a regression where file descriptors are opened
using O_PATH option. mac_smack_apply_fd() calls fsetxattr() and would fail
with a -EBADF (Bad file descriptor) error.

Use FORMAT_PROC_FD_PATH(fd) to convert the fd back into a full path and
call setxattr() or setfilecon() instead.

Signed-off-by: Donald Chan <hoiho@amazon.com>
(cherry picked from commit a718364e9d9242cc2111c9860f2ab5bb9bb26db9)
2022-02-14 21:56:48 +00:00
Yu Watanabe
530a18d493 sd-dhcp-server: refuse too large packet to send
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44134.

(cherry picked from commit 71df50a9734f7006bc1ac8be59ca81c797b39c35)
2022-02-14 21:56:48 +00:00
Arfrever Frehtes Taifersar Arahesis
5b20a2b19c logind.conf: Fix name of option: RuntimeDirectoryInodes -> RuntimeDirectoryInodesMax
(cherry picked from commit a42a93830fcc18da073a5ac06f93c386efc9109d)
2022-02-14 21:56:48 +00:00
Christian Brauner
09936a7ec9 core/namespace: s/normalize_mounts()/drop_unused_mounts()
Rename the normalize_mounts() helper to drop_unused_mounts. All the
helpers called in there get rid of mounts that are unused for a variety
of reasons. And whereas the helpers are aptly prefixed with "drop" the
overall helper isn't and instead uses "normalize".

Make it more obvious what the helper actually does by renaming it from
normalize_mounts() to drop_unused_mounts(). Readers of code calling this
helper will immediately see that it will get rid of unused mounts.

Link: https://github.com/systemd/systemd/issues/22206
(cherry picked from commit fbf90c0d5cadc5d1e95485f770f45a7d4cd39daa)
2022-02-14 21:56:48 +00:00