]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
15 months agonetwork: do not request dynamic addressing protocols finished when at least one stati... 27826/head
Yu Watanabe [Mon, 29 May 2023 03:56:30 +0000 (12:56 +0900)] 
network: do not request dynamic addressing protocols finished when at least one static address is configured

The setting IPv6AcceptRA= is defaults to yes, hence, even if a .network
file for an interface has static IP address configuration, it may takes
few seconds for the interface being configured state, as NDisc for the
interface needs to be finished. That makes wait-online.service
needlessly slow. Typically, such delay is not necessary for statically
configured networks.

Let's make the required condition slightly relaxed; if a .network file
has static IP address configurations, then let's make the matching
interface enter the 'configured' state soon after the static addresses
configured on the interface.

Note, this does not change the default for IPv6AcceptRA=, hence, NDisc
still runs on interfaces by default. So, addresses, routes, DNS servers,
and so on based on RA will be assigned on interfaces later.

Strictly speaking, this breaks backward compatibility, but the previous
behavior is not clearly documented. If a user requested both static
IPv4 address and IPv6 SLAAC address configured before an interface being
entered to the 'configured' state, then '--ipv6' for wait-online can be
used. So, the behavior change should not cause severe regression.

Closes #27779.

15 months agonetwork: require DHCP protocol to be finished when an address of delegated prefix...
Yu Watanabe [Tue, 30 May 2023 06:29:05 +0000 (15:29 +0900)] 
network: require DHCP protocol to be finished when an address of delegated prefix is assigned

15 months agonetwork: rewrite dynamic addressing protocol checkers in link_check_ready()
Yu Watanabe [Tue, 30 May 2023 05:50:17 +0000 (14:50 +0900)] 
network: rewrite dynamic addressing protocol checkers in link_check_ready()

Notable change is,
- UseAddress=no in [DHCPv6],
- Assign=no in [DHCPPrefixDelegation], and
- UseAutonomousPrefix=no in [IPv6AcceptRA]
are gracefully handled now.

15 months agobpf: test with GCC BPF compiler on opensuse
James Hilliard [Mon, 29 May 2023 21:45:13 +0000 (15:45 -0600)] 
bpf: test with GCC BPF compiler on opensuse

15 months agohome: move the assert back to the intended place
Frantisek Sumsal [Mon, 29 May 2023 18:28:34 +0000 (20:28 +0200)] 
home: move the assert back to the intended place

98d81cf974 moved the assertion at the beginning of home_dispatch_acquire(),
which is however before we even check for any ongoing operation, hence we
might hit it even in legitimate cases.

Let's move it back to after we check for any possibly ongoing operation, to
make it once again a safety check.

Follow-up to 98d81cf974.
Resolves: #22443 and #24036

15 months agobpf: stabilize GCC BPF support
James Hilliard [Mon, 29 May 2023 21:01:34 +0000 (15:01 -0600)] 
bpf: stabilize GCC BPF support

Now that we have a GCC release which should support our bpf programs
lets set the minimum version and stabilize it.

15 months agoresolvectl: drop extra colon
David Tardon [Sun, 28 May 2023 20:30:48 +0000 (22:30 +0200)] 
resolvectl: drop extra colon

15 months agobasic/syscall: update syscall list
Yu Watanabe [Sun, 28 May 2023 15:05:38 +0000 (00:05 +0900)] 
basic/syscall: update syscall list

Only notable change is that memfd_secret is now defined on s390(x).

15 months agogpt/DPS: add more aliases for python's machine
Luca Boccassi [Fri, 26 May 2023 19:45:29 +0000 (20:45 +0100)] 
gpt/DPS: add more aliases for python's machine

In mkosi we set the default architecture to platform.machine() which
is again slightly incompatible for a few architectures, so add more
aliases, so that repart works by default with these names.

15 months agopo: add a false positive to POTFILES.skip
Piotr Drąg [Sat, 27 May 2023 16:11:35 +0000 (18:11 +0200)] 
po: add a false positive to POTFILES.skip

Scripts used to detect files that should be in POTFILES.in, like
intltool-update -m used on https://l10n.gnome.org/module/systemd/,
falsely detect this file as containing translations. Avoid this
behavior by putting the file in POTFILES.skip.

15 months agotree-wide: Downgrade a few more noisy log messages to trace
Daan De Meyer [Sat, 27 May 2023 08:36:30 +0000 (10:36 +0200)] 
tree-wide: Downgrade a few more noisy log messages to trace

16 months agoboot/measure: replace TPM PolicyPCR session with calculation
Dan Streetman [Fri, 5 May 2023 23:48:14 +0000 (19:48 -0400)] 
boot/measure: replace TPM PolicyPCR session with calculation

Instead of using a trial policy with a TPM to calculate the measurement hash,
this uses a function to calculate the hash with no TPM needed.

16 months agoMerge pull request #27721 from yuwata/journalctl-cleanup
Yu Watanabe [Fri, 26 May 2023 22:59:22 +0000 (07:59 +0900)] 
Merge pull request #27721 from yuwata/journalctl-cleanup

journalctl: split get_boots() into three

16 months agoAdd DHCPServer information to JSON output.
Rene Hollander [Sun, 30 Apr 2023 11:31:28 +0000 (13:31 +0200)] 
Add DHCPServer information to JSON output.

Adds a new JSON object called DHCPServer for each interface that has a
DHCPServer configured. It has the following attributes:
- PoolSize and PoolOffset from the configuration
- List of offered leases
- List of static leases from the configuration

