]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
3 years agosd-dhcp-lease: fix a memory leak in dhcp_lease_parse_search_domains 22294/head
Evgeny Vereshchagin [Sat, 29 Jan 2022 03:16:40 +0000 (03:16 +0000)] 
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)

3 years agotests: add a file triggering a memory leak in dhcp_lease_parse_search_domains
Evgeny Vereshchagin [Sat, 29 Jan 2022 03:18:31 +0000 (03:18 +0000)] 
tests: add a file triggering a memory leak in dhcp_lease_parse_search_domains

3 years agosd-dhcp-lease: fix an infinite loop found by the fuzzer
Evgeny Vereshchagin [Sat, 29 Jan 2022 02:08:39 +0000 (02:08 +0000)] 
sd-dhcp-lease: fix an infinite loop found by the fuzzer

3 years agotests: fuzz client_handle_offer
Evgeny Vereshchagin [Fri, 28 Jan 2022 20:35:38 +0000 (20:35 +0000)] 
tests: fuzz client_handle_offer

Turns out that part of systemd isn't covered by any fuzz targets and
that's not ideal considering that it parses data sent remotely. The
fuzzer triggers an infinite loop in lease_parse_routes as soon as it
starts so it seems to be working :-)
```
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 23620602
INFO: Loaded 2 modules   (182073 inline 8-bit counters): 176548 [0x7fdf511fc8d0, 0x7fdf51227a74), 5525 [0x5f6ef0, 0x5f8485),
INFO: Loaded 2 PC tables (182073 PCs): 176548 [0x7fdf51227a78,0x7fdf514d94b8), 5525 [0x5f8488,0x60ddd8),
./build/fuzz-dhcp-client: Running 1 inputs 1 time(s) each.
Running: test/fuzz/fuzz-dhcp-client/timeout-ed34161922c7075c4773f2ada3dee8685d220980
ALARM: working on the last Unit for 31 seconds
       and the timeout value is 30 (use -timeout=N to change)
==80731== ERROR: libFuzzer: timeout after 31 seconds
    #0 0x51b32e in __sanitizer_print_stack_trace (/home/vagrant/systemd/build/fuzz-dhcp-client+0x51b32e)
    #1 0x4689e9 in fuzzer::PrintStackTrace() (/home/vagrant/systemd/build/fuzz-dhcp-client+0x4689e9)
    #2 0x44a0f4 in fuzzer::Fuzzer::StaticAlarmCallback() (/home/vagrant/systemd/build/fuzz-dhcp-client+0x44a0f4)
    #3 0x7fdf4f8b474f  (/lib64/libc.so.6+0x4274f)
    #4 0x465fee in __sanitizer_cov_trace_const_cmp4 (/home/vagrant/systemd/build/fuzz-dhcp-client+0x465fee)
    #5 0x57eee5 in lease_parse_routes /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:495:23
    #6 0x57baf3 in dhcp_lease_parse_options /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:701:21
    #7 0x572450 in parse_options /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:348:33
    #8 0x571cea in dhcp_option_parse /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:381:21
    #9 0x559a01 in client_handle_offer /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-client.c:1543:13
    #10 0x5592bd in LLVMFuzzerTestOneInput /home/vagrant/systemd/build/../src/libsystemd-network/fuzz-dhcp-client.c:78:9
    #11 0x44a379 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x44a379)
    #12 0x42ae1f in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x42ae1f)
    #13 0x432ade in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x432ade)
    #14 0x421f86 in main (/home/vagrant/systemd/build/fuzz-dhcp-client+0x421f86)
    #15 0x7fdf4f89f55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
    #16 0x7fdf4f89f60b in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x2d60b)
    #17 0x421fd4 in _start (/home/vagrant/systemd/build/fuzz-dhcp-client+0x421fd4)

SUMMARY: libFuzzer: timeout
```

3 years agotest: add missing oom check
Yu Watanabe [Fri, 28 Jan 2022 01:20:31 +0000 (10:20 +0900)] 
test: add missing oom check

Fixes CID#1469129.

3 years agoMerge pull request #22283 from yuwata/sd-device-suppress-log
Daan De Meyer [Fri, 28 Jan 2022 12:55:16 +0000 (12:55 +0000)] 
Merge pull request #22283 from yuwata/sd-device-suppress-log

sd-device: suppress log

3 years agounit: introduce wait-online@.service for specific interface
Yu Watanabe [Fri, 28 Jan 2022 06:30:01 +0000 (15:30 +0900)] 
unit: introduce wait-online@.service for specific interface

This should be useful when a host has multiple interfaces.

Inspired by #22246.

3 years agoMerge pull request #22282 from yuwata/test-revert-workaronds
Frantisek Sumsal [Fri, 28 Jan 2022 12:37:12 +0000 (12:37 +0000)] 
Merge pull request #22282 from yuwata/test-revert-workaronds

