Evgeny Vereshchagin [Thu, 22 Nov 2018 23:27:19 +0000 (00:27 +0100)]
tests: add a fuzzer for server_process_native_file
(cherry picked from commit
a4aa59bae206eebb4703b291147144def5d4bb3e)
Resolves: #
1764560
Evgeny Vereshchagin [Tue, 20 Nov 2018 00:20:32 +0000 (01:20 +0100)]
tests: add a fuzzer for journald streams
(cherry picked from commit
9541f5ff5c637bb1b3e3c69706cb73e68ff06813)
Resolves: #
1764560
Evgeny Vereshchagin [Sat, 17 Nov 2018 12:01:09 +0000 (13:01 +0100)]
tests: introduce dummy_server_init and use it in all journald fuzzers
(cherry picked from commit
ed62712dc6fb236845c489a7f386c7aff0ec31d6)
Resolves: #
1764560
Evgeny Vereshchagin [Fri, 16 Nov 2018 22:32:31 +0000 (23:32 +0100)]
journald: check whether sscanf has changed the value corresponding to %n
It's possible for sscanf to receive strings containing all three fields
and not matching the template at the same time. When this happens the
value of k doesn't change, which basically means that process_audit_string
tries to access memory randomly. Sometimes it works and sometimes it doesn't :-)
See also https://bugzilla.redhat.com/show_bug.cgi?id=
1059314.
(cherry picked from commit
1dab14aba749b9c5ab8176c5730107b70834240b)
Resolves: #
1764560
Evgeny Vereshchagin [Fri, 16 Nov 2018 20:23:56 +0000 (21:23 +0100)]
tests: add a fuzzer for process_audit_string
(cherry picked from commit
090a20cfaf3d5439fa39c5d8df473b0cfef181dd)
Resolves: #
1764560
Evgeny Vereshchagin [Fri, 16 Nov 2018 08:23:53 +0000 (09:23 +0100)]
test: initialize syslog_fd in fuzz-journald-kmsg too
This is a follow-up to
8857fb9beb9dcb that prevents the fuzzer from crashing with
```
==220==ERROR: AddressSanitizer: ABRT on unknown address 0x0000000000dc (pc 0x7ff4953c8428 bp 0x7ffcf66ec290 sp 0x7ffcf66ec128 T0)
SCARINESS: 10 (signal)
#0 0x7ff4953c8427 in gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35427)
#1 0x7ff4953ca029 in abort (/lib/x86_64-linux-gnu/libc.so.6+0x37029)
#2 0x7ff49666503a in log_assert_failed_realm /work/build/../../src/systemd/src/basic/log.c:805:9
#3 0x7ff496614ecf in safe_close /work/build/../../src/systemd/src/basic/fd-util.c:66:17
#4 0x548806 in server_done /work/build/../../src/systemd/src/journal/journald-server.c:2064:9
#5 0x5349fa in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-journald-kmsg.c:26:9
#6 0x592755 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:571:15
#7 0x590627 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:480:3
#8 0x594432 in fuzzer::Fuzzer::MutateAndTestOne() /src/libfuzzer/FuzzerLoop.cpp:708:19
#9 0x5973c6 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:839:5
#10 0x574541 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:764:6
#11 0x5675fc in main /src/libfuzzer/FuzzerMain.cpp:20:10
#12 0x7ff4953b382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#13 0x420f58 in _start (/out/fuzz-journald-kmsg+0x420f58)
```
(cherry picked from commit
cc55ac0171a2493768c021faa356513642797e7f)
Resolves: #
1764560
Evgeny Vereshchagin [Fri, 16 Nov 2018 06:33:02 +0000 (07:33 +0100)]
tests: add a reproducer for a heap-buffer-overflow fixed in
937b1171378bc1000a
(cherry picked from commit
f7a6b40187a98751a9ab6867e8b52e4e6f1dad5c)
Resolves: #
1764560
Evgeny Vereshchagin [Fri, 16 Nov 2018 06:20:44 +0000 (07:20 +0100)]
tests: add a reproducer for a memory leak fixed in
30eddcd51b8a472e05d3b8d1 in August
(cherry picked from commit
1dd485b700fe9ad94d7a780f14fcf18a4738ace4)
Resolves: #
1764560
Evgeny Vereshchagin [Fri, 16 Nov 2018 06:11:06 +0000 (07:11 +0100)]
journal: fix an off-by-one error in dev_kmsg_record
(cherry picked from commit
080d112caa0dc948555a69a008c1caf4d5d41ed6)
Resolves: #
1764560
Evgeny Vereshchagin [Fri, 16 Nov 2018 06:05:29 +0000 (07:05 +0100)]
basic: remove an assertion from cunescape_one
The function takes a pointer to a random block of memory and
the length of that block. It shouldn't crash every time it sees
a zero byte at the beginning there.
This should help the dev-kmsg fuzzer to keep going.
(cherry picked from commit
8dc4de966ce6d32470aaff30ed054f6a2688d6d7)
Resolves: #
1764560
Evgeny Vereshchagin [Thu, 15 Nov 2018 16:52:57 +0000 (17:52 +0100)]
tests: add a fuzzer for dev_kmsg_record
(cherry picked from commit
8857fb9beb9dcb95a6ce1be14dc94c4dc4cd3ea3)
Resolves: #
1764560
Evgeny Vereshchagin [Fri, 7 Sep 2018 06:13:17 +0000 (06:13 +0000)]
tests: put fuzz_journald_processing_function in a .c file
(cherry picked from commit
231dca5579cfba6175d19eee5347d693893fb5aa)
Resolves: #
1764560
Jan Synacek [Fri, 8 Nov 2019 13:54:30 +0000 (14:54 +0100)]
sd-bus: bump message queue size again
Simliarly to issue #4068, the current limit turns out to be too small for a
big storage setup that uses many small disks. Let's bump it further.
(cherry picked from commit
83a32ea7b03d6707b8e5bb90a0b3a6eb868ef633)
Resolves: #
1770189
Jan Synacek [Wed, 2 Oct 2019 09:59:41 +0000 (11:59 +0200)]
basic/user-util: allow dots in user names
(based on commit
1a29610f5fa1bcb2eeb37d2c6b79d8d1a6dbb865)
Resolves: #
1717603
Evgeny Vereshchagin [Sun, 23 Dec 2018 23:29:56 +0000 (00:29 +0100)]
journal: rely on _cleanup_free_ to free a temporary string used in client_context_read_cgroup
Closes https://github.com/systemd/systemd/issues/11253.
(cherry picked from commit
ef30f7cac18a810814ada7e6a68a31d48cc9fccd)
Resolves: #
1764560
Zbigniew Jędrzejewski-Szmek [Tue, 27 Aug 2019 17:28:19 +0000 (19:28 +0200)]
resolved: query polkit only after parsing the data
That's what we do everywhere else because it leads to nicer user experience.
Related: #
1746857
Zbigniew Jędrzejewski-Szmek [Tue, 27 Aug 2019 17:25:05 +0000 (19:25 +0200)]
resolved: allow access to Set*Link and Revert methods through polkit
This matches what is done in networkd very closely. In fact even the
policy descriptions are all identical (with s/network/resolve), except
for the last one:
resolved has org.freedesktop.resolve1.revert while
networkd has org.freedesktop.network1.revert-ntp and
org.freedesktop.network1.revert-dns so the description is a bit different.
Conflicts:
src/resolve/resolved-bus.c
src/resolve/resolved-link-bus.c
Related: #
1746857
Zbigniew Jędrzejewski-Szmek [Tue, 27 Aug 2019 17:02:53 +0000 (19:02 +0200)]
resolved: do not run loop twice
This doesn't matter much, but let's just do the loop once and allocate
the populate the result set on the fly. If we find an error, it'll get
cleaned up automatically.
Related: #
1746857
Zbigniew Jędrzejewski-Szmek [Tue, 27 Aug 2019 17:00:50 +0000 (19:00 +0200)]
sd-bus: adjust indentation of comments
Related: #
1746857
Zbigniew Jędrzejewski-Szmek [Tue, 27 Aug 2019 17:00:34 +0000 (19:00 +0200)]
shared/but-util: drop trusted annotation from bus_open_system_watch_bind_with_description()
https://bugzilla.redhat.com/show_bug.cgi?id=
1746057
This only affects systemd-resolved. bus_open_system_watch_bind_with_description()
is also used in timesyncd, but it has no methods, only read-only properties, and
in networkd, but it annotates all methods with SD_BUS_VTABLE_UNPRIVILEGED and does
polkit checks.
Resolves: #
1746857
Fabian Henneke [Wed, 21 Aug 2019 09:17:59 +0000 (11:17 +0200)]
udev: Add id program and rule for FIDO security tokens
Add a fido_id program meant to be run for devices in the hidraw
subsystem via an IMPORT directive. The program parses the HID report
descriptor and assigns the ID_SECURITY_TOKEN environment variable if a
declared usage matches the FIDO_CTAPHID_USAGE declared in the FIDO CTAP
specification. This replaces the previous approach of whitelisting all
known security token models manually.
This commit is accompanied by a test suite and a fuzzer target for the
descriptor parsing routine.
Fixes: #11996.
(cherry picked from commit
d45ee2f31a8358db0accde2e7c81777cedadc3c2)
Resolves: #
1753369
Yu Watanabe [Mon, 22 Oct 2018 03:04:13 +0000 (12:04 +0900)]
sd-device: introduce log_device_*() macros
(cherry picked from commit
b0cba0ca526ed2d86e283a0fcfebdf0a4d4bea9b)
Related: #
1753369
Michal Sekletar [Tue, 26 Feb 2019 16:33:27 +0000 (17:33 +0100)]
selinux: don't log SELINUX_INFO and SELINUX_WARNING messages to audit
Previously we logged even info message from libselinux as USER_AVC's to
audit. For example, setting SELinux to permissive mode generated
following audit message,
time->Tue Feb 26 11:29:29 2019
type=USER_AVC msg=audit(
1551198569.423:334): pid=1 uid=0 auid=
4294967295 ses=
4294967295 subj=system_u:system_r:init_t:s0 msg='avc: received setenforce notice (enforcing=0) exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
This is unnecessary and wrong at the same time. First, kernel already
records audit event that SELinux was switched to permissive mode, also
the type of the message really shouldn't be USER_AVC.
Let's ignore SELINUX_WARNING and SELINUX_INFO and forward to audit only
USER_AVC's and errors as these two libselinux message types have clear
mapping to audit message types.
(cherry picked from commit
6227fc14c48c4c17daed4b91f61cdd4aa375790a)
Resolves: #
1763612
Andrew Jorgensen [Wed, 25 Jul 2018 15:06:57 +0000 (08:06 -0700)]
shared/sleep-config: exclude zram devices from hibernation candidates
On a host with sufficiently large zram but with no actual swap, logind will
respond to CanHibernate() with yes. With this patch, it will correctly respond
no, unless there are other swap devices to consider.
(cherry picked from commit
411ae92b407bd7b4549b205ad754bcd0e3dfd81f)
Resolves: #
1763617
Frantisek Sumsal [Mon, 21 Oct 2019 16:39:39 +0000 (18:39 +0200)]
test: bump the second partition's size to 50M
The former size (10M) caused systemd-journald to crash with SIGABRT when
used on a LUKS2 partition, as the LUKS2 metadata consume a significant
part of the 10M partition, thus leaving no space for the journal file
itself (relevant for TEST-02-CRYPTSETUP). This change has been present
in upstream for a while anyway.
Related: #
1761519
rhel-only
Yu Watanabe [Thu, 1 Nov 2018 08:26:36 +0000 (17:26 +0900)]
test: mask several unnecessary services
This may make CIs run faster.
(cherry picked from commit
056ae88152a722bdbea54ff33db815d585c8b9c6)
Related: #
1761519
Frantisek Sumsal [Fri, 15 Mar 2019 09:05:33 +0000 (10:05 +0100)]
test: use PBKDF2 instead of Argon2 in cryptsetup...
to reduce memory requirements for volume manipulation. Also,
to further improve the test performance, reduce number of PBKDF
iterations to 1000 (allowed minimum).
(cherry picked from commit
5b69d297c153478f6f5e74ba66e1f4e5b6422baf)
Related: #
1761519
Renaud Métrich [Mon, 3 Sep 2018 03:42:39 +0000 (05:42 +0200)]
journald: fixed assertion failure when system journal rotation fails (#9893)
(cherry picked from commit
fd790d6f09b10a87b007b71403cb018f18ff91c9)
Resolves: #
1763619
Michal Sekletar [Mon, 9 Sep 2019 12:38:35 +0000 (14:38 +0200)]
path: stop watching path specs once we triggered the target unit
We start watching them again once we get a notification that triggered
unit entered inactive or failed state.
Fixes: #10503
(cherry picked from commit
8fca6944c2ee20c63d62154c8badddc77170b176)
Resolves: #
1763161
Anita Zhang [Mon, 8 Oct 2018 03:28:36 +0000 (20:28 -0700)]
core: implement per unit journal rate limiting
Add LogRateLimitIntervalSec= and LogRateLimitBurst= options for
services. If provided, these values get passed to the journald
client context, and those values are used in the rate limiting
function in the journal over the the journald.conf values.
Part of #10230
(cherry picked from commit
90fc172e191f44979005a524521112f2bd1ff21b)
Resolves: #
1719577
Franck Bui [Tue, 19 Mar 2019 09:59:26 +0000 (10:59 +0100)]
core: only watch processes when it's really necessary
If we know that main pid is our child then it's unnecessary to watch all
other processes of a unit since in this case we will get SIGCHLD when the main
process will exit and will act upon accordingly.
So let's watch all processes only if the main process is not our child since in
this case we need to detect when the cgroup will become empty in order to
figure out when the service becomes dead. This is only needed by cgroupv1.
Thanks Renaud Métrich for backporting this to RHEL.
Resolves: #
1744972
Franck Bui [Mon, 18 Mar 2019 19:59:36 +0000 (20:59 +0100)]
core: reduce the number of stalled PIDs from the watched processes list when possible
Some PIDs can remain in the watched list even though their processes have
exited since a long time. It can easily happen if the main process of a forking
service manages to spawn a child before the control process exits for example.
However when a pid is about to be mapped to a unit by calling unit_watch_pid(),
the caller usually knows if the pid should belong to this unit exclusively: if
we just forked() off a child, then we can be sure that its PID is otherwise
unused. In this case we take this opportunity to remove any stalled PIDs from
the watched process list.
If we learnt about a PID in any other form (for example via PID file, via
searching, MAINPID= and so on), then we can't assume anything.
Thanks Renaud Métrich for backporting this to RHEL.
Resolves: #
1744972
Franck Bui [Mon, 18 Mar 2019 10:48:34 +0000 (11:48 +0100)]
process-util: introduce pid_is_my_child() helper
No functional changes.
Thanks Renaud Métrich for backporting this to RHEL.
Resolves: #
1744972
Jan Synacek [Tue, 1 Oct 2019 06:45:08 +0000 (08:45 +0200)]
Consider smb3 as remote filesystem
Currently systemd will treat smb3 as local filesystem and cause
can't boot failures. Add smb3 to the list of remote filesystems
to fix this issue.
Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
(cherry picked from commit
ff7d6a740b0c6fa3be63d3908a0858730a0837c5)
Resolves: #
1757257
Renaud Métrich [Fri, 13 Sep 2019 09:18:18 +0000 (11:18 +0200)]
Call getgroups() to know size of supplementary groups array to allocate
Resolves RHBZ #
1743230 - journalctl dumps core when stack limit is reduced to 256 KB
(cherry picked from commit
f5e0b942af1e86993c21f4e5c84342bb10403dac)
Resolves: #
1743235
Jan Synacek [Thu, 17 Oct 2019 07:37:35 +0000 (09:37 +0200)]
udev: introduce CONST key name
Currently, there is no way to match against system-wide constants, such
as architecture or virtualization type, without forking helper binaries.
That potentially results in a huge number of spawned processes which
output always the same answer.
This patch introduces a special CONST keyword which takes a hard-coded
string as its key and returns a value assigned to that key. Currently
implemented are CONST{arch} and CONST{virt}, which can be used to match
against the system's architecture and virtualization type.
(based on commit
4801d8afe2ff1c1c075c9f0bc5631612172e0bb7)
Resolves: #
1762679
Michal Sekletar [Tue, 3 Sep 2019 08:05:42 +0000 (10:05 +0200)]
buildsys: don't garbage collect sections while linking
gc-sections is actually very aggressive and garbage collects ELF
sections used by annobin gcc plugin and annocheck then reports gaps in
coverage. Let's drop that linker flag.
RHEL-only
Resolves: #
1748258
Lennart Poettering [Fri, 19 Jul 2019 16:29:11 +0000 (18:29 +0200)]
core: try to reopen /dev/kmsg again right after mounting /dev
I was debugging stuff during early boot, and was confused that I never
found the logs for it in kmsg. The reason for that was that /proc is
generally not mounted the first time we do log_open() and hence
log_set_target(LOG_TARGET_KMSG) we do when running as PID 1 had not
effect. A lot later during start-up we call log_open() again where this
is fixed (after the point where we close all remaining fds still open),
but in the meantime no logs every got written to kmsg. This patch fixes
that.
(cherry picked from commit
0a2eef1ee1fef74be9d12f7dc4d0006b645b579c)
Resolves: #
1749212
Thadeu Lima de Souza Cascardo [Mon, 13 May 2019 19:58:01 +0000 (16:58 -0300)]
ask-password: prevent buffer overrow when reading from keyring
When we read from keyring, a temporary buffer is allocated in order to
determine the size needed for the entire data. However, when zeroing that area,
we use the data size returned by the read instead of the lesser size allocate
for the buffer.
That will cause memory corruption that causes systemd-cryptsetup to crash
either when a single large password is used or when multiple passwords have
already been pushed to the keyring.
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
(cherry picked from commit
59c55e73eaee345e1ee67c23eace8895ed499693)
Resolves: #
1752050
Zbigniew Jędrzejewski-Szmek [Fri, 23 Aug 2019 09:34:45 +0000 (11:34 +0200)]
kernel-install: do not require non-empty kernel cmdline
When booting with Fedora-Server-dvd-x86_64-30-
20190411.n.0.iso,
/proc/cmdline is empty (libvirt, qemu host with bios, not sure if that
matters), after installation to disk, anaconda would "crash" in kernel-core
%posttrans, after calling kernel-install, because dracut would fail
with
> Could not determine the kernel command line parameters.
> Please specify the kernel command line in /etc/kernel/cmdline!
I guess it's legitimate, even if unusual, to have no cmdline parameters.
Two changes are done in this patch:
1. do not fail if the cmdline is empty.
2. if /usr/lib/kernel/cmdline or /etc/kernel/cmdline are present, but
empty, ignore /proc/cmdline. If there's explicit configuration to
have empty cmdline, don't ignore it.
The same change was done in dracut:
https://github.com/dracutdevs/dracut/pull/561.
(cherry picked from commit
88e1306af6380794842fb31108ba67895799fab4)
Resolves: #
1701454
Frantisek Sumsal [Mon, 14 Oct 2019 15:14:35 +0000 (17:14 +0200)]
travis: don't run slow tests under ASan/UBSan
Resolves: #
1761519
Lennart Poettering [Fri, 16 Nov 2018 12:00:40 +0000 (13:00 +0100)]
sd-bus: make strict asan shut up
asan doesn't like it if we use strndup() (i.e. a string function) on a
non-NULL terminated buffer (i.e. something that isn't really a string).
Let's hence use memdup_suffix0() instead of strndup(), which is more
appropriate for binary data that is to become a string.
Fixes: #10385
(cherry picked from commit
ac0a94f7438b49a0890d9806db1fa211a5bca10a)
Resolves: #
1761519
Yu Watanabe [Wed, 8 Aug 2018 09:27:15 +0000 (18:27 +0900)]
syslog: fix segfault in syslog_parse_priority()
(cherry picked from commit
a5ee33b951cfa22db53d0274c9c6c0d9d4dae39d)
Resolves: #
1761519
Frantisek Sumsal [Mon, 14 Oct 2019 14:22:51 +0000 (16:22 +0200)]
travis: drop SCL remains
The `bash -ic` wrapper existed solely to make SCL work as expected
Resolves: #
1761519
Frantisek Sumsal [Mon, 14 Oct 2019 13:26:48 +0000 (15:26 +0200)]
travis: move to CentOS 8 docker images
As the CentOS 8 Docker images is finally out, we can use it and drop the
plethora of workarounds we had to implement to compile RHEL8 systemd on
CentOS 7.
Resolves: #
1761519
Zbigniew Jędrzejewski-Szmek [Fri, 15 Mar 2019 09:13:55 +0000 (10:13 +0100)]
man: reorder and add examples to systemd-analyze(1)
The number of verbs supported by systemd-analyze has grown quite a bit, and the
man page has become an unreadable wall of text. Let's put each verb in a
separate subsection, grouping similar verbs together, and add a lot of examples
to guide the user.
(cherry picked from commit
d323a99001c1f7625e8ac902e18deb514a4ca18d)
Related: #
1750343
Jan Synacek [Fri, 13 Sep 2019 07:23:32 +0000 (09:23 +0200)]
man: document systemd-analyze security
(cherry-picked from commit
ee93c1e664a7bbc59f1578e285c871999507b14d)
Resolves: #
1750343
Lennart Poettering [Wed, 17 Jul 2019 17:16:33 +0000 (19:16 +0200)]
core: never propagate reload failure to service result
Fixes: #11238
(cherry picked from commit
d611cfa748aaf600832160132774074e808c82c7)
Resolves: #
1735787
Jan Synacek [Wed, 31 Jul 2019 07:13:41 +0000 (09:13 +0200)]
analyze-security: fix potential division by zero
Upstream PR: https://github.com/systemd/systemd/pull/13238
Resolves: #
1734400
Lennart Poettering [Wed, 17 Jul 2019 16:58:44 +0000 (18:58 +0200)]
swap: scan /proc/swaps before processing waitid() results
Similar to the previous commit, but for /proc/swaps, where the same
logic and rationale applies.
(cherry picked from commit
bcce581d65de68cca01c73e1c890e261e72d20af)
Related: #
1696178
Lennart Poettering [Wed, 17 Jul 2019 16:57:13 +0000 (18:57 +0200)]
mount: rescan /proc/self/mountinfo before processing waitid() results
(The interesting bits about the what and why are in a comment in the
patch, please have a look there instead of looking here in the commit
msg).
Fixes: #10872
(cherry picked from commit
350804867dbcc9b7ccabae1187d730d37e2d8a21)
Conflicts:
src/core/mount.c
Resolves: #
1696178
Lennart Poettering [Wed, 17 Jul 2019 12:53:07 +0000 (14:53 +0200)]
mount: simplify /proc/self/mountinfo handler
Our IO handler is only installed for one fd, hence there's no reason to
conditionalize on it again.
Also, split out the draining into a helper function of its own.
(cherry picked from commit
fcd8e119c28be19ffbc5227089cf4d3b8ba60238)
Conflicts:
src/core/mount.c
Related: #
1696178
Jan Synacek [Thu, 6 Jun 2019 07:35:27 +0000 (09:35 +0200)]
rules: skip memory hotplug on ppc64
Resolves (#
1713159)
Jan Synacek [Tue, 14 May 2019 08:45:08 +0000 (10:45 +0200)]
man: note that journal does not validate syslog fields
(cherry picked from commit
63ea8032f28052f7cda860e5324c0a83dee7ed23)
Resolves: #
1707175
Yu Watanabe [Thu, 6 Dec 2018 17:51:56 +0000 (18:51 +0100)]
bash-completion: analyze: support 'security'
(cherry picked from commit
83da42c3bf86e8787cfec2c7fb6ca379dfec3632)
Resolves: #
1733395
Jonathon Kowalski [Thu, 17 Jan 2019 17:08:00 +0000 (17:08 +0000)]
Change job mode of manager triggered restarts to JOB_REPLACE
Fixes: #11305
Fixes: #3260
Related: #11456
So, here's what happens in the described scenario in #11305. A unit goes
down, and that triggeres stop jobs for the other two units as they were
bound to it. Now, the timer for manager triggered restarts kicks in and
schedules a restart job with the JOB_FAIL job mode. This means there is
a stop job installed on those units, and now due to them being bound to
us they also get a restart job enqueued. This however is a conflicts, as
neither stop can merge into restart, nor restart into stop. However,
restart should be able to replace stop in any case. If the stop
procedure is ongoing, it can cancel the stop job, install itself, and
then after reaching dead finish and convert itself to a start job.
However, if we increase the timer, then it can always take those units
from inactive -> auto-restart.
We change the job mode to JOB_REPLACE so the restart job cancels the
stop job and installs itself.
Also, the original bug could be worked around by bumping RestartSec= to
avoid the conflicting.
This doesn't seem to be something that is going to break uses. That is
because for those who already had it working, there must have never been
conflicting jobs, as that would result in a desctructive transaction by
virtue of the job mode used.
After this change, the test case is able to work nicely without issues.
(cherry picked from commit
03ff2dc71ecb09272d728d458498b44f7f132f51)
Resolves: #
1712524
Zhang Xianwei [Mon, 13 May 2019 10:41:55 +0000 (18:41 +0800)]
udev/scsi_id: fix incorrect page length when get device identification VPD page
The length of device identification VPD page is filled with two bytes,
but scsi_id only gets the low byte. Fix it.
Signed-off-by: Zhang Xianwei <zhang.xianwei8@zte.com.cn>
(cherry picked from commit
1f7b6872dbe8ccae1f3bda9aa6aeb87c9b42e01e)
Resolves: #
1713227
Milan Broz [Mon, 27 May 2019 07:44:14 +0000 (09:44 +0200)]
cryptsetup: Add LUKS2 token support.
LUKS2 supports so-called tokens. The libcryptsetup internally
support keyring token (it tries to open device using specified
keyring entry).
Only if all token fails (or are not available), it uses a passphrase.
This patch aligns the functionality with the cryptsetup utility
(cryptsetup luksOpen tries tokens first) but does not replace
the systemd native ask-password function (can be used the same in
combination with this patch).
(cherry picked from commit
894bb3ca4c730cc9e9d46ef5004ba4ca5e201d8d)
Resolves: #
1719153
Milan Broz [Mon, 27 May 2019 07:43:03 +0000 (09:43 +0200)]
cryptsetup: call crypt_load() for LUKS only once
The crypt_load() for LUKS2 can read a quite big area of disk
(metadata area size is configurable and can increase up to megabytes).
This initialization is not needed to be repeated, just use the existing context.
(This patch is also required for the following change.)
(cherry picked from commit
ea9a9d49e4af31c49e5c216e7e5e2f533e727579)
Related: #
1719153
Milan Broz [Mon, 27 May 2019 07:27:54 +0000 (09:27 +0200)]
cryptsetup: Do not fallback to PLAIN mapping if LUKS data device set fails.
If crypt_load() for LUKS succeeds, we know that it is a LUKS device.
Failure of data device setting should fail in this case; remapping
as a PLAIN device late could mean data corruption.
(If a user wants to map PLAIN device over a device with LUKS header,
it should be said explicitly with "plain" argument type.)
Also, if there is no explicit PLAIN type requested and crypt device
is already initialized (crypt_data_type() is set), do not run
the initialization again.
(cherry picked from commit
2e4beb875bcb24e7d7d4339cc202b0b3f2953f71)
Related: #
1719153
Yu Watanabe [Fri, 10 Aug 2018 02:07:54 +0000 (11:07 +0900)]
journal: do not remove multiple spaces after identifier in syslog message
Single space is used as separator.
C.f. discussions in #156.
Fixes #9839 introduced by
a6aadf4ae0bae185dc4c414d492a4a781c80ffe5.
(cherry picked from commit
8595102d3ddde6d25c282f965573a6de34ab4421)
Resolves: #
1691817
Yu Watanabe [Mon, 11 Mar 2019 03:27:18 +0000 (12:27 +0900)]
journal-remote: do not request Content-Length if Transfer-Encoding is chunked
This fixes a bug introduced by
7fdb237f5473cb8fc2129e57e8a0039526dcb4fd.
Closes #11571.
(cherry picked from commit
a289dfd69b3ff4bccdde93e84b67c947bafa27e1)
Resolves: #
1708849
Lennart Poettering [Mon, 25 Feb 2019 10:02:46 +0000 (11:02 +0100)]
sd-bus: deal with cookie overruns
Apparently this happens IRL. Let's carefully deal with issues like this:
when we overrun, let's not go back to zero but instead leave the highest
cookie bit set. We use that as indication that we are in "overrun
territory", and then are particularly careful with checking cookies,
i.e. that they haven't been used for still outstanding replies yet. This
should retain the quick cookie generation behaviour we used to have, but
permits dealing with overruns.
Replaces: #11804
Fixes: #11809
(cherry picked from commit
1f82f5bb4237ed5f015daf93f818e9db95e764b8)
Resolves: #
1694999
Yu Watanabe [Wed, 27 Jun 2018 05:50:19 +0000 (14:50 +0900)]
journal-gateway: use localStorage["cursor"] only when it has valid value
Discovered by LGTM.
(cherry picked from commit
944072feddb73333023d0a98bf87fd2a17f894d3)
Resolves: #
1705971
Yu Watanabe [Sat, 8 Dec 2018 10:33:37 +0000 (19:33 +0900)]
tools: drop unused variable
(cherry picked from commit
2f6c9b6f3fb0128cee7f74985c143b4850feff6d)
Resolves: #
1705971
Yu Watanabe [Wed, 27 Jun 2018 05:22:24 +0000 (14:22 +0900)]
journal-gateway: explicitly declare local variables
Suggested by LGTM.
(cherry picked from commit
c497e449f41774a36e01ae2cc2abade6133dffe1)
Resolves: #
1705971
Lennart Poettering [Tue, 17 Jul 2018 10:35:12 +0000 (12:35 +0200)]
test: add test for Type=exec
(cherry picked from commit
0e1f17561f5f6061ec5503de044298372ed7ca37)
Resolves: #
1683334
Lennart Poettering [Tue, 17 Jul 2018 10:24:50 +0000 (12:24 +0200)]
sd-login: let's also make sd-login understand ".host"
if sd-bus and machined grok it, then sd-login should grok it too.
(cherry picked from commit
a8c9b7a0fc0aa02666042543ff9a652aae3c9499)
Resolves: #
1683334
Lennart Poettering [Tue, 17 Jul 2018 10:23:26 +0000 (12:23 +0200)]
sd-bus: allow connecting to the pseudo-container ".host"
machined exposes the pseudo-container ".host" as a reference to the host
system, and this means "machinectl login .host" and "machinectl shell
.host" get your a login/shell on the host. systemd-run currently doesn't
allow that. Let's fix that, and make sd-bus understand ".host" as an
alias for connecting to the host system.
(cherry picked from commit
1e5057b904473696ae0d591d7555233adcb51fa4)
Resolves: #
1683334
Lennart Poettering [Tue, 17 Jul 2018 10:01:26 +0000 (12:01 +0200)]
man: document the new Type=exec type
And while we are at it, let's rearrange and extend the Type=
documentation a bit. Let's make it an itemized list, and let's add a
paragraph explaining which type best to use.
(cherry picked from commit
79905a246d645d21633f09f564b3672d5085a85c)
Resolves: #
1683334
Lennart Poettering [Tue, 17 Jul 2018 09:47:14 +0000 (11:47 +0200)]
core: introduce new Type=exec service type
Users are often surprised that "systemd-run" command lines like
"systemd-run -p User=idontexist /bin/true" will return successfully,
even though the logs show that the process couldn't be invoked, as the
user "idontexist" doesn't exist. This is because Type=simple will only
wait until fork() succeeded before returning start-up success.
This patch adds a new service type Type=exec, which is very similar to
Type=simple, but waits until the child process completed the execve()
before returning success. It uses a pipe that has O_CLOEXEC set for this
logic, so that the kernel automatically sends POLLHUP on it when the
execve() succeeded but leaves the pipe open if not. This means PID 1
waits exactly until the execve() succeeded in the child, and not longer
and not shorter, which is the desired functionality.
Making use of this new functionality, the command line
"systemd-run -p User=idontexist -p Type=exec /bin/true" will now fail,
as expected.
(cherry picked from commit
5686391b006ee82d8a4559067ad9818e3e631247)
Resolves: #
1683334
Lennart Poettering [Thu, 5 Jul 2018 08:00:52 +0000 (10:00 +0200)]
execute: use our usual syntax for defining bit masks
(cherry picked from commit
ce0d60a7c4e07c5bdfed9f076bd48752287f0777)
Resolves: #
1683334
Lennart Poettering [Thu, 5 Jul 2018 07:56:54 +0000 (09:56 +0200)]
core: swap order of "n_storage_fds" and "n_socket_fds" parameters
When process fd lists to pass to activated programs we always place the
socket activation fds first, and the storage fds last. Irritatingly in
almost all calls the "n_storage_fds" parameter (i.e. the number of
storage fds to pass) came first so far, and the "n_socket_fds" parameter
second. Let's clean this up, and specify the number of fds in the order
the fds themselves are passed.
(Also, let's fix one more case where "unsigned" was used to size an
array, while we should use "size_t" instead.)
(cherry picked from commit
25b583d7ffd699384435eba8e49f6ce927a83af0)
Resolves: #
1683334
Filipe Brandenburger [Wed, 25 Jul 2018 01:46:01 +0000 (18:46 -0700)]
socket-util: Introduce send_one_fd_iov() and receive_one_fd_iov()
These take a struct iovec to send data together with the passed FD.
The receive function returns the FD through an output argument. In case data is
received, but no FD is passed, the receive function will set the output
argument to -1 explicitly.
Update code in dynamic-user to use the new helpers.
(cherry picked from commit
d34673ecb825aa9ecf6958b0caab792f5061c56a)
Resolves: #
1683319
Filipe Brandenburger [Wed, 25 Jul 2018 03:15:55 +0000 (20:15 -0700)]
test-socket-util: Add tests for receive_fd_iov() and friends.
Test it when sending an FD without any contents, or an FD and some contents,
or only contents and no FD (using a bare send().)
Also fix the previous test which forked but was missing an _exit() at the
end of the child execution code.
(cherry picked from commit
8a3386ab4fea9c4efa9c72e7c149cf510a46f03e)
Resolves: #
1683319
Frantisek Sumsal [Sat, 23 Feb 2019 21:28:05 +0000 (22:28 +0100)]
travis: switch from trusty to xenial
This should fix the timeout in test-event
Taken from:
b635e4ef6b2f35f07111bb66a68fe850a2ccab72
Resolves: #
1683319
Lennart Poettering [Sat, 8 Dec 2018 19:21:43 +0000 (20:21 +0100)]
mount-point: honour AT_SYMLINK_FOLLOW correctly
Fixes: #11092
(cherry picked from commit
be24321f3dae91a166166b239954032727439942)
Resolves: #
1683319
Lennart Poettering [Wed, 10 Oct 2018 09:12:54 +0000 (11:12 +0200)]
sd-bus: call cap_last_cap() only once in has_cap()
Also, use the same type everywhere for dealing with it.
(cherry picked from commit
92a40e20bf970c3ded8a50fbeeae882a7b970c9a)
Resolves: #
1683319
Lennart Poettering [Wed, 10 Oct 2018 09:12:22 +0000 (11:12 +0200)]
sd-bus: use size_t when dealing with memory offsets
(cherry picked from commit
3cae6c21e732fd46ff024d6625243d88ef6377ed)
Resolves: #
1683319
Lennart Poettering [Wed, 10 Oct 2018 09:07:54 +0000 (11:07 +0200)]
capability: introduce CAP_TO_MASK_CORRECTED() macro replacing CAP_TO_MASK()
linux/capability.h's CAP_TO_MASK potentially shifts a signed int "1"
(i.e. 32bit wide) left by 31 which means it becomes negative. That's
just weird, and ubsan complains about it. Let's introduce our own macro
CAP_TO_MASK_CORRECTED which doesn't fall into this trap, and make use of
it.
Fixes: #10347
(cherry picked from commit
5f00c5684f96c93a22840f7241ee444b9a632b1e)
Resolves: #
1683319
Evgeny Vereshchagin [Fri, 12 Oct 2018 12:17:04 +0000 (12:17 +0000)]
sd-journal: escape binary data in match_make_string()
Fixes: #10383
(cherry picked from commit
9e8b1ec08e8eb0b4611b7caf6adb8828feb32312)
Resolves: #
1683319
Zbigniew Jędrzejewski-Szmek [Tue, 21 Aug 2018 17:44:48 +0000 (19:44 +0200)]
test-socket-util: avoid "memleak" reported by valgrind
valgrind reports the allocation done in the short-lived child as a leak.
Let's restructure the code to avoid this.
(cherry picked from commit
181c4ba750770b54a54b5abbe8ae8ff4f6db59b5)
Resolves: #
1683319
Yu Watanabe [Wed, 8 Aug 2018 07:22:55 +0000 (16:22 +0900)]
util: introduce memcmp_safe()
(cherry picked from commit
f30faf854b9bf01da294547a1bc3660506d750db)
Resolves: #
1683319
Lennart Poettering [Wed, 10 Oct 2018 09:34:30 +0000 (11:34 +0200)]
tree-wide: various ubsan zero size memory fixes
Fixes: #10346
(cherry picked from commit
65f95765d05ddcd9e5849b68c379afa7e87d1248)
Resolves: #
1683319
Frantisek Sumsal [Fri, 9 Nov 2018 11:47:30 +0000 (12:47 +0100)]
tests: keep SYS_PTRACE when running under ASan
(cherry picked from commit
7a3025658836c536f81fdd742fa338545294f5bf)
Resolves: #
1683319
Frantisek Sumsal [Sat, 23 Feb 2019 16:10:55 +0000 (17:10 +0100)]
travis: enable ASan and UBSan on RHEL8
Resolves: #
1683319
rhel-only
Yu Watanabe [Wed, 22 Aug 2018 03:33:27 +0000 (12:33 +0900)]
util: do not use stack frame for parsing arbitrary inputs
This replaces strndupa() by strndup() in socket_address_parse(),
as input string may be too long.
Fixes issue 10007 by ClusterFuzz-External:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10007
(cherry picked from commit
8d30fcb9b51b1d102a589171b6e28f5f370236f6)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Thu, 23 Aug 2018 12:48:40 +0000 (14:48 +0200)]
bus-message: avoid wrap-around when using length read from message
We would read (-1), and then add 1 to it, call message_peek_body(..., 0, ...),
and when trying to make use of the data.
The fuzzer test case is just for one site, but they all look similar.
v2: fix two UINT8_MAX/UINT32_MAX mismatches founds by LGTM
(cherry picked from commit
902000c19830f5e5a96e8948d691b42e91ecb1e7)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Sat, 11 Aug 2018 09:43:09 +0000 (11:43 +0200)]
bus-message: return -EBADMSG not -EINVAL on invalid !gvariant messages
(cherry picked from commit
d831fb6f2bde829f9309aea242f502587662d1cc)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Sat, 11 Aug 2018 09:31:45 +0000 (11:31 +0200)]
fuzz-bus-message: add two test cases that pass now
It seems that they got fixed by one of the patches. Let's add them
just in case.
(cherry picked from commit
edde66ffc2404de58e8b19810951f376efb344da)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Sat, 11 Aug 2018 07:02:48 +0000 (09:02 +0200)]
bus-message: also properly copy struct signature when skipping
The change is similar to that in the previous commit, but I don't have
a reproducer / test case case for this one, so I'm keeping it seperate.
(cherry picked from commit
3d338a302f56c0ef0445660d9856794abe1af8b5)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Sat, 11 Aug 2018 06:32:20 +0000 (08:32 +0200)]
bus-message: fix skipping of array fields in !gvariant messages
We copied part of the string into a buffer that was off by two.
If the element signature had length one, we'd copy 0 bytes and crash when
looking at the "first" byte. Otherwise, we would crash because strncpy would
not terminate the string.
(cherry picked from commit
73777ddba5100fe6c0791cd37a91f24a515f3202)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Fri, 3 Aug 2018 16:05:27 +0000 (18:05 +0200)]
bus-message: output debug information about offset troubles
(cherry picked from commit
0b4775b52747bebf7ecb62062798475629767044)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Fri, 3 Aug 2018 14:36:51 +0000 (16:36 +0200)]
bus-message: drop asserts in functions which are wrappers for varargs version
The function does no processing on it's own, and just forwards arguments
to the other function. Let's just use the asserts there.
(cherry picked from commit
8792bdf8a3311f9e629daa0ec592c97c1cfb2a7c)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Fri, 3 Aug 2018 12:46:57 +0000 (14:46 +0200)]
bus-message: fix calculation of offsets table for arrays
This is similar to the grandparent commit 'fix calculation of offsets table',
except that now the change is for array elements. Same story as before: we need
to make sure that the offsets increase enough taking alignment into account.
While at it, rename 'p' to 'previous' to match similar code in other places.
(cherry picked from commit
f88214cf9d66c93f4d22c4c8980de9ee3ff45bab)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Thu, 2 Aug 2018 12:25:31 +0000 (14:25 +0200)]
bus-message: remove duplicate assignment
(cherry picked from commit
4d82a8d5052fce8c1ea51f8bdec3476fb8cc4747)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Thu, 2 Aug 2018 12:25:11 +0000 (14:25 +0200)]
bus-message: fix calculation of offsets table
The offsets specify the ends of variable length data. We would trust the
incoming data, putting the offsets specified in our message
into the offsets tables after doing some superficial verification.
But when actually reading the data we apply alignment, so we would take
the previous offset, align it, making it bigger then current offset, and
then we'd try to read data of negative length.
In the attached example, the message specifies the following offsets:
[1, 4]
but the alignment of those items is
[1, 8]
so we'd calculate the second item as starting at 8 and ending at 4.
(cherry picked from commit
12603b84d2fb07603e2ea94b240c6b78ad17510e)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Wed, 1 Aug 2018 22:46:20 +0000 (00:46 +0200)]
bus: do not print (null) if the message has unknown type
(cherry picked from commit
e8fd7e4b5b5269377efc641a7da43850822c1250)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Tue, 24 Jul 2018 19:24:53 +0000 (21:24 +0200)]
bus-message: use define
(cherry picked from commit
f22c308aff556bf5c6599ffcb61e637e366ab232)
Resolves: #
1696224
Zbigniew Jędrzejewski-Szmek [Tue, 24 Jul 2018 18:14:39 +0000 (20:14 +0200)]
bus-message: rename function for clarity
There's already message_free_last_container(), so rename to match.
(cherry picked from commit
9c65778d614588d21645163dea97a5fe2c1c4ca5)
Resolves: #
1696224