16 months agoRevert "test: add test case for systemd-update-utmp vs daemon-reexec"
Frantisek Sumsal [Fri, 26 May 2023 19:41:43 +0000 (21:41 +0200)] 
Revert "test: add test case for systemd-update-utmp vs daemon-reexec"

Temporarily revert the test case for #27167, as the additional
daemon-reexecs exacerbate #27287, making CIs fail quite often.
As the #27167 is also covered by TEST-01-BASIC itself, since we do
daemon-reexec there anyway, we shouldn't lose any coverage, but it
should make CIs more stable until #27287 is figured out.

Resolves (or more like works around): #27807

This reverts commit d689f70a2c18666bbf6500df7a53962a8f3e91a4.

16 months agoMerge pull request #27517 from ddstreet/tpm2_calculate_policy
Daan De Meyer [Fri, 26 May 2023 21:08:15 +0000 (23:08 +0200)] 
Merge pull request #27517 from ddstreet/tpm2_calculate_policy

Tpm2 calculate policy

16 months agojournalctl: split get_boots() into three 27721/head
Yu Watanabe [Fri, 26 May 2023 18:57:39 +0000 (03:57 +0900)] 
journalctl: split get_boots() into three

Previously, get_boots() used for three ways; finding boot entry by
boot ID, finding boot entry by offset, listing up all boot IDs.

Let's split it into three for each usecase.

No functional change, just refactoring.

16 months agologs-show: introduce add_match_boot_id() helper function
Yu Watanabe [Sun, 21 May 2023 14:06:28 +0000 (23:06 +0900)] 
logs-show: introduce add_match_boot_id() helper function

16 months agoMerge pull request #27787 from keszybz/firstboot-synchronous-restart
Mike Yuan [Fri, 26 May 2023 18:30:45 +0000 (02:30 +0800)] 
Merge pull request #27787 from keszybz/firstboot-synchronous-restart

firstboot: make restart of vconsole-setup synchronuous

16 months agoMerge pull request #27786 from YHNdnzj/format-timestamp-monotonic
Yu Watanabe [Fri, 26 May 2023 18:05:34 +0000 (03:05 +0900)] 
Merge pull request #27786 from YHNdnzj/format-timestamp-monotonic

time-util,format-table: add relative_monotonic variant for timestamp

16 months agoMerge pull request #27803 from mrc0mmand/even-more-nalloc-shenanigans
Yu Watanabe [Fri, 26 May 2023 17:58:32 +0000 (02:58 +0900)] 
Merge pull request #27803 from mrc0mmand/even-more-nalloc-shenanigans

A couple more fixes for potential OOM-related issues

16 months agogpt/DPS: alias amd64 to x86-64 and aarch64 to arm64
Luca Boccassi [Fri, 26 May 2023 14:44:42 +0000 (15:44 +0100)] 
gpt/DPS: alias amd64 to x86-64 and aarch64 to arm64

The DSP and our implementation mixes Debian terminology with CPU
terminology. It uses arm64 which is a Debian thing instead of
aarch64, but x86-64 which is a CPU thing instead of amd64.
Add some convenience and transparent aliasing, so that we don't
need to maintain architecture-specific and tool-specific translation
layers in mkosi among other places, while at the same time the DDIs
still look the same (ie: the partlabel does not change depending on
which alias is used, the canonical label is used on disk).

16 months agotest-gpt: verify that alias entries are identical to the primary ones
Lennart Poettering [Fri, 26 May 2023 14:55:29 +0000 (16:55 +0200)] 
test-gpt: verify that alias entries are identical to the primary ones

Given we allow aliases we better check for consistency of alias entries
and the primary one.

16 months agotpm2: add tpm2_calculate_sealing_policy() 27517/head
Dan Streetman [Thu, 15 Dec 2022 17:56:35 +0000 (12:56 -0500)] 
tpm2: add tpm2_calculate_sealing_policy()

This adds a function to fully calculate the authPolicy needed to seal a secret,
and updates tpm2_seal() to use the new function instead of a trial policy.

16 months agotpm2: use tpm2_policy_authorize()
Dan Streetman [Thu, 9 Feb 2023 15:04:58 +0000 (10:04 -0500)] 
tpm2: use tpm2_policy_authorize()

This updates the function to build the sealing policy to use the dedicated
function to perform PolicyAuthorize.

This is separate from the previous commit to make each commit easier to read.

16 months agotpm2: add tpm2_policy_authorize()
Dan Streetman [Fri, 9 Dec 2022 19:49:52 +0000 (14:49 -0500)] 
tpm2: add tpm2_policy_authorize()

This adds functions to get the digest for a PolicyAuthorize operation. For
building a policy hash, this provides a function to calculate the hash; and for
building a policy hash to satisfy the authPolicy for an existing object, this
provides a function to perform PolicyAuthorize with an existing session.

16 months agotpm2: add tpm2_policy_auth_value()
Dan Streetman [Fri, 9 Dec 2022 19:59:05 +0000 (14:59 -0500)] 
tpm2: add tpm2_policy_auth_value()

This adds functions to get the digest for a PolicyAuthValue operation. For
building a policy hash, this provides a function to calculate the hash; and for
building a policy hash to satisfy the authPolicy for an existing object, this
provides a function to perform PolicyAuthValue with an existing session.

16 months agotpm2: add tpm2_policy_pcr()
Dan Streetman [Thu, 8 Dec 2022 22:56:11 +0000 (17:56 -0500)] 
tpm2: add tpm2_policy_pcr()