test: revert workaronds

3 years agosd-dhcp-server: refuse too large packet to send
Yu Watanabe [Fri, 28 Jan 2022 02:53:49 +0000 (11:53 +0900)] 
sd-dhcp-server: refuse too large packet to send

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44134.

3 years agohwdb: add two Elecom trackballs
Ryan Hendrickson [Thu, 27 Jan 2022 23:06:14 +0000 (18:06 -0500)] 
hwdb: add two Elecom trackballs

3 years agonetwork: fix log messages
Yu Watanabe [Fri, 28 Jan 2022 01:40:30 +0000 (10:40 +0900)] 
network: fix log messages

3 years agotest: frequency in mouse DPI is optional
Yu Watanabe [Fri, 28 Jan 2022 02:08:43 +0000 (11:08 +0900)] 
test: frequency in mouse DPI is optional

Prompted by #22278.

3 years agoMerge pull request #22277 from yuwata/test-network-activation-policy
Yu Watanabe [Fri, 28 Jan 2022 03:45:49 +0000 (12:45 +0900)] 
Merge pull request #22277 from yuwata/test-network-activation-policy

test-network: fixes for test_activation_policy

3 years agobpf: load firewall with name only if supported
Julia Kartseva [Fri, 28 Jan 2022 00:36:25 +0000 (16:36 -0800)] 
bpf: load firewall with name only if supported

BPF firewall is supported starting from v4.9 kernel where
BPF_PROG_TYPE_SOCKET_FILTER support was added [0].

However, program name support was added to v4.15 [1] and BPF_PROG_LOAD
syscall will fail on older kernels if called with prog_name attribute.
BPF_F_ALLOW_MULTI was also added to v4.15 kernel which allows reusing
BPF_F_ALLOW_MULTI probe to indicate that program name is also supported.

It is no problem for BPF_PROG_TYPE_CGROUP_DEVICE since it was added in
v4.15.

[0] https://elixir.bootlin.com/linux/v4.9/source/include/uapi/linux/bpf.h#L92
[1] https://elixir.bootlin.com/linux/v4.15/source/include/uapi/linux/bpf.h#L191

Follow-up of https://github.com/systemd/systemd/pull/22214

3 years agoMerge pull request #22272 from bluca/state_dir_private_rootfs
Yu Watanabe [Fri, 28 Jan 2022 03:04:41 +0000 (12:04 +0900)] 
Merge pull request #22272 from bluca/state_dir_private_rootfs

core: do not attempt to add 'private' symlinks when RootImage/RootDirectory are used

3 years agoman: extend the DHCPv6-PD example and add a DHCPv4-6RD example
Yu Watanabe [Thu, 27 Jan 2022 20:25:47 +0000 (05:25 +0900)] 
man: extend the DHCPv6-PD example and add a DHCPv4-6RD example

3 years agosd-device: suppress too many debugging log when enumerating devices 22283/head
Yu Watanabe [Fri, 28 Jan 2022 01:56:38 +0000 (10:56 +0900)] 
sd-device: suppress too many debugging log when enumerating devices

Follow-up for d7cb60daf6d3769f1e26753195d62e8fcee025fa.

3 years agolog: introduce log_trace_errno()
Yu Watanabe [Fri, 28 Jan 2022 01:50:36 +0000 (10:50 +0900)] 
log: introduce log_trace_errno()

3 years agoRevert "test: wait for user inactive" 22282/head
Yu Watanabe [Fri, 28 Jan 2022 01:44:12 +0000 (10:44 +0900)] 
Revert "test: wait for user inactive"

As it does not work, and the test still randomly fails.

This reverts commit de27f4c8b8dd230a936f1b467a1da275f6fe024b.

3 years agoRevert "test: wait for newly created btrfs triggered"
Yu Watanabe [Fri, 28 Jan 2022 01:42:51 +0000 (10:42 +0900)] 
Revert "test: wait for newly created btrfs triggered"

This reverts commit 39f83dd7606730f65eb9831703a8ea3667682a85.

As this does not solve the issue.

3 years agoMerge pull request #22276 from mrc0mmand/TEST-64-workaround
Luca Boccassi [Fri, 28 Jan 2022 00:56:04 +0000 (00:56 +0000)] 
Merge pull request #22276 from mrc0mmand/TEST-64-workaround

test: temporary workaround for #21819

3 years agocore: do not attempt to add 'private' symlinks when RootImage/RootDirectory are used 22272/head
Luca Boccassi [Thu, 27 Jan 2022 14:10:34 +0000 (14:10 +0000)] 
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

3 years agohwdb: treat logitech craft keyboard as a keyboard
Seth Falco [Thu, 27 Jan 2022 21:08:30 +0000 (21:08 +0000)] 
hwdb: treat logitech craft keyboard as a keyboard

