1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-21 18:03:41 +03:00

58481 Commits

Author SHA1 Message Date
Yu Watanabe
05a6a67e55 dissect-image: log expected UUID for /var
Closes #25443.

(cherry picked from commit a52efa813df9614b98069976b73fe63a68983ee7)
(cherry picked from commit d0b80bf81eebf76516b4d6cf2e016779bbd29615)
2022-12-14 17:53:17 +01:00
Yu Watanabe
3303be63f4 bootspec: fix null-dereference-read
Fixes [oss-fuzz#53578](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53578).
Fixes #25450.

(cherry picked from commit 46dc071985ff487f5ccf20808531168a6add73d3)
(cherry picked from commit b0b97848e8acfa7bba19b8a70c3aa7ff02f4c322)
2022-12-14 17:52:42 +01:00
Neil Moore
df977d44e3 virt: Support detection of LMHS SRE guests
(cherry picked from commit d833ed781f61b820e7abb17caa85c3c37c7ea807)
(cherry picked from commit 0ba8e9ecff068bfdeba4f8aa8b0e030f577b0892)
2022-12-14 17:52:33 +01:00
Ray Strode
7160de171d terminal-util: Set OPOST when setting ONLCR
reset_terminal_fd sets certain minimum required terminal attributes
that systemd relies on.

One of those attributes is `ONLCR` which ensures that when a new line
is sent to the terminal, that the cursor not only moves to the next
line, but also moves to the very beginning of that line.

In order for `ONLCR` to work, the terminal needs to perform output
post-processing. That requires an additional attribute, `OPOST`,
which reset_terminal_fd currently fails to ensure is set.

In most cases `OPOST` (and `ONLCR` actually) are both set anyway, so
it's not an issue, but it could be a problem if, e.g., the terminal was
put in raw mode by a program and the program unexpectedly died before
restoring settings.

This commit ensures when `ONLCR` is set `OPOST` is set too, which is
the only thing that really makes sense to do.

(cherry picked from commit 9fe26523a189435d75b9d745188e09c17928d89e)
(cherry picked from commit 787b2c32f33225df7359bddf101b8aec4d7754fe)
2022-12-14 17:52:25 +01:00
Lennart Poettering
2378bbae57 units: change Requires=systemd-networkd.service → BindsTo= one more time
Follow-up for da15f8406e9aeb7908e1d92c02d2ff5147c7788a which did the
change for systemd-networkd-wait-online.service, let's also do this for
systemd-networkd-wait-online@.service

(cherry picked from commit 51f3dc2234082c1ca9bdda403e4f355cab6be03b)
(cherry picked from commit c7bf13b2d96d5e234d5e896a960661d7561cade6)
2022-12-14 17:52:19 +01:00
Yu Watanabe
814acf7a6f sd-netlink: fix segfault
(cherry picked from commit 766417bd763db913efdd9c48442b1094c23d7042)
(cherry picked from commit 25050101780f95c27ebf094fca23d665cff5fb8c)
2022-12-14 17:51:24 +01:00
Michal Koutný
d11c3a2a06 test: Add tests for systemd-cgtop args parsing
(cherry picked from commit d4e32838e875539ad6991b75b083c9563eddc3ed)
(cherry picked from commit 4b885f3591eecc2672b9504bd75a7473d94af9f6)
2022-12-14 17:51:24 +01:00
Michal Koutný
598260221c cgtop: Do not rewrite -P or -k options
--recursive=no will overwrite possible -P or -k option hence making the
recursive disabling impossible.

Check what counting types the system supports (encoded in the ordering
of our enum) of and pick whatever user requests but is also supported.

Fixes: #25248
(cherry picked from commit 48600b3524afe05d0faa8a5c88b5aaa53b801199)
(cherry picked from commit b97c1c427c2156495e141c736babbccabba7265d)
2022-12-14 17:51:24 +01:00
Michal Koutný
95b20a94fb logind: Properly unescape names of lingering users
Filenames to store user linger requests are created with C-escaping.
When we enumerate the files to acquire ligering users, we use the
filenames verbatim. In the case C-escaping is not an identity map (such
as "DOMAIN\User"), we won't be able to start user instances of
such mangled users.

Unescape filenames when we treat them as usernames again.

Fixes: #25448
(cherry picked from commit f38e89c23ce52efa27bb47f5c3dafecdb987492b)
(cherry picked from commit 6cbf72a8d9976ba182587cf62e2b7b8ae00ae2dd)
2022-12-14 17:51:24 +01:00
Daan De Meyer
0fbb019020 units: Use BindsTo=systemd-networkd in systemd-networkd-wait-online.service
We don't want systemd-networkd-wait-online to start if systemd-networkd
is skipped due to condition failures. This is only guaranteed by BindsTo=
and not Requires=, so let's use BindsTo=

(cherry picked from commit da15f8406e9aeb7908e1d92c02d2ff5147c7788a)
(cherry picked from commit 01a39e96b523c06d99499a28451b24f12f8ecd4b)
2022-12-14 17:51:24 +01:00
Christian Göttsche
aec3dc60e4 core: update audit messages
Pass getuid() instead of literal `0` as auid, since user session
managers also issue audit messages on SELinux denials.

(cherry picked from commit c826b7ef3272157167a5c9d493e9672f00d84b98)
(cherry picked from commit 475c130003e999958420fc8e0e2e55adb690bfc3)
2022-12-14 17:51:24 +01:00
Daan De Meyer
85d37c860d sd-bus: Use goto finish instead of return in bus_add_match_full
Fixes #25340

(cherry picked from commit 0f3c342903d1a09577378912717539b530af1fcf)
(cherry picked from commit eea92b179d07ef46b2fdfe4e0a918278ac43a81c)
2022-12-14 17:34:48 +01:00
Daan De Meyer
8f13d34510 strv: Make sure strv_make_nulstr() always returns a valid nulstr
strv_make_nulstr() is documented to always return a valid nulstr,
but if the input is `NULL` we return a string terminated with only
a single NUL terminator, so let's fix that and always terminate the
resulting string with two NUL bytes.

(cherry picked from commit 5ea173a91b2093664a9ebb9add678edd6f5d1efd)
(cherry picked from commit 0916514b8c595e6133527a4386d9903f2c7559d7)
2022-12-14 17:34:41 +01:00
Luca Boccassi
fd5fe6d834 repart: respect --discard=no also for block devices
It's only used to avoid BLKDISCARD on individual partitions at the moment.
It can take a lot of time to run on very slow devices, so avoid it for
them too.

(cherry picked from commit 0dce448bbc97c861520c287b01d632b887442925)
(cherry picked from commit d5e3625a61db2abd96c400af52bda4f39e06f65d)
2022-12-14 17:32:50 +01:00
Luca Boccassi
e802dcf8bb portable: add a few more useful debug log messages
When attaching and /etc/systemd/system.attached can't be created or used
(eg: dead symlink) the logs are pretty much useless as even at debug
level there's no indication of what is going wrong.
Add some debug logs, and return a more specific error string over D-Bus.

(cherry picked from commit 80d95fcd6e1947a7887b96b22a32dbca115baac9)
(cherry picked from commit 79f161ac6523991f038dae8c7fc5298cad675a96)
2022-12-14 17:32:44 +01:00
Yu Watanabe
c68262375b network: wifi: try to reconfigure when connected
Sometimes, RTM_NEWLINK message with carrier is received earlier than
NL80211_CMD_CONNECT. To make SSID= or other WiFi related settings in
[Match] section work, let's try to reconfigure the interface.

Fixes a bug introduced by 96f5f9ef9a1ba5146d3357c1548fb675d3bd5b68.

Fixes #25384.

(cherry picked from commit 8a4ad01a72481a6a7c0309064dd2dbd814818c94)
(cherry picked from commit da01d83ab40ddc7dc88aaf066b6d2b65cec6e02b)
2022-12-14 17:31:49 +01:00
Benjamin Fogle
6080d56403 resolved: Fix OpenSSL error messages
(cherry picked from commit f4a49d1c58578cb8d759dc6266a23d1acabdc38f)
(cherry picked from commit 595dd9b2b9111f927723881265ba15e4df4cfa54)
2022-12-14 17:30:07 +01:00
Lennart Poettering
147117adec resolved: when configuring 127.0.0.1 as per-interface DNS server, contact it via "lo" always
ussually if you specify a DNS server on some interface then we'll use
that interface to talk to it. Let's override this for localhost
addresses, as they only really make sense on "lo".

Fixes: #25397
(cherry picked from commit 6e32414a66ff8dbcef233981a7066684d903ee9f)
(cherry picked from commit d337ac02d60c4f233c509a683c0d04692996ba63)
2022-12-14 17:29:41 +01:00
Lennart Poettering
57116b5ed0 resolved: use right conditionalization when setting unicast ifindex on UDP sockets
(cherry picked from commit 5faaed5b62d5ed88d8df2802c5ab4d3ab2eb755a)
(cherry picked from commit 813d52dbf818edc09cbf4bcc2358fd0638c4c29c)
2022-12-14 17:29:36 +01:00
Sam James
de80b160ed nspawn: allow sched_rr_get_interval_time64 through seccomp filter
We only allow a selected subset of syscalls from nspawn containers
and don't list any time64 variants (needed for 32-bit arches when
built using TIME_BITS=64, which is relatively new).