This adds functions to get the digest for a PolicyPCR operation. For building
a policy hash, this provides a function to calculate the hash; and for building
a policy hash to satisfy the authPolicy for an existing object, this provides a
function to perform PolicyPCR with an existing session.

16 months agotpm2: rename pcr_values_size vars to n_pcr_values
Dan Streetman [Thu, 11 May 2023 19:33:31 +0000 (15:33 -0400)] 
tpm2: rename pcr_values_size vars to n_pcr_values

Using the n_ prefix is more appropriate/conventional than the _size suffix.

No functional change, this is cosmetic only.

16 months agotpm2: add tpm2_get_name()
Dan Streetman [Wed, 14 Dec 2022 15:46:13 +0000 (10:46 -0500)] 
tpm2: add tpm2_get_name()

This adds functions to get the "name" of a key. The key "name", as defined
by the TPM2 spec, includes its entire public area (with attribute fields),
not only its key fingerprint.

A function is added to calculate the name of a provided key public area,
as well as a function to get the name of a key which is present in the TPM.

16 months agotpm2: add tpm2_set_auth()
Dan Streetman [Tue, 6 Dec 2022 18:16:43 +0000 (13:16 -0500)] 
tpm2: add tpm2_set_auth()

This provides a function to perform the SetAuth TPM function, which provides
the authValue for a key.

16 months agotpm2: replace hash_pin() with tpm2_digest_*() functions
Dan Streetman [Wed, 14 Dec 2022 15:46:13 +0000 (10:46 -0500)] 
tpm2: replace hash_pin() with tpm2_digest_*() functions

The hash_pin() function is just a specific use case of the digest functions.

16 months agotpm2: add tpm2_digest_*() functions
Dan Streetman [Wed, 14 Dec 2022 15:46:13 +0000 (10:46 -0500)] 
tpm2: add tpm2_digest_*() functions

These functions allow extending (or initializing) a TPM2B_DIGEST with additional
data, using a specified hash operation. This is needed to perform hash
calculations instead of relying on the TPM to perform the calculations in
trial sessions.

16 months agoman: fix UKI filename suffix in 'tries' description
Vitaly Kuznetsov [Fri, 26 May 2023 14:57:37 +0000 (16:57 +0200)] 
man: fix UKI filename suffix in 'tries' description

Boot Loader Type #2 entries (UKIs in $BOOT/EFI/Linux/) have '.efi' suffix,
not '.conf'.

16 months agomount-util: Downgrade another noisy debug log to trace level
Daan De Meyer [Fri, 26 May 2023 14:14:46 +0000 (16:14 +0200)] 
mount-util: Downgrade another noisy debug log to trace level

16 months agonspawn: restore cross-architecture booting
Luca Boccassi [Fri, 26 May 2023 11:42:42 +0000 (12:42 +0100)] 
nspawn: restore cross-architecture booting

The check added by 4c27749b8c6b24ef7481ba183ae1fca3749afbf7 breaks
booting an arm64 image on x86 using qemu-bin-fmt, so remove it.
Without it, the image built with mkosi --architecture=aarch64
boots fine in nspawn.

16 months agoudev: introduce .PART_SUFFIX internal property
Yu Watanabe [Wed, 24 May 2023 04:05:56 +0000 (13:05 +0900)] 
udev: introduce .PART_SUFFIX internal property

To make unify rules for disk and partition.

16 months agoMerge pull request #27746 from yuwata/unit-bidirectional-dep
Zbigniew Jędrzejewski-Szmek [Fri, 26 May 2023 14:20:48 +0000 (16:20 +0200)] 
Merge pull request #27746 from yuwata/unit-bidirectional-dep

core/unit: make unit dependency always bidirectional

16 months agosd-network: avoid leaking DHCPLease 27803/head
Frantisek Sumsal [Fri, 26 May 2023 09:38:58 +0000 (11:38 +0200)] 
sd-network: avoid leaking DHCPLease

If we fail any allocation prior adding the lease to the server lease
hashmap.

==2103==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 128 byte(s) in 2 object(s) allocated from:
    #0 0x4a203e in __interceptor_calloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0x4f6341 in calloc (/build/fuzz-dhcp-server+0x4f6341)
    #2 0x4ec818 in add_lease /work/build/../../src/systemd/src/libsystemd-network/fuzz-dhcp-server.c:26:9
    #3 0x4ec2bf in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/libsystemd-network/fuzz-dhcp-server.c:75:9
    #4 0x4f68a8 in NaloFuzzerTestOneInput (/build/fuzz-dhcp-server+0x4f68a8)
    #5 0x5158b3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #6 0x51509a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
    #7 0x516769 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
    #8 0x517435 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
    #9 0x50679f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
    #10 0x507068 in LLVMFuzzerRunDriver /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:925:10
    #11 0x4f6b25 in main (/build/fuzz-dhcp-server+0x4f6b25)
    #12 0x7f16084e3082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)

DEDUP_TOKEN: __interceptor_calloc--calloc--add_lease
SUMMARY: AddressSanitizer: 128 byte(s) leaked in 2 allocation(s).

Found by Nallocufzz.

16 months agosd-journal: log about errors from ordered_hashmap_*()
Frantisek Sumsal [Thu, 25 May 2023 09:58:32 +0000 (11:58 +0200)] 
sd-journal: log about errors from ordered_hashmap_*()

Follow-up to 08a8fd6e8d.