3 years agotest-network: wait for a while if manual policy is always-{up,down} 22277/head
Yu Watanabe [Thu, 27 Jan 2022 22:29:32 +0000 (07:29 +0900)] 
test-network: wait for a while if manual policy is always-{up,down}

If wait_operstate() is called super quickly after ip command, then the
up/down state may not be changed and propagated to networkd, and
wait_operstate() mistakenly pass with the previous state.

To avoid such situation, wait for a while to make networkd actually
detect the interface brought up/down.

3 years agotest-network: dummy interface is initially down when activation policy is manual
Yu Watanabe [Thu, 27 Jan 2022 22:17:08 +0000 (07:17 +0900)] 
test-network: dummy interface is initially down when activation policy is manual

3 years agotest-network: wait for the link is activated
Yu Watanabe [Thu, 27 Jan 2022 22:02:00 +0000 (07:02 +0900)] 
test-network: wait for the link is activated

This fixes the following race:
1. when a dummy interface is created, it is initially down state,
2. hence, wait_operstate() may pass before the link is activated,
3. and the ip command bring up the interface before the activation,
4. and networkd activates, that is, brings down the interface,
5. thus, next wait_operstate() timedout, as it waits for the interface up.

To fix the race, let's wait the link is activated, before enter the loop
of wait_operstate().

Fixes #22267.

3 years agotest-network: always cleanup the testing environment
Yu Watanabe [Thu, 27 Jan 2022 21:59:43 +0000 (06:59 +0900)] 
test-network: always cleanup the testing environment

Previously, if a subtest fail, then the cleanup process does not run,
and affects the subsequent tests.

3 years agotest: temporary workaround for #21819 22276/head
Frantisek Sumsal [Thu, 27 Jan 2022 21:51:15 +0000 (22:51 +0100)] 
test: temporary workaround for #21819

Since the TEST-64-UDEV-STORAGE fails are quite frequent now and the root
cause is yet to be discovered, let's add a kludge that attempts to retry
the test up to two more times in case it fails, so we don't
unnecessarily disturb CIs while the issue is being investigated.

Revert this commit once #21819 is sorted out.

3 years agotest: don't leak local variable to outer scopes
Frantisek Sumsal [Thu, 27 Jan 2022 21:50:58 +0000 (22:50 +0100)] 
test: don't leak local variable to outer scopes

3 years agotree-wide: fix typo
Yu Watanabe [Thu, 27 Jan 2022 19:47:39 +0000 (04:47 +0900)] 
tree-wide: fix typo

3 years agoMerge pull request #22132 from joanbm/main
Yu Watanabe [Thu, 27 Jan 2022 19:23:34 +0000 (04:23 +0900)] 
Merge pull request #22132 from joanbm/main

resolved: Fix DoT timeout on multiple answer records (for CloudFlare, Google, etc. DoT servers)

3 years agoMerge pull request #22262 from DaanDeMeyer/journal-fixes
Yu Watanabe [Thu, 27 Jan 2022 19:15:11 +0000 (04:15 +0900)] 
Merge pull request #22262 from DaanDeMeyer/journal-fixes

Journal fixes

3 years agojournal: Truncate file instead of punching hole in final object 22262/head
Daan De Meyer [Thu, 27 Jan 2022 14:44:35 +0000 (14:44 +0000)] 
journal: Truncate file instead of punching hole in final object

Instead of punching a hole in the final object if it's an entry array,
let's just truncate the file instead.

3 years agojournal: stat journal file after truncating
Daan De Meyer [Tue, 25 Jan 2022 23:53:58 +0000 (23:53 +0000)] 
journal: stat journal file after truncating

Let's make sure the data stored in last_stat is up-to-date after
truncating the journal file.

3 years agocore: add clearer debug log when setting up ExecDirectories symlinks fails
Luca Boccassi [Thu, 27 Jan 2022 14:08:44 +0000 (14:08 +0000)] 
core: add clearer debug log when setting up ExecDirectories symlinks fails

3 years agotest: use mksquashfs -noappend
Luca Boccassi [Thu, 27 Jan 2022 14:08:05 +0000 (14:08 +0000)] 
test: use mksquashfs -noappend

Makes the setup idempotent, as mksquashfs by default attempts to
append to an existing image

3 years agotest: rename service used in TEST-29-PORTABLE to avoid conflict
Luca Boccassi [Thu, 27 Jan 2022 14:07:20 +0000 (14:07 +0000)] 
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

3 years agotest: initialize buffer to make Coverity silent
Yu Watanabe [Thu, 27 Jan 2022 07:29:20 +0000 (16:29 +0900)] 
test: initialize buffer to make Coverity silent

