1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00
Commit Graph

55678 Commits

Author SHA1 Message Date
Yu Watanabe
54ab65f5f3 resolve: make dns_scope_good_domain() take DnsQuery*
(cherry picked from commit 176a9a2cca)
2022-02-24 10:20:14 +01:00
Yu Watanabe
499115dbc3 resolve: drop never matched condition
As dns_scope_good_domain() does not return negative errno.

(cherry picked from commit 830f50ab1e)
2022-02-24 10:20:14 +01:00
Yu Watanabe
89b439ee00 resolve: synthesize null address, IPv4 broadcast address, or invalid domain
These are filtered in `dns_scope_good_domain()`, but not synthesized.

Fixes #22229.

(cherry picked from commit 46b53e8035)
2022-02-24 10:20:14 +01:00
Yu Watanabe
0fd3ccca64 resolve: synthesize empty name
Do not return any error for empty name. Just returns empty answer.

Before:
---
$ dig .

; <<>> DiG 9.16.24-RH <<>> .
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 13617
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;.				IN	A

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Jan 24 05:49:30 JST 2022
;; MSG SIZE  rcvd: 28
---

After:
---
$ dig .

; <<>> DiG 9.16.24-RH <<>> .
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7957
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;.				IN	A

;; Query time: 1 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Jan 24 06:05:02 JST 2022
;; MSG SIZE  rcvd: 28
---

Replaces #22197.

Fixes RHBZ#2039854 (https://bugzilla.redhat.com/show_bug.cgi?id=2039854).

(cherry picked from commit 3b2ac14ac4)
2022-02-24 10:20:14 +01:00
Yu Watanabe
df08c12062 dns-domain: re-introduce dns_name_is_empty()
(cherry picked from commit 7bdf419830)
2022-02-24 10:20:14 +01:00
Frantisek Sumsal
477b85f438 packit: drop unnumbered patches as well
(cherry picked from commit 729c6b6af8)
2022-02-22 21:47:38 +00:00
Yu Watanabe
336711e062 sd-dhcp-server: do not offer server address
The server address may be in the pool.

(cherry picked from commit 9e0cb8b61f)
2022-02-22 21:47:38 +00:00
Yu Watanabe
995086918c sd-dhcp-server: do not assign address reserved for static leases to non-matching clients
This fix the root cause of the issue #22253.

(cherry picked from commit bd1a3eb65b)
2022-02-22 21:47:38 +00:00
Yu Watanabe
0478298bf9 sd-dhcp-server: explicitly refuse when conflicting address is requested
(cherry picked from commit 7e98fe05a0)
2022-02-22 21:47:38 +00:00
Yu Watanabe
71d05ec458 sd-dhcp-server: do not assign an address from pool when a static lease for the client ID exists
(cherry picked from commit e2ba408084)
2022-02-22 21:47:38 +00:00
Yu Watanabe
316f6bdb39 sd-dhcp-server: rename get_pool_offset() -> address_is_in_pool()
As, the value of pool_offset is not used.

(cherry picked from commit 5cc8be890d)
2022-02-22 21:47:38 +00:00
Yu Watanabe
7f36fb25d5 sd-dhcp-server: rename server_send_nak() -> server_send_nak_or_ignore()
And logs error in the function.

(cherry picked from commit eb5bff9c9d)
2022-02-22 21:47:38 +00:00
Yu Watanabe
1dcd82a7bf 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.

(cherry picked from commit 8a7d048d1d)
2022-02-22 21:47:38 +00:00
Frantisek Sumsal
fa6e263273 ci: fix clang-13 installation
For some reason Ubuntu Focal repositories now have `llvm-13` virtual
package which can't be installed, but successfully fools our check,
resulting in no clang/llvm being installed...

```
$ apt show llvm-13
Package: llvm-13
State: not a real package (virtual)
N: Can't select candidate version from package llvm-13 as it has no candidate
N: Can't select versions from package 'llvm-13' as it is purely virtual
N: No packages found

$ apt install --dry-run llvm-13
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package llvm-13 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'llvm-13' has no installation candidate
```

(cherry picked from commit b491d74064)
2022-02-22 21:47:38 +00:00
Evgeny Vereshchagin
c92297a20c ci: replace apt-key with signed-by
to limit the scope of the key to apt.llvm.org only.

This is mostly inspired by https://blog.cloudflare.com/dont-use-apt-key/

(cherry picked from commit bfa6bd1be0)
2022-02-22 21:47:38 +00:00
Yu Watanabe
66411cea19 network: dhcp-pd: fix prefix length of address assigned to upstream interface
This effectively revert ab0c82d9f7.

I have no idea why I did that...

Fixes #22559.

(cherry picked from commit 38488babe7)
2022-02-22 21:47:38 +00:00
Yu Watanabe
919d398668 resolve: add reference of the original bus message to the aux queries
Otherwise, the error in aux queries cannot be replied.

Fixes #22477.

(cherry picked from commit 08275791d8)
2022-02-22 21:47:38 +00:00
Yu Watanabe
084c88983e resolve: refuse AF_UNSPEC when resolving address
Fixes #22480.

(cherry picked from commit 0234f0c053)
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 9fa31df62d)
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 e1658632ae)
2022-02-22 21:47:38 +00:00
Yu Watanabe
7b121ab288 network: use udev_available() where applicable
(cherry picked from commit 82f52245ba)
2022-02-22 21:47:38 +00:00
Yu Watanabe
c809c046be udev-util: introduce udev_available() helper function
(cherry picked from commit f92c5bb18c)
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 599be274c1

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 ea583ed5a3)
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 76bcd1d6d2.
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 87728a590a.
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 0628d48ec2)

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 ac3979abd7)
2022-02-14 22:04:02 +00:00
Yu Watanabe
ab30fe12ed test-network: add missing tests for bridge properties
(cherry picked from commit b6d5dab7bb)
2022-02-14 22:03:45 +00:00
Yu Watanabe
514a4c051c network: bridge: fix endian of vlan protocol
Fixes #22469.

(cherry picked from commit 6eb35be8e0)
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 952d1e784a)
2022-02-14 22:03:20 +00:00
Daan De Meyer
88c711885f journal: Fix upwards iteration of entry items in case of corruption
8d801e35cb 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 aa00163d79)
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 ecdfb9a1ae)
2022-02-14 22:03:07 +00:00
Yu Watanabe
0533d1aab6 resolve: use _cleanup_ attribute for freeing DnsQuery
(cherry picked from commit c704288c47)
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 fe8c5ce615)
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 73bfd7be04)
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 007e03b284)
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 3fa80e5e75)

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 6d7c999ab5)
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 392d46d7a8)
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 d76f0de746)
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 26a63b8132 ('sd-dhcp6-client: Fix
sending prefix delegation request (#17136)'). The justification is
probably the same.

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

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 3008a6f21c.

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 5117059ee9)
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 e22916e61d)
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 e4de58c823)
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 d5ee050ffc, 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 23b1e8d087)
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 06cf04dff4)
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 7b86854307)
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 020483b248)
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 fd11005951)
2022-02-14 21:58:16 +00:00