16 months agojournal-remote: bump the refcount right after creating the writer object
Frantisek Sumsal [Thu, 25 May 2023 20:47:13 +0000 (22:47 +0200)] 
journal-remote: bump the refcount right after creating the writer object

Otherwise we might hit an assertion during cleanup if the
following mmap_cache_new() call fails:

Assertion 'p->n_ref > 0' failed at src/journal-remote/journal-remote-write.c:80, function writer_unref(). Aborting.

==2069==ERROR: AddressSanitizer: ABRT on unknown address 0x000000000815 (pc 0x7f39dcd0200b bp 0x7ffe2fe24db0 sp 0x7ffe2fe24b60 T0)
SCARINESS: 10 (signal)
    #0 0x7f39dcd0200b in raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
    #1 0x7f39dcce1858 in abort (/lib/x86_64-linux-gnu/libc.so.6+0x22858) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
    #2 0x7f39dd747e49 in log_assert_failed /work/build/../../src/systemd/src/basic/log.c:940:9
    #3 0x4e4431 in writer_unref /work/build/../../src/systemd/src/journal-remote/journal-remote-write.c:80:1
    #4 0x4e3fd5 in writer_unrefp /work/build/../../src/systemd/src/journal-remote/journal-remote-write.h:27:1
    #5 0x4e3fd5 in writer_new /work/build/../../src/systemd/src/journal-remote/journal-remote-write.c:56:1
    #6 0x4e04bc in journal_remote_get_writer /work/build/../../src/systemd/src/journal-remote/journal-remote.c:125:21
    #7 0x4e0e0b in get_source_for_fd /work/build/../../src/systemd/src/journal-remote/journal-remote.c:181:13
    #8 0x4e0e0b in journal_remote_add_source /work/build/../../src/systemd/src/journal-remote/journal-remote.c:233:13
    #9 0x4df99f in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/journal-remote/fuzz-journal-remote.c:54:9
    #10 0x4e8f48 in NaloFuzzerTestOneInput (/build/fuzz-journal-remote+0x4e8f48)
    #11 0x507f53 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #12 0x50773a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
    #13 0x508e09 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
    #14 0x509ad5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
    #15 0x4f8e3f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
    #16 0x4f9708 in LLVMFuzzerRunDriver /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:925:10
    #17 0x4e91c5 in main (/build/fuzz-journal-remote+0x4e91c5)
    #18 0x7f39dcce3082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
    #19 0x420bcd in _start (/build/fuzz-journal-remote+0x420bcd)

DEDUP_TOKEN: raise--abort--log_assert_failed
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: ABRT (/lib/x86_64-linux-gnu/libc.so.6+0x4300b) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee) in raise

Found by Nallocufzz.

16 months agoMerge pull request #27554 from ElvishJerricco/tmpfiles-c-escapes
Zbigniew Jędrzejewski-Szmek [Fri, 26 May 2023 13:42:48 +0000 (15:42 +0200)] 
Merge pull request #27554 from ElvishJerricco/tmpfiles-c-escapes

tmpfiles: Allow C escapes

16 months agovarious: fix error message for bus_wait_for_jobs_new() 27787/head
Zbigniew Jędrzejewski-Szmek [Fri, 26 May 2023 13:09:03 +0000 (15:09 +0200)] 
various: fix error message for bus_wait_for_jobs_new()

As pointed out by Mike Yuan in review of grandparent commit,
bus_wait_for_jobs_new() can also fail for non-oom reasons.

16 months agounits: order systemd-firstboot after systemd-tmpfiles-setup
Zbigniew Jędrzejewski-Szmek [Thu, 25 May 2023 11:36:17 +0000 (13:36 +0200)] 
units: order systemd-firstboot after systemd-tmpfiles-setup

We may copy files from factory to /etc. The default mkosi config has
factory/etc/vconsole.conf. systemd-firstboot would race with tmpfiles-setup,
and sometimes ask for the keymap, and sometimes not.

I guess that if there are files in factory, we shouldn't ask the user for
the same configuration.

16 months agofirstboot: synchronously wait for systemd-vconsole-setup.service/restart job
Zbigniew Jędrzejewski-Szmek [Thu, 25 May 2023 10:26:37 +0000 (12:26 +0200)] 
firstboot: synchronously wait for systemd-vconsole-setup.service/restart job

Requested in https://github.com/systemd/systemd/pull/27755#pullrequestreview-1443489520.

I dropped the info message about the job being requested, because we get
fairly verbose logs from starting the unit, and the additional message isn't
useful.

In the unit, the ordering before systemd-vconsole-setup.service is dropped,
because now it needs to happen in parallel, while systemd-firstboot.service
is running. This means that we may potentially execute vconsole-setup twice,
but it's fairly quick, so this doesn't matter much.

16 months agofstab-generator: use correct swap name var
Frantisek Sumsal [Fri, 26 May 2023 12:05:40 +0000 (14:05 +0200)] 
fstab-generator: use correct swap name var

Follow-up to 9445623363.

16 months agoMerge pull request #27563 from yuwata/fstab-generator
Lennart Poettering [Fri, 26 May 2023 09:52:19 +0000 (02:52 -0700)] 
Merge pull request #27563 from yuwata/fstab-generator

fstab-generator: support defining mount units through kernel command line

16 months agocore: change 'basename' to 'path_extract_filename'
Jordan Rome [Thu, 25 May 2023 21:40:58 +0000 (14:40 -0700)] 
core: change 'basename' to 'path_extract_filename'