Follow-up for f82f0b993740f4a9a3719c4df7c185411710df2b.

Fixes CID#1469119.

3 years agoNEWS: mention temporary limitations for running containers in systemd-homed directories
Christian Brauner [Thu, 27 Jan 2022 09:39:47 +0000 (10:39 +0100)] 
NEWS: mention temporary limitations for running containers in systemd-homed directories

3 years agoMerge pull request #22259 from bluca/exec_cond_restart
Yu Watanabe [Thu, 27 Jan 2022 06:09:47 +0000 (15:09 +0900)] 
Merge pull request #22259 from bluca/exec_cond_restart

core: do not restart a service with Restart=always when ExecCondition fails

3 years agoresolved: Test for DnsStream (plain TCP DNS and DoT) 22132/head
Joan Bruguera [Sun, 23 Jan 2022 16:08:12 +0000 (17:08 +0100)] 
resolved: Test for DnsStream (plain TCP DNS and DoT)

Tests DnsStream event handling, both for plain TCP DNS and DNS over TLS.

The DoT test requires the "openssl s_server" command line tool to mock a simple
TLS server. Thus the test's TLS part is skipped if openssl it not available.
The test works for both DNS_OVER_TLS_USE_GNUTLS and DNS_OVER_TLS_USE_OPENSSL.

The DoT case fails due to a bug, which is fixed on the next commit.

3 years agoresolved: Fix DoT timeout on multiple answer records
Joan Bruguera [Sat, 15 Jan 2022 16:33:25 +0000 (17:33 +0100)] 
resolved: Fix DoT timeout on multiple answer records

When sending multiple DNS questions to a DNS-over-TLS server (e.g. a question
for A and AAAA records, as is typical) on the same session, the server may
answer to each question in a separate TLS record, but it may also aggregate
multiple answers in a single TLS record.
(Some servers do this very often (e.g. Cloudflare 1.0.0.1), some do it sometimes
(e.g. Google 8.8.8.8) and some seem to never do it (e.g. Quad9 9.9.9.10)).

Both cases should be handled equivalently, as the byte stream is the same, but
when multiple answers came in a single TLS record, usually the first answer was
processed, but the second answer was entirely ignored, which caused a 10s delay
until the resolution timed out and the missing question was retried.
This can be reproduced by configuring one of the offending server and running
`resolvectl query google.com --cache=no` a few times.

To be notified of incoming data, systemd-resolved listens to `EPOLLIN` events
on the underlying socket. However, when DNS-over-TLS is used, the TLS library
(OpenSSL or GnuTLS) may read and buffer the entire TLS record when reading the
first answer, so usually no further `EPOLLIN` events will be generated, and the
second answer will never be processed.

To avoid this, if there's buffered TLS data, generate a "fake" EPOLLIN event.
This is hacky, but it makes this case transparent to the rest of the IO code.

3 years agologind.conf: Fix name of option: RuntimeDirectoryInodes -> RuntimeDirectoryInodesMax
Arfrever Frehtes Taifersar Arahesis [Thu, 27 Jan 2022 00:00:00 +0000 (00:00 +0000)] 
logind.conf: Fix name of option: RuntimeDirectoryInodes -> RuntimeDirectoryInodesMax

3 years agotests: fuzz dhcp_server_relay_message
Evgeny Vereshchagin [Wed, 26 Jan 2022 18:45:55 +0000 (18:45 +0000)] 
tests: fuzz dhcp_server_relay_message

It's a follow-up to https://github.com/systemd/systemd/pull/19384 where
dhcp_server_relay_message was introduced.

This PR was prompted by https://github.com/systemd/systemd/pull/22236#issuecomment-1020113269
for the most part.

3 years agotree-wide: don't use strjoina() on getenv() values
Anita Zhang [Wed, 26 Jan 2022 18:53:40 +0000 (10:53 -0800)] 
tree-wide: don't use strjoina() on getenv() values

Avoid doing stack allocations on environment variables.

3 years agodocs: fix typos and improve language
Erik Sjölund [Wed, 26 Jan 2022 18:42:49 +0000 (19:42 +0100)] 
docs: fix typos and improve language

Fix typos and improve the language by
adding a few commas and a missing word.

3 years agoman: Fix paths for user units (transient/generator.early)
Rike-Benjamin Schuppner [Wed, 26 Jan 2022 17:21:11 +0000 (18:21 +0100)] 
man: Fix paths for user units (transient/generator.early)

3 years agoMerge pull request #22251 from medhefgo/boot-cleanup
Luca Boccassi [Wed, 26 Jan 2022 22:34:32 +0000 (22:34 +0000)] 
Merge pull request #22251 from medhefgo/boot-cleanup

boot: Small improvements