We allow sched_rr_get_interval which cpython's test suite makes
use of, but we don't allow sched_rr_get_interval_time64.

The test failures when run in an arm32 nspawn container on an arm64 host
were as follows:
```
======================================================================
ERROR: test_sched_rr_get_interval (test.test_posix.PosixTester.test_sched_rr_get_interval)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-lang/python-3.11.0_p1/work/Python-3.11.0/Lib/test/test_posix.py", line 1180, in test_sched_rr_get_interval
    interval = posix.sched_rr_get_interval(0)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 1] Operation not permitted
```

Then strace showed:
```
sched_rr_get_interval_time64(0, 0xffbbd4a0) = -1 EPERM (Operation not permitted)
```

This appears to be the only time64 syscall that isn't already included one of
the sets listed in nspawn-seccomp.c that has a non-time64 variant. Checked
over each of the time64 syscalls known to systemd and verified that none
of the others had a non-time64-variant whitelisted in nspawn other than
sched_rr_get_interval.

Bug: https://bugs.gentoo.org/880131
(cherry picked from commit b9e7f22c2d80930cad36ae53e66e42a2996dca4a)
(cherry picked from commit 2b52748d45dd9d30e3ffb61a9f724e3b701975e4)
2022-12-14 17:29:29 +01:00
Li kunyu
5e5cbc3daa fuzz: fuzz-compress: fix copy-and-paste error: buf -> buf2 (#25431)
(cherry picked from commit f54f6d88b1235487eb7f0c634c488edc7813579a)
(cherry picked from commit f68be4fd79b63b8629b9fadb2894508f704f2bd0)
2022-12-14 17:28:38 +01:00
Jan Janssen
04d74c5090 boot: Correctly handle @saved default patterns
(cherry picked from commit 7941f11acb67c4f8ec857a791a51f3148af67b32)
(cherry picked from commit 6189505d7936bc495801f2322321844fdea619c1)
2022-12-14 17:28:01 +01:00
Yu Watanabe
59cff705e7 ac-power: check battery existence and status
If a battery is not present or its status is not discharging, then
the battery should not be used as a power source.
Let's count batteries currently discharging.

Fixes #25316.

(cherry picked from commit 1c03f7f4ba419aa65997e90accc0d935ae1cfbc5)
(cherry picked from commit f791ecd0c58f572580f1990dac8b0f136d352b8d)
2022-12-14 17:27:14 +01:00
Zbigniew Jędrzejewski-Szmek
fdb251e0dd pid1: skip cleanup if root is not tmpfs/ramfs
in_initrd() was really doing two things: checking if we're in the initrd, and
also verifying that the initrd is set up correctly. But this second check is
complicated, in particular it would return false for overlayfs, even with an
upper tmpfs layer. It also doesn't support the use case of having an initial
initrd with tmpfs, and then transitioning into an intermediate initrd that is
e.g. a DDI, i.e. a filesystem possibly with verity arranged as a disk image.

We don't need to check if we're in initrd in every program. Instead, concerns
are separated:
- in_initrd() just does a simple check for /etc/initrd-release.
- When doing cleanup, pid1 checks if it's on a tmpfs before starting to wipe
  the old root. The only case where we want to remove the old root is when
  we're on a plain tempory filesystem. With an overlay, we'd be creating
  whiteout files, which is not very useful. (*)

This should resolve https://bugzilla.redhat.com/show_bug.cgi?id=2137631
which is caused by systemd refusing to treat the system as an initrd because
overlayfs is used.

(*) I think the idea of keeping the initrd fs around for shutdown is outdated.
We should just have a completely separate exitrd that is unpacked when we want
to shut down. This way, we don't waste memory at runtime, and we also don't
transition to a potentially older version of systemd. But we don't have support
for this yet.

This replaces 0fef5b0f0bd9ded1ae7bcb3e4e4b2893e36c51a6.

(cherry picked from commit a940f507fbe1c81d6787dc0b7ce232c39818eec9)
(cherry picked from commit c2620a6bdba9bcc0abd404b92fde0d06a000438d)
2022-12-14 17:27:09 +01:00
Zbigniew Jędrzejewski-Szmek
0665d94c5e Revert "initrd: extend SYSTEMD_IN_INITRD to accept non-ramfs rootfs"
This reverts commit 1f22621ba33f8089d2ae5fbcaf8b3970dd68aaf0.

This is a replacement for b1fd5cd4eda02a323db93d7daa97f5138f89677d. See that
commit for details.

(cherry picked from commit 83a772aae2c6a0263832fc82e2132a1baee0834c)
2022-12-14 17:27:04 +01:00
Lennart Poettering
ca5b66b5a3 tpm2: add some extra validation of device string before using it
Let's add some extra validation before constructing and using the .so
name to load. This isn't really security sensitive, given that we
used secure_getenv() to get the device string (and it thus should have
been come from a trusted source) but let's better be safe than sorry.

(cherry picked from commit 50a085143fa8f5dd6b6b3cef8a6ea2ec7c53ed0d)
(cherry picked from commit 542dbc623e00d55224db30280d90f48d51cdf8f8)
2022-12-14 17:26:18 +01:00
Lennart Poettering
e1248c8474 tpm2-util: force default TCTI to be "device" with parameter "/dev/tpmrm0"
Apparently some distros default to tss-abmrd. Let's bypass that and
always go to the kernel resource manager.

abmrd cannot really work for us, since we want to access the TPM already
in earliest boot i.e. in environments the abmrd service is not available
in.

Fixes: #25352
(cherry picked from commit 34906680afe60d724ea435b79b9b830a4bf2e7e9)
(cherry picked from commit b3228085bae27adcf1f892f2857ad93f90d70e00)
2022-12-14 17:26:03 +01:00
Christian Göttsche
ae8b249af4 test: fstab-generator: adjust PATH for fsck
fsck(8) is located in /usr/sib/ on Debian sid:

    stdout:
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-01-dev-nfs.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-02-dhcp.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-03-dhcp6.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-04-nfs.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-05-nfs4.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-06-ipv4.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-07-ipv6.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-08-implicit-nfs.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-09-cifs.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-10-iscsi.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-11-live.input
    *** Running /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-12-dev-sdx.input
    --- /dev/fd/63  2022-11-04 15:39:13.131532174 +0100
    +++ /dev/fd/62  2022-11-04 15:39:13.131532174 +0100
    @@ -6,3 +6,4 @@
     initrd-usr-fs.target.requires
     initrd-usr-fs.target.requires/sysroot.mount
     sysroot.mount
    +systemd-fsck-root.service
    **** Unexpected output for /home/christian/Coding/workspaces/systemd/test/testdata/test-fstab-generator/test-12-dev-sdx.input
    stderr:
    Skipping root directory handling, as root on NFS was requested.
    Skipping root directory handling, as root on NFS was requested.
    Skipping root directory handling, as root on NFS was requested.
    Skipping root directory handling, as root on NFS was requested.
    Skipping root directory handling, as root on NFS was requested.
    Skipping root directory handling, as root on NFS was requested.
    Skipping root directory handling, as root on NFS was requested.
    Skipping root directory handling, as root on NFS was requested.
    Skipping root directory handling, as root on CIFS was requested.
    Skipping root directory handling, as root on iSCSI was requested.
    Skipping root directory handling, as root on live image was requested.
    Found entry what=/dev/sdx1 where=/sysroot type=n/a opts=ro
    Checking was requested for /dev/sdx1, but the fsck command does not exist.

(cherry picked from commit a45efc9e4b574a85176610496f2ac7ae769364bb)
(cherry picked from commit 2b2845ef6b89742c06fe4bc09228ed7eeade8f23)
v251.8
2022-11-08 14:00:17 +00:00
Zbigniew Jędrzejewski-Szmek
03514a9f64 man: add note that network-generator is not a generator
Also fix indentation.

(cherry picked from commit 2fa6574e835566c2aa5cbf4167ecee316f71bf98)
(cherry picked from commit dbed9051f701bfb1f0df1e19f01538348280d498)
2022-11-08 14:00:17 +00:00
Daan De Meyer
8c8a423821 condition: Check that subsystem is enabled in ConditionSecurity=tpm2
Instead of succeeding when either the firmware reports a TPM device
or we find a TPM device, let's check that the firmware reports a TPM
device and the TPM subsystem is enabled in the kernel.

To check whether the subsystem enabled, we check if the relevant
subdirectory in /sys exists at all.

(cherry picked from commit 300bba79c22e4be1effe2faad0e59ac725d396a1)
(cherry picked from commit 1757446e8bc4dc076badd5c1ad53a0021c42638c)
2022-11-08 11:21:08 +00:00
Yu Watanabe
9243b88b55 test: wait for loop device to be removed
Follow-up for bca762ce1abafd24016eba7310fdd38c758419f8.

Fixes #24450.

(cherry picked from commit 1a0e065e9f154f46fd68cd45f46310bc7df7a51c)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
f5c2be99bc test: wait for the lodev to get properly initialized
Otherwise we might start writing to one of its partition before the
respective node is created under /dev, resulting in... interesting
stuff.

Resolves: #24390
(cherry picked from commit bca762ce1abafd24016eba7310fdd38c758419f8)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
8cfe979030 test: disable LSan in the ASan env wrapper
This wrapper is used in situations where  we don't care about *San reports,
we just want to make things work. However, with enabled LSan we might
trigger some bogus reports we're definitely not interested in, causing
unexpected test fails.

Spotted on C8S in TEST-34-DYNAMICUSERMIGRATE:
```
[10654.804162] testsuite-34.sh[56]: + systemctl start testservice-34-check-writable.service
         Starting testservice-34-check-writable.service...
[10655.055969] bash[546]: + set -o pipefail
[10655.056127] bash[546]: + declare -a writable_dirs
[10655.056234] bash[546]: + readarray -t writable_dirs
[10655.060838] bash[548]: ++ find / '(' -path /var/tmp -o -path /tmp -o -path /proc -o -path /dev/mqueue -o -path /dev/shm -o -path /sys/fs/bpf -o -path /dev/.lxc -o -path /sys/devices/system/cpu ')' -prune -o -type d -writable -print
[10655.061534] bash[549]: ++ sort -u
[10655.688740] bash[547]: =================================================================
[10655.689075] bash[547]: ==547==ERROR: LeakSanitizer: detected memory leaks
[10655.689246] bash[547]: Direct leak of 112 byte(s) in 1 object(s) allocated from:
[10655.743851] bash[547]:     #0 0x7ffff752d364  (/usr/lib64/clang/14.0.0/lib/libclang_rt.asan-powerpc64le.so+0x13d364) (BuildId: 321f4ed1caea6a1a4c37f9272e07275cf16f034d)
[10655.744060] bash[547]:     #1 0x1000b5d20 in xmalloc (/usr/bin/bash+0xb5d20) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.744224] bash[547]:     #2 0x100083338  (/usr/bin/bash+0x83338) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.744393] bash[547]:     #3 0x10008847c  (/usr/bin/bash+0x8847c) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.744552] bash[547]:     #4 0x1000af6ec in redirection_expand (/usr/bin/bash+0xaf6ec) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.744728] bash[547]:     #5 0x1000b005c  (/usr/bin/bash+0xb005c) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.744886] bash[547]:     #6 0x1000b1388 in do_redirections (/usr/bin/bash+0xb1388) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.745051] bash[547]:     #7 0x100050484  (/usr/bin/bash+0x50484) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.745208] bash[547]:     #8 0x100052160 in execute_command_internal (/usr/bin/bash+0x52160) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.745376] bash[547]:     #9 0x100052a10 in execute_command_internal (/usr/bin/bash+0x52a10) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.745536] bash[547]:     #10 0x100053e38 in execute_command (/usr/bin/bash+0x53e38) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.745711] bash[547]:     #11 0x1000529d8 in execute_command_internal (/usr/bin/bash+0x529d8) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.745870] bash[547]:     #12 0x100053e38 in execute_command (/usr/bin/bash+0x53e38) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.746038] bash[547]:     #13 0x1000529d8 in execute_command_internal (/usr/bin/bash+0x529d8) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.746198] bash[547]:     #14 0x100053e38 in execute_command (/usr/bin/bash+0x53e38) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.746367] bash[547]:     #15 0x1000529d8 in execute_command_internal (/usr/bin/bash+0x529d8) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.746548] bash[547]:     #16 0x100053e38 in execute_command (/usr/bin/bash+0x53e38) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.746741] bash[547]:     #17 0x1000529d8 in execute_command_internal (/usr/bin/bash+0x529d8) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.746897] bash[547]:     #18 0x100053e38 in execute_command (/usr/bin/bash+0x53e38) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.747067] bash[547]:     #19 0x1000529d8 in execute_command_internal (/usr/bin/bash+0x529d8) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.747227] bash[547]:     #20 0x100053e38 in execute_command (/usr/bin/bash+0x53e38) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.747414] bash[547]:     #21 0x1000529d8 in execute_command_internal (/usr/bin/bash+0x529d8) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.747573] bash[547]:     #22 0x100053e38 in execute_command (/usr/bin/bash+0x53e38) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.747741] bash[547]:     #23 0x1000529d8 in execute_command_internal (/usr/bin/bash+0x529d8) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.747896] bash[547]:     #24 0x100053e38 in execute_command (/usr/bin/bash+0x53e38) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.748064] bash[547]:     #25 0x1000529d8 in execute_command_internal (/usr/bin/bash+0x529d8) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.748225] bash[547]:     #26 0x100053e38 in execute_command (/usr/bin/bash+0x53e38) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.748390] bash[547]:     #27 0x1000529d8 in execute_command_internal (/usr/bin/bash+0x529d8) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.748553] bash[547]:     #28 0x1000bf91c in parse_and_execute (/usr/bin/bash+0xbf91c) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.748717] bash[547]:     #29 0x1000311ec  (/usr/bin/bash+0x311ec) (BuildId: da38eb38f6870bdc2a6ef51c52aa6ce20921fe40)
[10655.748883] bash[547]: Direct leak of 17 byte(s) in 1 object(s) allocated from:
...
```

(cherry picked from commit b8dd27664c8668eb2249adc8385bdb38c118f258)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
db00a62be8 test: introduce a simple environment file for test service
(cherry picked from commit 25213e16f7bfb371e6a37b520bb256a3202953c2)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
fd082f335e test: lower the # of mpath devices to 16
to make the test suitable for slower machines.

(cherry picked from commit 1678bd2f81096b3b2b7c09f335e9c5cc8da96dca)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
d17a45340b test: make TEST-64 a bit more ASan friendly
Reduce the number of iterations in some of the test cases, since they
generate a huge amount of uevents and basically DoS udev (which can't
keep up while being slowed down by ASan). To avoid this, let's reduce
the number of iterations and bump the timeout when running under ASan,
since we're not interested in performance in such cases.

(cherry picked from commit 1e429729589e0e17158727694c8d1e9c3d42466b)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
a51cc9e578 test: don't wrap binaries built with ASan
since they should handle loading other instrumented libraries without
issues.

(cherry picked from commit b727d7e02d6c88476ae9e46211e1f9c24720d5c3)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
e176dca593 test: drop all LD_PRELOAD-related ASan workarounds
since they shouldn't be necessary anymore, as we tweak the "problematic"
binaries on per-binary basis.

(cherry picked from commit fa65ba6baac8c9241cf30802bb5fd3698d1f3189)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
9fba4cdf61 test: set $ASAN_RT_PATH along with $LD_PRELOAD to the ASan runtime DSO
Since we unset $LD_PRELOAD in the testsuite-* units (due to another
issue), let's store the path to the ASan DSO in another env variable, so
we can easily access it in the testsuite scripts when needed.

(cherry picked from commit 3ea18a2e36a5b8ac60c76e407f9dd38800455725)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
4fbf69fd1b semaphore: remove the Semaphore repositories recursively
The list of disabled repositories was recently converted from a single
file into a directory with separate repository files, so let's adjust
the setup script accordingly.

```
$ ls -lR /etc/apt/sources.list.d/
/etc/apt/sources.list.d/:
total 36
-rw-r--r-- 1 root root   76 Nov  3 10:28 azure-cli.list
-rw-r--r-- 1 root root   72 Nov  3 10:22 bazel.list
drwxr-xr-x 2 root root 4096 Nov  3 10:31 disabled
-rw-r--r-- 1 root root  113 Nov  3 10:13 docker-source.list
-rw-r--r-- 1 root root  367 Nov  3 10:28 github_git-lfs.list
-rw-r--r-- 1 root root  111 Nov  3 10:25 google-chrome-source.list
-rw-r--r-- 1 root root   64 Nov  3 10:14 google-cloud-sdk.list
-rw-r--r-- 1 root root   54 Nov  3 10:23 helm-stable-debian.list
-rw-r--r-- 1 root root   89 Nov  3 10:29 yarn-source.list

/etc/apt/sources.list.d/disabled:
total 20
-rw-r--r-- 1 root root 100 Nov  3 10:23 devel_kubic_libcontainers_stable.list
-rw-r--r-- 1 root root 103 Nov  3 10:27 git.list
-rw-r--r-- 1 root root 105 Nov  3 10:22 gradle.list
-rw-r--r-- 1 root root 118 Nov  3 10:13 pypy.list
-rw-r--r-- 1 root root 104 Nov  3 10:13 python.list
```

(cherry picked from commit 610eb3f8260ecbb161db5186a5e27417f3110a68)
(cherry picked from commit 31cfa1cc96650eb4b4112e6e62e6990846bde810)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
6258394c1e test: wrap ls and stat to make it work w/ sanitizers in specific cases
When `/etc/nsswitch.conf` uses `systemd` together with `[SUCCESS=merge]`,
`ls -l` will pull in `libnss_systemd` causing `SIGABRT`, as `ls` is not
instrumented (by default):

```
-bash-5.1# strace -f -e %file ls -l /dev
execve("/usr/bin/ls", ["ls", "-l", "/dev"], 0x7ffc3bb211c8 /* 24 vars*/) = 0
...
openat(AT_FDCWD, "/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=1896, ...}, AT_EMPTY_PATH) = 0
newfstatat(AT_FDCWD, "/etc/nsswitch.conf", {st_mode=S_IFREG|0644, st_size=359, ...}, 0) = 0
openat(AT_FDCWD, "/etc/group", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=965, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=10779, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/usr/lib/libnss_systemd.so.2", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=16195176, ...}, AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/usr/lib/libasan.so.8", O_RDONLY|O_CLOEXEC) = 3
...
readlink("/proc/self/exe", "/usr/bin/ls", 4096) = 11
open("/proc/self/cmdline", O_RDONLY)    = 3
open("/proc/self/environ", O_RDONLY)    = 3
==620==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=620, si_uid=0} ---
+++ killed by SIGABRT (core dumped) +++
Aborted (core dumped)
```

This also happens with `stat`. Let's add both `ls` and `stat` to the "wrap list"
to work around this.

Spotted on Arch Linux.

(cherry picked from commit 5ad15138458b4f2957bd9d2bc2c8e3c9afe99337)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
db14b371df test: create an ASan wrapper for getent and su
since they "suffer" from the same issue as `login` and other binaries
that load PAM stuff

(cherry picked from commit fdb70dd9222219307ca53662e789fc9304ca3616)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
1027d3d633 test: always wrap useradd/userdel when running w/ ASan
since they dlopen() PAM modules, including systemd ones.

(cherry picked from commit 94850fb956458703e0c6e0bee7f482aa41a47e9e)
2022-11-08 00:09:18 +01:00
Evgeny Vereshchagin
65ab7b0950 Revert "Support -D_FORTIFY_SOURCE=3 by using __builtin_dynamic_object_size."
This reverts commit 0bd292567a543d124cd303f7dd61169a209cae64.

It isn't guaranteed anywhere that __builtin_dynamic_object_size can
always deduce the size of every object passed to it so systemd
can end up using either malloc_usable_size or
__builtin_dynamic_object_size when pointers are passed around,
which in turn can lead to actual segfaults like the one mentioned in
https://github.com/systemd/systemd/issues/23619.

Apparently __builtin_object_size can return different results for
pointers referring to the same memory as well but somehow it hasn't
caused any issues yet. Looks like this whole
malloc_usable_size/FORTIFY_SOURCE stuff should be revisited.

Closes https://github.com/systemd/systemd/issues/23619 and
https://github.com/systemd/systemd/issues/23150.

Reopens https://github.com/systemd/systemd/issues/22801

(cherry picked from commit 2cfb790391958ada34284290af1f9ab863a515c7)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
f994276068 test: make TEST-63 more reliable on slower machines
Otherwise we might never hit the trigger limit and wait indefinitely.

Found when trying to run the test on an EC2 xen machine without a nested
virt in CentOS CI (in preparations for some ... unforseseen consequences).

(cherry picked from commit 0f1f5629747011d0401730ce81c955ec1d430e3d)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
68b4f10f82 test: use PBKDF2 with capped iterations instead of Argon2
to reduce the amount of resources the test needs (similarly to TEST-24
where we do the same thing).

(cherry picked from commit 8fec14a7d397f52b93024bf3417de8f77b0d85e6)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
1f32ec761c hashmap: use assert_se() to make clang happy
Otherwise it complains about a set but unused variable:

```
../src/basic/hashmap.c:1070:48: error: variable 'n_rehashed' set but not used [-Werror,-Wunused-but-set-variable]
        unsigned old_n_buckets, new_n_buckets, n_rehashed, new_n_entries;
                                                       ^
                                                       1 error generated.
```

(cherry picked from commit 3b2b3d298541fbf20a05553cc3a1b1bf173ccf3f)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
94a25aa6d5 coredump: drop an unused variable
(cherry picked from commit 9abe4cfc39579037937c63602ce8fe4f51746d38)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
5f09fa4d5e network: drop an unused variable
(cherry picked from commit f8769631e13914b2fad45fe746df79c92e3a131a)
2022-11-08 00:09:18 +01:00
Frantisek Sumsal
a29ddb989b machine: drop an unused variable
(cherry picked from commit f7c1808e69771c3b9179573bfdddac5218fd6fee)
2022-11-08 00:09:18 +01:00