This is part of a cleanup effort in the TODO doc.

Tested locally: `meson compile -C build && meson test -C build`

16 months agocore/unit: update bidirectional dependency simultaneously 27746/head
Yu Watanabe [Tue, 23 May 2023 08:49:16 +0000 (17:49 +0900)] 
core/unit: update bidirectional dependency simultaneously

Previously, if unit_add_dependency_hashmap() failed, then a
one-directional unit dependency reference might be created, and
triggeres use-after-free. See issue #27742 for more details.

This makes unit dependency always bidirectional, and cleanly revert
partial update on failure.

Fixes #27742.

16 months agocore/unit: search shared namespace in transitive relation of JoinsNamespaceOf=
Yu Watanabe [Thu, 25 May 2023 09:08:37 +0000 (18:08 +0900)] 
core/unit: search shared namespace in transitive relation of JoinsNamespaceOf=

Previously, dependency chain of JoinsNamespaceOf= did not work, e.g.
- a.service has JoinsNamespaceOf=b.service
- b.service has JoinsNamespaceOf=c.service
if, first c.service, next a.service, finally b.service is started,
then a.service is not joined to the namespace of c.service. And, as
mentioned in the document, the namespace used by b.service is not
deterministic.

This makes when searching exsiting namespace to be joined, all units in
the transitive dependency of JoinsNamespaceOf= are checked.

16 months agologinctl: use FORMAT_TIMESTAMP_RELATIVE_MONOTONIC 27786/head
Mike Yuan [Thu, 25 May 2023 10:35:08 +0000 (18:35 +0800)] 
loginctl: use FORMAT_TIMESTAMP_RELATIVE_MONOTONIC

Follow-up for #27769

Addresses https://github.com/systemd/systemd/pull/27769#discussion_r1205215743

16 months agologinctl: realign bus_properties_map
Mike Yuan [Thu, 25 May 2023 10:25:15 +0000 (18:25 +0800)] 
loginctl: realign bus_properties_map

16 months agosystemctl: list-units: use TABLE_TIMESTAMP_RELATIVE_MONOTONIC
Mike Yuan [Thu, 25 May 2023 10:23:17 +0000 (18:23 +0800)] 
systemctl: list-units: use TABLE_TIMESTAMP_RELATIVE_MONOTONIC

16 months agotime-util,format-table: add relative_monotonic variant for timestamp
Mike Yuan [Thu, 25 May 2023 09:47:57 +0000 (17:47 +0800)] 
time-util,format-table: add relative_monotonic variant for timestamp

16 months agotmpfiles: Allow C escapes 27554/head
Will Fancher [Sat, 6 May 2023 20:11:58 +0000 (16:11 -0400)] 
tmpfiles: Allow C escapes

Fixes #26955

16 months agotmpfiles: Test C-style escape sequences
Will Fancher [Fri, 26 May 2023 04:02:35 +0000 (00:02 -0400)] 
tmpfiles: Test C-style escape sequences

16 months agotest: split the ASan wrapper into smaller blocks and tidy it up a bit
Frantisek Sumsal [Thu, 25 May 2023 13:31:48 +0000 (15:31 +0200)] 
test: split the ASan wrapper into smaller blocks and tidy it up a bit

No functional change (hopefully), just making it easier on the eyes.

16 months agocore/unit: make JoinsNamespaceOf= implies the inverse dependency
Yu Watanabe [Mon, 22 May 2023 21:36:44 +0000 (06:36 +0900)] 
core/unit: make JoinsNamespaceOf= implies the inverse dependency

Previously, even if a.service has JoinsNamespaceOf=b.service, the
inverse direction of reference was not introduced.
Hence, a.service is started earlier than b.service, the namespace will
not shared with b.service.
Also, even if a.service had the reference to b.service, b.service did not.
If b.service is freed earlier, then unit_clear_dependencies() does not clear
the reference from a to b, and will cause use-after-free on unit_free() for
a.service.

Let's make JoinsNamespaceOf=b.service in a.service implies the inverse
dependency, i.e. JoinsNamespaceOf=a.service for b.service. Then, we can safely
free b.service.

16 months agocore/unit: drop doubled empty line
Yu Watanabe [Mon, 22 May 2023 21:03:52 +0000 (06:03 +0900)] 
core/unit: drop doubled empty line

16 months agotest: add tests for JoinsNamespaceOf=
Yu Watanabe [Wed, 24 May 2023 21:48:16 +0000 (06:48 +0900)] 
test: add tests for JoinsNamespaceOf=

To illustrate the current behavior of the dependency.

16 months agounits: Shut down networkd and resolved on switch-root
Daan De Meyer [Thu, 25 May 2023 16:13:02 +0000 (18:13 +0200)] 
units: Shut down networkd and resolved on switch-root

Let's explicitly order these against initrd-switch-root.target, so
that they are properly shut down before we switch root. Otherwise,
there's a race condition where networkd might only shut down after
switching root and after we've already we've loaded the unit graph,
meaning it won't be restarted in the rootfs.

Fixes #27718

16 months agorules: add rule for accel devices
Stanislaw Gruszka [Thu, 25 May 2023 09:44:00 +0000 (11:44 +0200)] 
rules: add rule for accel devices

Accel (Compute Acceleration) are new devices for AI/ML computation:
https://docs.kernel.org/accel/introduction.html