3 years agojournal: Stop comparing hash values from entry items against data objects
Daan De Meyer [Mon, 1 Nov 2021 14:33:08 +0000 (14:33 +0000)] 
journal: Stop comparing hash values from entry items against data objects

These checks don't achieve anything of value. Assuming they were added to
check for corruption, they don't actually achieve this goal since other parts
of the data object can still get corrupted and we wouldn't notice unless we'd
recalculate the hash every time.

In theory, we could use the entry item hash to avoid a random access lookup
for the data object hash in the journal file in the future to speed up searching,
but for finding all entry objects containing a specific data objects, we already
have entry arrays per data object to get fast access to this information.

This means that duplicating the hashes in the entry item doesn't result in any
added value. In this commit, we remove the checks so that in future commits we
can remove the hashes from the journal file format in the new compact mode.

3 years agojournal: Inline loop variable
Daan De Meyer [Thu, 13 Jan 2022 16:37:38 +0000 (16:37 +0000)] 
journal: Inline loop variable

3 years agojournal: Invert verify entry <=> data consistency checks
Daan De Meyer [Tue, 25 Jan 2022 13:26:22 +0000 (13:26 +0000)] 
journal: Invert verify entry <=> data consistency checks

Previously, for each entry in a data object's entry array, we'd check
if one of that entry's entry items referred to the data object.

Instead, when verifying the main entry array, let's check if for each
entry item found by iterating the main entry array, the corresponding
data object's entry array refers to that entry.

This enables us to re-use more code from journal-file and turns out to
be roughly 10s faster when verifying my 4G laptop journal.

When verifying data objects, we still check if every entry in the data
object's entry array also exists in the main entry array so that we ensure
we're not missing any entries when iterating the main entry array.

3 years agojournal: Fail gracefully when linking a new entry
Daan De Meyer [Tue, 25 Jan 2022 13:21:55 +0000 (13:21 +0000)] 
journal: Fail gracefully when linking a new entry

Let's always try to link all entry items even if linking one fails
due to not being able to allocate a new entry array. Other entry
items might still be successfully linked if the entry array of the
corresponding data object isn't full yet.

3 years agojournal: Use ret_offset everywhere in journal-file.h
Daan De Meyer [Tue, 25 Jan 2022 12:28:21 +0000 (12:28 +0000)] 
journal: Use ret_offset everywhere in journal-file.h

3 years agojournal: Only move to objects when necessary
Daan De Meyer [Tue, 25 Jan 2022 11:50:40 +0000 (11:50 +0000)] 
journal: Only move to objects when necessary

Let's make sure we only move to objects when it's required. If "ret"
is NULL, the caller isn't interested in the actual object and the
function being called shouldn't move to it unless it has to
inspect/modify the object itself.

3 years agojournal: Pass data objects to journal_file_move_to_entry_..._for_data() functions
Daan De Meyer [Tue, 25 Jan 2022 11:10:26 +0000 (11:10 +0000)] 
journal: Pass data objects to journal_file_move_to_entry_..._for_data() functions

This reduces the number of calls to journal_file_move_to_object() which are heavy.
All call sites have easy access to the data object so this change doesn't end up
complicating things.

3 years agojournal: Log error when keyed hash env variable cannot be parsed
Daan De Meyer [Tue, 18 Jan 2022 11:18:05 +0000 (11:18 +0000)] 
journal: Log error when keyed hash env variable cannot be parsed

3 years agojournal: Use offsetof(Object, ...) to retrieve object field offsets
Daan De Meyer [Mon, 24 Jan 2022 13:40:06 +0000 (13:40 +0000)] 
journal: Use offsetof(Object, ...) to retrieve object field offsets

We currently use both offsetof(Object, ...) and offsetof(DataObject, ...).
This makes it harder to grep for usages as we have to make sure we grep for
both usages. Let's unify these all to use offsetof(Object, ...) to make it
easier to grep for usages.

3 years agoNEWS: note breaking change w.r.t. Restart=always and ExecCondition= 22259/head
Luca Boccassi [Wed, 26 Jan 2022 19:03:34 +0000 (19:03 +0000)] 
NEWS: note breaking change w.r.t. Restart=always and ExecCondition=

3 years agocore: do not restart a service with Restart=always when ExecCondition fails
Luca Boccassi [Wed, 26 Jan 2022 19:00:25 +0000 (19:00 +0000)] 
core: do not restart a service with Restart=always when ExecCondition fails

When a Condition*= fails, and a service has Restart=always,
the service is not restarted.
Follow the same behaviour for ExecCondition= to avoid inconsistencies.

Fixes #22257

3 years agoboot: Add screen resolution to print status 22251/head
Jan Janssen [Wed, 26 Jan 2022 12:50:22 +0000 (13:50 +0100)] 
boot: Add screen resolution to print status