They are part of DRM subsystem. Add them to 'render' group since
no other appropriate group in standard linux systems exist. This
can be changed when proper common user-space components will emerge,
and new group for acceleration devices access will be established.

Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
16 months agogpt-auto-generator: also honor systemd.swap=no
David Tardon [Thu, 25 May 2023 07:03:10 +0000 (09:03 +0200)] 
gpt-auto-generator: also honor systemd.swap=no

16 months agoman: add trailing =
David Tardon [Thu, 25 May 2023 06:44:21 +0000 (08:44 +0200)] 
man: add trailing =

16 months agomeson: Create credstore directories
Daan De Meyer [Wed, 24 May 2023 13:32:17 +0000 (15:32 +0200)] 
meson: Create credstore directories

Let's make the creds directories a bit more discoverable and make it
easier for users to use them. This also allows us to fix the
mode to 0700 for /etc instead of the usual 0755 which is what probably
would happen if users had to create this directory themselves.

16 months agoresolved-dns-rr: use automatic cleanup
David Tardon [Thu, 25 May 2023 08:30:06 +0000 (10:30 +0200)] 
resolved-dns-rr: use automatic cleanup

Follow-up for #27770.

16 months agoupdate TODO
Lennart Poettering [Thu, 25 May 2023 12:33:45 +0000 (14:33 +0200)] 
update TODO

16 months agoMerge pull request #27358 from bluca/pe_mule
Lennart Poettering [Thu, 25 May 2023 10:56:06 +0000 (03:56 -0700)] 
Merge pull request #27358 from bluca/pe_mule

stub: allow loading and verifying kernel command line addons

16 months agomount-util: Downgrade log message to trace
Daan De Meyer [Thu, 25 May 2023 07:48:24 +0000 (09:48 +0200)] 
mount-util: Downgrade log message to trace

This debug log message is extremely noisy so let's downgrade it to
trace.

16 months agomkosi: Bump default timeout to 180s
Daan De Meyer [Thu, 25 May 2023 08:00:59 +0000 (10:00 +0200)] 
mkosi: Bump default timeout to 180s

Hopefully fixes #27778 where waiting for the root device to appear
times out before systemd-repart has a chance to run and create it.

16 months agoMerge pull request #26959 from poettering/creds-mount-dep-fix
Lennart Poettering [Thu, 25 May 2023 09:06:47 +0000 (02:06 -0700)] 
Merge pull request #26959 from poettering/creds-mount-dep-fix

credential ramfs mount order fixes

16 months agoMerge pull request #27483 from yuwata/udev-id-path-usb-revision
Zbigniew Jędrzejewski-Szmek [Thu, 25 May 2023 08:24:45 +0000 (10:24 +0200)] 
Merge pull request #27483 from yuwata/udev-id-path-usb-revision

udev: include USB revision in ID_PATH

16 months agoMerge pull request #27770 from mrc0mmand/more-nallocfuzz-shenanigans
Yu Watanabe [Thu, 25 May 2023 08:15:37 +0000 (17:15 +0900)] 
Merge pull request #27770 from mrc0mmand/more-nallocfuzz-shenanigans

A couple of fixes for potential issues during OOM situations

16 months agoMerge pull request #27769 from YHNdnzj/loginctl-followup
Yu Watanabe [Wed, 24 May 2023 20:52:06 +0000 (05:52 +0900)] 
Merge pull request #27769 from YHNdnzj/loginctl-followup

loginctl: some follow-ups

16 months agoMerge pull request #27723 from YHNdnzj/service-restart-cleanup
Yu Watanabe [Wed, 24 May 2023 20:14:52 +0000 (05:14 +0900)] 
Merge pull request #27723 from YHNdnzj/service-restart-cleanup

core: get rid of unused Service.will_auto_restart logic

16 months agotree-wide: check memstream buffer after closing the handle 27770/head
Frantisek Sumsal [Wed, 24 May 2023 11:29:52 +0000 (13:29 +0200)] 
tree-wide: check memstream buffer after closing the handle

When closing the FILE handle attached to a memstream, it may attempt to
do a realloc() that may fail during OOM situations, in which case we are
left with the buffer pointer pointing to NULL and buffer size > 0. For
example:

```
    #include <errno.h>
    #include <stdio.h>
    #include <stdlib.h>

    void *realloc(void *ptr, size_t size) {
        return NULL;
    }

    int main(int argc, char *argv[])
    {
        FILE *f;
        char *buf;
        size_t sz = 0;

        f = open_memstream(&buf, &sz);
        if (!f)
            return -ENOMEM;

        fputs("Hello", f);

        fflush(f);
        printf("buf: 0x%lx, sz: %lu, errno: %d\n",
                    (unsigned long) buf, sz, errno);
        fclose(f);
        printf("buf: 0x%lx, sz: %lu, errno: %d\n",
                    (unsigned long) buf, sz, errno);

        return 0;
    }
```

```
$ gcc -o main main.c
$ ./main
buf: 0x74d4a0, sz: 5, errno: 0
buf: 0x0, sz: 5, errno: 0
```

This might do unexpected things if the underlying code expects a valid
pointer to the memstream buffer after closing the handle.

Found by Nallocfuzz.

16 months agosystem-update-generator: drop pointless goto
David Tardon [Tue, 16 May 2023 05:39:32 +0000 (07:39 +0200)] 
system-update-generator: drop pointless goto

16 months agoMerge pull request #27173 from yuwata/update-utmp
Yu Watanabe [Wed, 24 May 2023 19:00:58 +0000 (04:00 +0900)] 
Merge pull request #27173 from yuwata/update-utmp

update-utmp: do not fail when PID1 is reexecuting

16 months agoMerge pull request #27773 from dtardon/timestamp-cleanup
Yu Watanabe [Wed, 24 May 2023 18:27:15 +0000 (03:27 +0900)] 
Merge pull request #27773 from dtardon/timestamp-cleanup

Use *timestamp_is_set() at more places

16 months agoMerge pull request #27774 from dtardon/free-cleanup
Yu Watanabe [Wed, 24 May 2023 18:06:51 +0000 (03:06 +0900)] 
Merge pull request #27774 from dtardon/free-cleanup

Use free_and_*() more

16 months agologinctl: also show idle hint in session-status 27769/head
Mike Yuan [Tue, 23 May 2023 10:54:30 +0000 (18:54 +0800)] 
loginctl: also show idle hint in session-status

16 months agologinctl: list-users: use bus_map_all_properties
Mike Yuan [Tue, 23 May 2023 10:27:05 +0000 (18:27 +0800)] 
loginctl: list-users: use bus_map_all_properties

16 months agologinctl: list-sessions: fix timestamp for idle hint
Mike Yuan [Wed, 24 May 2023 17:20:45 +0000 (01:20 +0800)] 
loginctl: list-sessions: fix timestamp for idle hint

Follow-up for 556723e738b96a5c2b2d45a96b87b7b80e0c5664

TABLE_TIMESTAMP_RELATIVE takes a realtime timestamp.

16 months agologinctl: some modernizations
Mike Yuan [Wed, 24 May 2023 11:42:03 +0000 (19:42 +0800)] 
loginctl: some modernizations

16 months agoukify: fix handling signed kernel as file
Malte Poll [Wed, 24 May 2023 09:01:25 +0000 (11:01 +0200)] 
ukify: fix handling signed kernel as file

The .linux section would contain the path to the signed kernel (instead of the signed kernel itself), since the python type of the variable is used to determine how it is handled when adding the pe sections.

Co-authored-by: Otto Bittner <cobittner@posteo.net>
16 months agosd-journal: propagate errors from ordered_hashmap_*()
Frantisek Sumsal [Wed, 24 May 2023 12:17:25 +0000 (14:17 +0200)] 
sd-journal: propagate errors from ordered_hashmap_*()

Instead of masking them with -ENOMEM.

16 months agotimer: use dual_timestamp_is_set() at one more place 27773/head
David Tardon [Wed, 24 May 2023 13:29:30 +0000 (15:29 +0200)] 
timer: use dual_timestamp_is_set() at one more place

16 months agotree-wide: use timestamp_is_set() at more places
David Tardon [Wed, 24 May 2023 13:26:32 +0000 (15:26 +0200)] 
tree-wide: use timestamp_is_set() at more places

16 months agoTODO: remove fixed item 27358/head
Luca Boccassi [Wed, 24 May 2023 10:18:18 +0000 (11:18 +0100)] 
TODO: remove fixed item

16 months agostub: allow loading and verifying cmdline addons
Luca Boccassi [Thu, 11 May 2023 23:55:58 +0000 (00:55 +0100)] 
stub: allow loading and verifying cmdline addons

Files placed in /EFI/Linux/UKI.efi.extra.d/ and /loader/addons/ are
opened and verified using the LoadImage protocol, and will thus get
verified via shim/firmware.
If they are valid signed PE files, the .cmdline section will be
extracted and appended. If there are multiple addons in each directory,
they will be parsed in alphanumerical order.

Optionally the .uname sections are also matched if present, so
that they can be used to filter out addons as well if needed, and only
addons that correspond exactly to the UKI being loaded are used.
It is recommended to also always add a .sbat section to addons, so
that they can be mass-revoked with just a policy update.

The files must have a .addon.efi suffix.

Files in the per-UKI directory are parsed, sorted, measured and
appended first. Then, files in the generic directory are processed.

16 months agocore: drop UnitNotifyFlags 27723/head
Mike Yuan [Mon, 22 May 2023 00:35:53 +0000 (08:35 +0800)] 
core: drop UnitNotifyFlags

This essentially reverts 2ad2e41a72ec19159c0746a78e15ff880fe32a63.

No longer needed after dropping UNIT_NOTIFY_WILL_AUTO_RESTART.

16 months agocore: get rid of unused Service.will_auto_restart logic
Mike Yuan [Mon, 22 May 2023 00:30:30 +0000 (08:30 +0800)] 
core: get rid of unused Service.will_auto_restart logic

The announced new behavior for OnFailure= never worked properly,
and we've fixed the document instead in #27675.
Therefore, let's get rid of the unused logic completely. More at #27594.

The to-be-added RestartMode= option should cover the use case hopefully.

Closes #27594

16 months agojournal-upload: use mfree() 27774/head
David Tardon [Wed, 24 May 2023 12:27:27 +0000 (14:27 +0200)] 
journal-upload: use mfree()

16 months agotree-wide: use free_and_str*dup() more
David Tardon [Wed, 24 May 2023 12:47:36 +0000 (14:47 +0200)] 
tree-wide: use free_and_str*dup() more

16 months agotree-wide: use free_and_replace() more
David Tardon [Wed, 24 May 2023 12:21:04 +0000 (14:21 +0200)] 
tree-wide: use free_and_replace() more

16 months agoMerge pull request #27752 from DaanDeMeyer/timer-oncalendar-fix
Daan De Meyer [Wed, 24 May 2023 12:39:32 +0000 (14:39 +0200)] 
Merge pull request #27752 from DaanDeMeyer/timer-oncalendar-fix