3 years agoboot: Also NUL-terminate for CHAR16 in file_reaad
Jan Janssen [Wed, 19 Jan 2022 12:28:32 +0000 (13:28 +0100)] 
boot: Also NUL-terminate for CHAR16 in file_reaad

3 years agoboot: Use ASSERT_PTR
Jan Janssen [Wed, 19 Jan 2022 11:10:32 +0000 (12:10 +0100)] 
boot: Use ASSERT_PTR

3 years agoboot: Optimize unique title generation
Jan Janssen [Wed, 19 Jan 2022 10:15:22 +0000 (11:15 +0100)] 
boot: Optimize unique title generation

3 years agoMerge pull request #22252 from medhefgo/boot-build
Yu Watanabe [Wed, 26 Jan 2022 16:32:04 +0000 (01:32 +0900)] 
Merge pull request #22252 from medhefgo/boot-build

meson: Boot build/test changes

3 years agoMerge pull request #22249 from yuwata/wait-online-fix-unmanaged-state
Yu Watanabe [Wed, 26 Jan 2022 16:17:12 +0000 (01:17 +0900)] 
Merge pull request #22249 from yuwata/wait-online-fix-unmanaged-state

wait-online: fix handling of unmanaged state

3 years agoshared: Ensure COPY_HOLES copies trailing holes
Daan De Meyer [Wed, 26 Jan 2022 12:08:50 +0000 (12:08 +0000)] 
shared: Ensure COPY_HOLES copies trailing holes

Previously, files with a hole at the end would get silently truncated
which breaks reading journal files. This commit makes sure that holes
are punched in existing space and if no more space is available, that
we grow the file and the hole by using ftruncate().

The corresponding test is extended to put a hole at the end of the file
and we make sure that hole is copied correctly.

3 years agowait-online: make manager_link_is_online() return 0 when in unmanaged state 22249/head
Yu Watanabe [Wed, 26 Jan 2022 07:48:08 +0000 (16:48 +0900)] 
wait-online: make manager_link_is_online() return 0 when in unmanaged state

Previously, even if a link is in unmanaged state, the function may
returns positive value. So, even if all managed links are in the configured
sate but do not satisfy the online criteria, e.g., IPv4 address state,
then wait-online finishes with positive value.

This makes the function always return 0 for unmanaged state. So, at
least one managed link must satisfies the online criteria.

This also adds more comments and debugging logs.

Fixes #22246.

3 years agowait-online: rename Manager elements
Yu Watanabe [Wed, 26 Jan 2022 11:54:39 +0000 (20:54 +0900)] 
wait-online: rename Manager elements

3 years agomeson: Use --no-wchar-size-warning 22252/head
Jan Janssen [Wed, 26 Jan 2022 11:29:57 +0000 (12:29 +0100)] 
meson: Use --no-wchar-size-warning

This only disables the one warning that we care to ignore, making
sure that any future issues do not get masked.

3 years agomeson: Use same name format for efi binary intermediates
Jan Janssen [Wed, 26 Jan 2022 09:20:46 +0000 (10:20 +0100)] 
meson: Use same name format for efi binary intermediates

3 years agomeson: Remove test-efi-create-disk.sh
Jan Janssen [Thu, 20 Jan 2022 10:59:49 +0000 (11:59 +0100)] 
meson: Remove test-efi-create-disk.sh

The script was probably not used for a very long time. It is currently
passed systemd_boot.so as boot loader, which cannot work. The test
entries it creates are all pointing at non-existant efi/linux binaries,
which means they would not even show up in the menu if the created image
were actually booted. There is also nothing that actually tries to run
the image in the first place.

If we end up creating a proper systemd-boot test suite, it would be
better to start from scratch. In the meantime, mkosi already covers
the bare minimum with a simple bootup test.

3 years agoportable: add flag to return extension-releases in GetImageMetadataWithExtensions
Luca Boccassi [Tue, 25 Jan 2022 15:49:22 +0000 (15:49 +0000)] 
portable: add flag to return extension-releases in GetImageMetadataWithExtensions

Return the name of each extension and the associated extension-release
file, and pretty-print them in 'portablectl inspect', if a new flag
is passed.

$ portablectl inspect --extension app2 --extension app0  minimal app0 app1
(Matching unit files with prefixes 'app0', 'app1'.)
Image:
        /run/portables/minimal.raw
Portable Service:
        n/a
Operating System:
        Debian GNU/Linux 10 (buster)
Extension:
        /run/portables/app2.raw
        Extension Scope:
                n/a
        Extension Compatibility Level:
                n/a
        Portable Service:
                n/a
        Portable Prefixes:
                n/a
        Operating System:
                n/a (debian 10)
Extension:
        /run/portables/app0.raw
        Extension Scope:
                n/a
        Extension Compatibility Level:
                n/a
        Portable Service:
                n/a
        Portable Prefixes:
                n/a
        Operating System:
                n/a (debian 10)
Unit files:
        app0.service

3 years agoportable: add GetImageStateWithExtensions method
Luca Boccassi [Mon, 24 Jan 2022 17:42:32 +0000 (17:42 +0000)] 
portable: add GetImageStateWithExtensions method

Allow to correctly query a layered portable service for
attached/detached state.

3 years agohostname: expose hardware serial through dbus
Yu Watanabe [Sat, 22 Jan 2022 18:12:35 +0000 (03:12 +0900)] 
hostname: expose hardware serial through dbus

Closes #22119.

3 years agoNEWS: update
Yu Watanabe [Mon, 24 Jan 2022 18:03:09 +0000 (03:03 +0900)] 
NEWS: update

3 years agoNEWS: mention about the regression in WireGuard
Yu Watanabe [Mon, 24 Jan 2022 17:40:37 +0000 (02:40 +0900)] 
NEWS: mention about the regression in WireGuard

3 years agoMerge pull request #22236 from yuwata/fuzz-dhcp-server
Yu Watanabe [Mon, 24 Jan 2022 17:19:22 +0000 (02:19 +0900)] 
Merge pull request #22236 from yuwata/fuzz-dhcp-server

fuzz-dhcp-server: three fixes or improvements

3 years agofuzz-dhcp-server: attach sd_event to make dhcp_server_cleanup_expired_leases() works... 22236/head
Yu Watanabe [Mon, 24 Jan 2022 15:04:59 +0000 (00:04 +0900)] 
fuzz-dhcp-server: attach sd_event to make dhcp_server_cleanup_expired_leases() works in the fuzzer

Otherwise, most code paths in dhcp_server_handle_message() are not
evaluated by the fuzzer.

3 years agoUpdate systemd.netdev.xml
march1993 [Mon, 17 Jan 2022 14:11:28 +0000 (22:11 +0800)] 
Update systemd.netdev.xml

Mind users to avoid use name gre0, gretap0 and erspan0 for GRE tunnels.

3 years agouser-runtime-dir: error out immediately if mkdir fails
Zbigniew Jędrzejewski-Szmek [Mon, 24 Jan 2022 09:53:00 +0000 (10:53 +0100)] 
user-runtime-dir: error out immediately if mkdir fails

We try to create two directories: /run/user and /run/user/<UID>. For the
first we check the return value and error out if creation fails. But for
the second one we continued based on the assumption that the subsequent
mount will immediately fail anyway. But this has the disadvantage that we
get a somewhat confusing error message:

janv. 23 22:04:31 nsfw systemd-user-runtime-dir[1660]: Failed to mount per-user tmpfs directory /run/user/1000: No such file or directory

Let's instead fail immediately with a precise error message.

For https://bugzilla.redhat.com/show_bug.cgi?id=2044100.

3 years agoMerge pull request #22203 from brauner/2022-01-21.procsubset.pid
Luca Boccassi [Mon, 24 Jan 2022 13:04:23 +0000 (13:04 +0000)] 
Merge pull request #22203 from brauner/2022-01-21.procsubset.pid

core/namespace: allow using ProtectSubset=pid and ProtectHostname=tru…

3 years agoMerge pull request #22231 from yuwata/resolve-synthesize
Luca Boccassi [Mon, 24 Jan 2022 12:11:29 +0000 (12:11 +0000)] 
Merge pull request #22231 from yuwata/resolve-synthesize

resolve: synthesize several filtered name

3 years agofuzz-dhcp-server: duplicate input data
Yu Watanabe [Mon, 24 Jan 2022 10:35:14 +0000 (19:35 +0900)] 
fuzz-dhcp-server: duplicate input data

As `dhcp_server_handle_message()` -> `ensure_sane_request()` may modify
the input data, and that causes error in some fuzzing engine.

3 years agofuzz-dhcp-server: also set new lease elements correctly
Yu Watanabe [Mon, 24 Jan 2022 10:26:25 +0000 (19:26 +0900)] 
fuzz-dhcp-server: also set new lease elements correctly

The fuzzer does not send anything to the address, so it should be not
necessary, but just for safety.

3 years agocore/namespace: s/normalize_mounts()/drop_unused_mounts() 22203/head
Christian Brauner [Mon, 24 Jan 2022 09:12:57 +0000 (10:12 +0100)] 
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
3 years agocore/namespace: allow using ProtectSubset=pid and ProtectHostname=true together
Christian Brauner [Fri, 21 Jan 2022 12:08:19 +0000 (13:08 +0100)] 
core/namespace: allow using ProtectSubset=pid and ProtectHostname=true together