core/timer: Always use inactive_exit_timestamp if it is set

16 months agoenv-file: use free_and_replace()
Frantisek Sumsal [Wed, 24 May 2023 09:41:30 +0000 (11:41 +0200)] 
env-file: use free_and_replace()

16 months agospecifier: avoid leaking memory on allocation error
Frantisek Sumsal [Wed, 24 May 2023 09:39:24 +0000 (11:39 +0200)] 
specifier: avoid leaking memory on allocation error

==8036==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x4a10bc in __interceptor_realloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:85:3
    #1 0x4deef1 in realloc (/build/fuzz-unit-file+0x4deef1)
    #2 0x7ffa35abfe23 in greedy_realloc /work/build/../../src/systemd/src/basic/alloc-util.c:70:13
    #3 0x7ffa35aefad2 in parse_env_file_internal /work/build/../../src/systemd/src/basic/env-file.c:127:38
    #4 0x7ffa35af08a6 in parse_env_file_fdv /work/build/../../src/systemd/src/basic/env-file.c:374:13
    #5 0x7ffa35b6391e in parse_extension_release_atv /work/build/../../src/systemd/src/basic/os-util.c:323:16
    #6 0x7ffa35b63c8a in parse_extension_release_sentinel /work/build/../../src/systemd/src/basic/os-util.c:360:13
    #7 0x7ffa35a5e3f5 in parse_os_release_specifier /work/build/../../src/systemd/src/shared/specifier.c:292:13
    #8 0x7ffa35a5e3f5 in specifier_os_id /work/build/../../src/systemd/src/shared/specifier.c:303:16
    #9 0x7ffa35a5c7f5 in specifier_printf /work/build/../../src/systemd/src/shared/specifier.c:70:45
    #10 0x7ffa3690b279 in unit_full_printf_full /work/build/../../src/systemd/src/core/unit-printf.c:264:16
    #11 0x7ffa367de795 in config_parse_bus_name /work/build/../../src/systemd/src/core/load-fragment.c:2401:13
    #12 0x7ffa358fe5ec in next_assignment /work/build/../../src/systemd/src/shared/conf-parser.c:151:24
    #13 0x7ffa358fe5ec in parse_line /work/build/../../src/systemd/src/shared/conf-parser.c:257:16
    #14 0x7ffa358fd653 in config_parse /work/build/../../src/systemd/src/shared/conf-parser.c:400:21
    #15 0x4de828 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:72:16
    #16 0x4df208 in NaloFuzzerTestOneInput (/build/fuzz-unit-file+0x4df208)
    #17 0x4fe213 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #18 0x4fd9fa in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
    #19 0x4ff0c9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
    #20 0x4ffd95 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
    #21 0x4ef0ff in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
    #22 0x4ef9c8 in LLVMFuzzerRunDriver /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:925:10
    #23 0x4df485 in main (/build/fuzz-unit-file+0x4df485)
    #24 0x7ffa35232082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)

DEDUP_TOKEN: __interceptor_realloc--realloc--greedy_realloc
SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).

Found by Nallocfuzz.

16 months agoresolve: avoid memory leak from a partially processed RR
Frantisek Sumsal [Tue, 23 May 2023 19:34:48 +0000 (21:34 +0200)] 
resolve: avoid memory leak from a partially processed RR

==5==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4096 byte(s) in 1 object(s) allocated from:
    #0 0x4a2056 in __interceptor_malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x5180a9 in malloc (/build/fuzz-resource-record+0x5180a9)
    #2 0x4f7182 in dns_packet_extend /work/build/../../src/systemd/src/resolve/resolved-dns-packet.c:371:36
    #3 0x4f8b8b in dns_packet_append_uint8 /work/build/../../src/systemd/src/resolve/resolved-dns-packet.c:433:13
    #4 0x4f8b8b in dns_packet_append_name /work/build/../../src/systemd/src/resolve/resolved-dns-packet.c:597:13
    #5 0x4f8f16 in dns_packet_append_key /work/build/../../src/systemd/src/resolve/resolved-dns-packet.c:622:13
    #6 0x4fa9a0 in dns_packet_append_rr /work/build/../../src/systemd/src/resolve/resolved-dns-packet.c:883:13
    #7 0x4eb00c in dns_resource_record_to_wire_format /work/build/../../src/systemd/src/resolve/resolved-dns-rr.c:1224:13
    #8 0x4df7be in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/resolve/fuzz-resource-record.c:32:16
    #9 0x518428 in NaloFuzzerTestOneInput (/build/fuzz-resource-record+0x518428)
    #10 0x537433 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #11 0x536c1a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
    #12 0x5382e9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
    #13 0x538fb5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
    #14 0x52831f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
    #15 0x528be8 in LLVMFuzzerRunDriver /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:925:10
    #16 0x5186a5 in main (/build/fuzz-resource-record+0x5186a5)
    #17 0x7f991fab8082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)

DEDUP_TOKEN: __interceptor_malloc--malloc--dns_packet_extend
SUMMARY: AddressSanitizer: 4096 byte(s) leaked in 1 allocation(s).

Found by Nallocfuzz.

16 months agosd-journal: use TAKE_PTR() a bit more
Frantisek Sumsal [Tue, 23 May 2023 17:21:20 +0000 (19:21 +0200)] 
sd-journal: use TAKE_PTR() a bit more