If a service requests both ProtectSubset=pid and ProtectHostname=true
then it will currently fail to start. The ProcSubset=pid option
instructs systemd to mount procfs for the service with subset=pid which
hides all entries other than /proc/<pid>. Consequently trying to
interact with the two files /proc/sys/kernel/{hostname,domainname}
covered by ProtectHostname=true will fail.

Fix this by only performing this check when ProtectSubset=pid is not
requested. Essentially ProtectSubset=pid implies/provides
ProtectHostname=true.

3 years agobuild(deps): bump github/codeql-action from 1.0.27 to 1.0.29
dependabot[bot] [Mon, 24 Jan 2022 07:37:07 +0000 (07:37 +0000)] 
build(deps): bump github/codeql-action from 1.0.27 to 1.0.29

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1.0.27 to 1.0.29.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/cd783c8a29bdcf5a5c79c5137889e24651fa626c...384cfc42b2131df01c009d3d2eed7b78d8e8556e)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years agoMerge pull request #22226 from yuwata/hostname-allow-to-override-hardware-vendor...
Yu Watanabe [Sun, 23 Jan 2022 21:55:29 +0000 (06:55 +0900)] 
Merge pull request #22226 from yuwata/hostname-allow-to-override-hardware-vendor-and-model

hostname: allow to override hardware vendor and model

3 years agoMerge pull request #22227 from yuwata/dhcp-server-fix-heap-buffer-overflow
Yu Watanabe [Sun, 23 Jan 2022 21:55:02 +0000 (06:55 +0900)] 
Merge pull request #22227 from yuwata/dhcp-server-fix-heap-buffer-overflow

sd-dhcp-server: fix heap buffer overflow

3 years agogithub: point to "tags" instead of "releases" in systemd-stable
Frantisek Sumsal [Sun, 23 Jan 2022 21:49:57 +0000 (22:49 +0100)] 
github: point to "tags" instead of "releases" in systemd-stable

since we don't do releases there.

Mentioned in https://github.com/systemd/systemd/issues/22230#issue-1111991271.

3 years agoresolve: synthesize null address, IPv4 broadcast address, or invalid domain 22231/head
Yu Watanabe [Sun, 23 Jan 2022 21:36:53 +0000 (06:36 +0900)] 
resolve: synthesize null address, IPv4 broadcast address, or invalid domain

These are filtered in `dns_scope_good_domain()`, but not synthesized.

Fixes #22229.

3 years agoresolve: synthesize empty name
Yu Watanabe [Sun, 23 Jan 2022 21:07:33 +0000 (06:07 +0900)] 
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).

3 years agodns-domain: re-introduce dns_name_is_empty()
Yu Watanabe [Sun, 23 Jan 2022 21:06:55 +0000 (06:06 +0900)] 
dns-domain: re-introduce dns_name_is_empty()

3 years agoRevert "resolve: refuse to resolve empty hostname"
Yu Watanabe [Sun, 23 Jan 2022 20:51:47 +0000 (05:51 +0900)] 
Revert "resolve: refuse to resolve empty hostname"

This reverts commit 6e8ecb8974db74eba716bfd75231987172e10d83.

3 years agofuzz: add testcases of heap-buffer-overflow for sd-dhcp-server 22227/head
Yu Watanabe [Sun, 23 Jan 2022 19:52:33 +0000 (04:52 +0900)] 
fuzz: add testcases of heap-buffer-overflow for sd-dhcp-server

3 years agosd-dhcp-server: fix heap buffer overflow
Yu Watanabe [Sun, 23 Jan 2022 19:49:30 +0000 (04:49 +0900)] 
sd-dhcp-server: fix heap buffer overflow

This checks client hardware length earlier.

3 years agoMerge pull request #22222 from yuwata/dhcp-server-support-non-ethernet-packet
Yu Watanabe [Sun, 23 Jan 2022 19:19:26 +0000 (04:19 +0900)] 
Merge pull request #22222 from yuwata/dhcp-server-support-non-ethernet-packet

dhcp-server: support packets from non-Ethernet interfaces

3 years agosd-dhcp-server: support packet from non-Ethernet interface 22222/head
Yu Watanabe [Sat, 22 Jan 2022 17:27:32 +0000 (02:27 +0900)] 
sd-dhcp-server: support packet from non-Ethernet interface

Fixes #22217.

3 years agosd-dhcp-client,sd-dhcp-client-server: set chaddr in dhcp_message_init()
Yu Watanabe [Sat, 22 Jan 2022 17:14:31 +0000 (02:14 +0900)] 
sd-dhcp-client,sd-dhcp-client-server: set chaddr in dhcp_message_init()

And also set chaddr and hlen for packets on non-Ethernet interfaces,
except for InfiniBand.

3 years agosd-dhcp-client: fix RFC number
Yu Watanabe [Sun, 23 Jan 2022 02:15:43 +0000 (11:15 +0900)] 
sd-dhcp-client: fix RFC number