Anita Zhang [Tue, 23 Mar 2021 07:49:28 +0000 (00:49 -0700)]
process-util: don't allocate max length to read /proc/PID/cmdline
Alternative title: Replace get_process_cmdline()'s fopen()/fread() with
read_full_virtual_file().
When RLIMIT_STACK is set to infinity:infinity, _SC_ARG_MAX will
return
4611686018427387903 (depending on the system, but definitely
something larger than most systems have). It's impractical to allocate this
in one go when most cmdlines are much shorter than that.
Instead use read_full_virtual_file() which seems to increase the buffer
depending on the size of the contents.
(cherry picked from commit
7b7a060e83d6c7de8705904d71978ba4664f0a65)
(cherry picked from commit
fca334fb072545e2db8a81a51f8d1ab343fb610f)
Lincoln Ramsay [Wed, 24 Mar 2021 07:37:25 +0000 (17:37 +1000)]
pid1: do not use generated strings as format strings (#19098)
The generated string may include %, which will confuse both the
xprintf call, and the VA_FORMAT_ADVANCE macro.
Pass the generated string as an argument to a "%s" format string
instead.
(cherry picked from commit
7325a2b2d15af09a9389723d6153050130c0bd36)
(cherry picked from commit
0d4ba1519552761baeb4b464fad8854b24497193)
hide [Tue, 23 Mar 2021 16:05:25 +0000 (01:05 +0900)]
network: fix ipv6 tunnel encapsulation limit (#19087)
The encapsulation limit of IPv6 tunnel can not be set to 4, which is the default value of the encapsulation limit.
(cherry picked from commit
6b1ed5e7e68fc5992a7bdabe4a05a7a3e1e1d898)
(cherry picked from commit
5678859dfd2eb1d018a0f5d468131367d152bbe2)
Lennart Poettering [Tue, 23 Mar 2021 13:04:59 +0000 (14:04 +0100)]
blockdev-util: actually specify an access mode on open()
Linux is pretty lenient here, but we should specify the access mode.
(cherry picked from commit
86b86107942e84de4eb22944251694c0ae21b3ee)
(cherry picked from commit
857533a523d058e9833a553f6ef192ff1ab33b15)
Zbigniew Jędrzejewski-Szmek [Wed, 24 Mar 2021 10:10:17 +0000 (11:10 +0100)]
Revert "resolved: gracefully handle with packets with too large RR count"
This reverts commit
fdfffdaf20a18a50c9a6d858359cf4af6d2f4c8b.
There are multiple reports that this breaks lookups for people, and reverting
this commit, even on the main branch (approx. v248-rc4), fixes the issue.
https://github.com/systemd/systemd/issues/18917#issuecomment-
799421587
https://bodhi.fedoraproject.org/updates/FEDORA-2021-
1c1a870ceb
(cherry picked from commit
7e88a9aef6e6385b0f5889bfc412e03540806085)
David Tardon [Fri, 19 Mar 2021 09:05:47 +0000 (10:05 +0100)]
man: document differences in clean exit status for Type=oneshot
See commit
1f0958f640b87175cd547c1e69084cfe54a22e9d .
(cherry picked from commit
f055cf77862bc580f3afbfaac161d1c060f39411)
(cherry picked from commit
c86f4f5f287258938d0c30354040c3b034b0c066)
Zbigniew Jędrzejewski-Szmek [Mon, 22 Mar 2021 11:51:47 +0000 (12:51 +0100)]
shared/calendarspec: when mktime() moves us backwards, jump forward
When trying to calculate the next firing of 'Sun *-*-* 01:00:00', we'd fall
into an infinite loop, because mktime() moves us "backwards":
Before this patch:
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
tm_within_bounds: good=0 2021-03-29 01:00:00 → 2021-03-29 00:00:00
...
We rely on mktime() normalizing the time. The man page does not say that it'll
move the time forward, but our algorithm relies on this. So let's catch this
case explicitly.
With this patch:
$ TZ=Europe/Dublin faketime 2021-03-21 build/systemd-analyze calendar --iterations=5 'Sun *-*-* 01:00:00'
Normalized form: Sun *-*-* 01:00:00
Next elapse: Sun 2021-03-21 01:00:00 GMT
(in UTC): Sun 2021-03-21 01:00:00 UTC
From now: 59min left
Iter. #2: Sun 2021-04-04 01:00:00 IST
(in UTC): Sun 2021-04-04 00:00:00 UTC
From now: 1 weeks 6 days left <---- note the 2 week jump here
Iter. #3: Sun 2021-04-11 01:00:00 IST
(in UTC): Sun 2021-04-11 00:00:00 UTC
From now: 2 weeks 6 days left
Iter. #4: Sun 2021-04-18 01:00:00 IST
(in UTC): Sun 2021-04-18 00:00:00 UTC
From now: 3 weeks 6 days left
Iter. #5: Sun 2021-04-25 01:00:00 IST
(in UTC): Sun 2021-04-25 00:00:00 UTC
From now: 1 months 4 days left
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=
1941335.
(cherry picked from commit
129cb6e249bef30dc33e08f98f0b27a6de976f6f)
(cherry picked from commit
e5cf86ff98a21b427e1439a001d8e6b81c07b19c)
Zbigniew Jędrzejewski-Szmek [Sun, 21 Mar 2021 19:59:32 +0000 (20:59 +0100)]
shared/calendarspec: abort calculation after 1000 iterations
We have a bug where we seem to enter an infinite loop when running in the
Europe/Dublin timezone. The timezone is "special" because it has negative SAVE
values. The handling of this should obviously be fixed, but let's use a
belt-and-suspenders approach, and gracefully fail if we fail to find an answer
within a specific number of attempts. The code in this function is rather
complex, and it's hard to rule out another bug in the future.
(cherry picked from commit
169615c9a8cdc54d748d4dfc8279be9b3c2bec44)
(cherry picked from commit
f14b80e09e225ccf7cfd8a85578b7e64c3fdebb9)
Lennart Poettering [Mon, 22 Mar 2021 17:27:36 +0000 (18:27 +0100)]
resolved: propagate correct error variable
(cherry picked from commit
4cba52cc7a2191d0b38e605801c60d8648bc67e2)
(cherry picked from commit
78415ea9f7de25fc883af980e91fbffadd5a38b5)
Sergey Bugaev [Mon, 22 Mar 2021 15:31:12 +0000 (18:31 +0300)]
log: protect errno in log_open()
Commit
0b1f3c768ce1bd1490a5e53f539976dcef8ca765 has introduced log_open()
calls after exec fails post-fork. However, the log_open() call itself could
change the value of errno, which, for me, manifested in:
$ coredumpctl gdb
...
Failed to invoke gdb: Success
Fix this by using PROTECT_ERRNO in log_open().
(cherry picked from commit
0e557eef37c9ebcc8f5c19fc6fc44b6fd617cc5d)
(cherry picked from commit
dabf9f2109e5b8cc26d9e0d9188deebff3edf8c2)
Yu Watanabe [Fri, 19 Mar 2021 13:16:22 +0000 (22:16 +0900)]
shell-completion: systemd-run: add missing options
Closes #19044.
(cherry picked from commit
c23bb96b388f371e44c4f1756801dec2b4e72307)
(cherry picked from commit
e60fe377e449f402b61237d6476cde6dadd2e03f)
I'm not sure if all options listed in this patch are already there in v246… But
at least --slice-inherit which was originally requested in #19044 is here.
Worst case, users will get completion to some options which are not there yet.
Antonio Terceiro [Sun, 21 Mar 2021 14:37:51 +0000 (11:37 -0300)]
logs-show: add missing newline in warning message
(cherry picked from commit
17e90001643d07a7353ba88417e12be2ff0fa042)
(cherry picked from commit
012d36ed985dc140b46208fff303a75ecf87d1d4)
Lennart Poettering [Fri, 19 Mar 2021 10:14:52 +0000 (11:14 +0100)]
blockdev-util: fix access to possibly invalidated dirent struct
Let's copy out the string we need from the dirent, there's no reason to
believe the dirent struct might live for longer than one loop iteration.
(cherry picked from commit
c68fc3514ddd53abd7ecfd22afb07aa0ad785c5c)
(cherry picked from commit
928ab001fb77fea95ee833fe27e1913f043587ff)
Lennart Poettering [Fri, 19 Mar 2021 09:36:48 +0000 (10:36 +0100)]
repart: make sure to grow partition table after growing backing loopback file
This fixes the --size= switch, i.e. where we grow a disk image: after
growing it we need to expand the partition table so that its idea of the
the medium size matches the new reality. Otherwise our disk size
calculations in the subsequent steps might still use the original
ungrown size.
(This used to work, I guess this was borked when libfdisk learnt the
concept of "minimized" partition tables)
(cherry picked from commit
f9b3afae96c72564cd4cd766555845f17e3c12a9)
(cherry picked from commit
b132bca9f6dc6ed4965c0ac48bac90e9fc443a9e)
Sam Lunt [Thu, 18 Mar 2021 19:50:30 +0000 (14:50 -0500)]
Wrong index in error message
(cherry picked from commit
6f50c94dfda7c5bd31b364a40038c3d68d1e56ab)
(cherry picked from commit
85e45e8722cd2732c4a26f535ddc6472dd1fb0a6)
Mike Gilbert [Tue, 9 Mar 2021 22:57:37 +0000 (17:57 -0500)]
cg_unified_cached: return ENOMEDIUM if we cannot find a known hierarchy
When the test suite is being run in a foreign environment,
/sys/fs/cgroup might not be set up in a way that we recognize.
Returning ENOMEDIUM causes the tests to be skipped in this case.
Bug: https://bugs.gentoo.org/771819
(cherry picked from commit
2156061fb33811aedb160d1b476793a5b845b143)
(cherry picked from commit
84ed68f5f0c393db3824dbbb2bc2118cf6e03722)
Lennart Poettering [Tue, 16 Mar 2021 15:09:47 +0000 (16:09 +0100)]
journald: restore syslog priority *with* facility bits for stream connections when restarting journald
Fixes: #19019
(cherry picked from commit
d977ef2542accd3e10a7540b3a8b6d1278cc0041)
(cherry picked from commit
b55a7dd551d332440615d5efb07d6620ba4ffb1d)
Yu Watanabe [Sat, 13 Mar 2021 10:56:30 +0000 (19:56 +0900)]
man: DNS/NTP servers received from DHCP server are concatenated with the statically configured ones
Prompted by #9473.
(cherry picked from commit
b63dae3168209a06cefe2b9916667b7754b7de34)
(cherry picked from commit
438777cc00ccf2c05f8a05fa02907aa7be547719)
Kevin Backhouse [Fri, 12 Mar 2021 17:00:56 +0000 (18:00 +0100)]
ask-password-api: fix error handling on invalid unicode character
The integer overflow happens when utf8_encoded_valid_unichar() returns an error
code. The error code is a negative number: -22. This overflows when it is
assigned to `z` (type `size_t`). This can cause an infinite loop if the value
of `q` is 22 or larger.
To reproduce the bug, you need to run `systemd-ask-password` and enter an
invalid unicode character, followed by a backspace character.
GHSL-2021-052
(cherry picked from commit
37ca78a35cd1b9f13e584ccf3d332413c7875e40)
(cherry picked from commit
069525e84a67375e27429cb490e8d28af78e673a)
Zbigniew Jędrzejewski-Szmek [Mon, 1 Mar 2021 22:10:06 +0000 (23:10 +0100)]
resolved: disable event sources before unreffing them
We generally operate on the assumption that a source is "gone" as soon
as we unref it. This is generally true because we have the only reference.
But if something else holds the reference, our unref doesn't really stop
the source and it could fire again.
In particular, on_query_timeout() is called with DnsQuery* as userdata, and
it calls dns_query_stop() which invalidates that pointer. If it was ever
called again, we'd be accessing already-freed memory.
I don't see what would hold the reference. sd-event takes a temporary reference,
but on the sd_event object, not on the individual sources. And our sources
are non-floating, so there is no reference from the sd_event object to the
sources.
For #18427.
(cherry picked from commit
97935302283729c9206b84f5e00b1aff0f78ad19)
(cherry picked from commit
78a43c33c8847ebbc2d3cf530ebe304924c58b32)
Frantisek Sumsal [Mon, 8 Feb 2021 10:26:26 +0000 (11:26 +0100)]
tree-wide: fix the string concatenation warning with clang-12
e.g.:
./src/shared/dissect-image.c:2218:39: error: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Werror,-Wstring-concatenation]
"/usr/lib/os-release\0",
^
../src/shared/dissect-image.c:2217:39: note: place parentheses around the string literal to silence warning
[META_OS_RELEASE] = "/etc/os-release\0"
^
1 error generated.
See: https://reviews.llvm.org/D85545
(cherry picked from commit
8762049792024df1be9f0b219438220bb9ee547d)
(cherry picked from commit
6345ef607976ce0311d01a38ee30855f5416ff1f)
Zbigniew Jędrzejewski-Szmek [Wed, 10 Mar 2021 09:17:23 +0000 (10:17 +0100)]
Revert "udev: do not execute hwdb builtin import twice or thrice"
This reverts commit
876c75fe870846b09b54423a6b719d80bc879b27.
The patch seems to cause usb devices to get some attributes set from the parent
PCI device. 'hwdb' builtin has support for breaking iteration upwards on usb
devices. But when '--subsystem=foo' is specified, iteration is continued. I'm
sure it *could* be figured out, but it seems hard to get all the combinations
correct. So let's revert to functional status quo ante, even if does the lookup
more than once unnecessarily.
Fixes #18125.
(cherry picked from commit
451ba55fecd8b494add2001b3ca3c1915c8fd655)
(cherry picked from commit
f69a0fd38938b20e0b390f7876f8474daa66a100)
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 19:49:53 +0000 (20:49 +0100)]
timedated: fix skipping of comments in config file
Reading file '/usr/lib/systemd/ntp-units.d/80-systemd-timesync.list'
Failed to add NTP service "# This file is part of systemd.", ignoring: Invalid argument
Failed to add NTP service "# See systemd-timedated.service(8) for more information.", ignoring: Invalid argument
:(
(cherry picked from commit
03a81441b1a490f8fc2a19aeb9b23299657c380c)
(cherry picked from commit
279c24e155df495164b68905bfe6340b5de1c797)
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 10:37:17 +0000 (11:37 +0100)]
homed: disable event sources before unreffing them
C.f.
9793530228.
We'd crash when trying to access an already-deallocated object:
Thread no. 1 (7 frames)
#2 log_assert_failed_realm at ../src/basic/log.c:844
#3 event_inotify_data_drop at ../src/libsystemd/sd-event/sd-event.c:3035
#4 source_dispatch at ../src/libsystemd/sd-event/sd-event.c:3250
#5 sd_event_dispatch at ../src/libsystemd/sd-event/sd-event.c:3631
#6 sd_event_run at ../src/libsystemd/sd-event/sd-event.c:3689
#7 sd_event_loop at ../src/libsystemd/sd-event/sd-event.c:3711
#8 run at ../src/home/homed.c:47
The source in question is an inotify source, and the messages are:
systemd-homed[1340]: /home/ moved or renamed, recreating watch and rescanning.
systemd-homed[1340]: Assertion '*_head == _item' failed at src/libsystemd/sd-event/sd-event.c:3035, function event_inotify_data_drop(). Aborting.
on_home_inotify() got called, then manager_watch_home(), which unrefs the
existing inotify_event_source. I assume that the source gets dispatched again
because it was still in the pending queue.
I can't reproduce the issue (timing?), but this should
fix #17824, https://bugzilla.redhat.com/show_bug.cgi?id=
1899264.
(cherry picked from commit
cf5366387b24633284ee92285ea64a282270d591)
(cherry picked from commit
668554d9dbfa9f240dd18455a52c68f3f48bdb81)
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 10:28:19 +0000 (11:28 +0100)]
homed: wrap some very long lines
(cherry picked from commit
23d24b76f3df765fa6dbe7fe815bd4f8e76c9bb5)
(cherry picked from commit
2bfdf842f4a4b7faa5927d4eefeb46729ef6e696)
Yu Watanabe [Sat, 6 Mar 2021 15:05:03 +0000 (00:05 +0900)]
dissect: fix memleak
Fixes #18903.
(cherry picked from commit
f91861e49fea01c98ad0e1131b9141830c029f28)
(cherry picked from commit
dcb5d6f92990104c67dda409fc836c47c8be1e1f)
Zbigniew Jędrzejewski-Szmek [Fri, 5 Mar 2021 14:16:18 +0000 (15:16 +0100)]
sd-bus: fix memleak in failure path in bus_match_parse()
(cherry picked from commit
8df3f44c90a3e479b717e8cc4bb26c95ebbc5cb0)
(cherry picked from commit
3a383fed01e275b05955e6b2e2626363816cdd62)
Zbigniew Jędrzejewski-Szmek [Thu, 4 Mar 2021 20:19:02 +0000 (21:19 +0100)]
sd-bus: fix memstream buffer extraction
I'm getting the following error under valgrind:
==305970== Invalid free() / delete / delete[] / realloc()
==305970== at 0x483E9F1: free (vg_replace_malloc.c:538)
==305970== by 0x4012CD: mfree (alloc-util.h:48)
==305970== by 0x4012EF: freep (alloc-util.h:83)
==305970== by 0x4017F4: LLVMFuzzerTestOneInput (fuzz-bus-match.c:58)
==305970== by 0x401A58: main (fuzz-main.c:39)
==305970== Address 0x59972f0 is 0 bytes inside a block of size 8,192 free'd
==305970== at 0x483FCE4: realloc (vg_replace_malloc.c:834)
==305970== by 0x4C986F7: _IO_mem_finish (in /usr/lib64/libc-2.33.so)
==305970== by 0x4C8F5E0: fclose@@GLIBC_2.2.5 (in /usr/lib64/libc-2.33.so)
==305970== by 0x49D2CDB: fclose_nointr (fd-util.c:108)
==305970== by 0x49D2D3D: safe_fclose (fd-util.c:124)
==305970== by 0x4A4BCCC: fclosep (fd-util.h:41)
==305970== by 0x4A4E00F: bus_match_to_string (bus-match.c:859)
==305970== by 0x4016C2: LLVMFuzzerTestOneInput (fuzz-bus-match.c:58)
==305970== by 0x401A58: main (fuzz-main.c:39)
==305970== Block was alloc'd at
==305970== at 0x483FAE5: calloc (vg_replace_malloc.c:760)
==305970== by 0x4C98787: open_memstream (in /usr/lib64/libc-2.33.so)
==305970== by 0x49D56D6: open_memstream_unlocked (fileio.c:97)
==305970== by 0x4A4DEC5: bus_match_to_string (bus-match.c:859)
==305970== by 0x4016C2: LLVMFuzzerTestOneInput (fuzz-bus-match.c:58)
==305970== by 0x401A58: main (fuzz-main.c:39)
==305970==
So the fclose() which is called from _cleanup_fclose_ clearly reallocates the
buffer (maybe to save memory?). open_memstream(3) says:
The locations referred to by these pointers are updated each time the
stream is flushed (fflush(3)) and when the stream is closed (fclose(3)).
This seems to mean that we should close the stream first before grabbing the
buffer pointer.
(cherry picked from commit
5963e6f43c4f33d5255ef0fb887cdf382bd51c9e)
(cherry picked from commit
f8fd75183bcf9cd6b55c3f8e752863d0083ed772)
caoxia [Thu, 28 Jan 2021 12:50:08 +0000 (20:50 +0800)]
trans_time sec is int32,it will overflow if local system time is later than 2038.
(cherry picked from commit
370d3c31b4637d1b2faeec555da3283e49a6744f)
(cherry picked from commit
02e9679cceeaa8f2fd7a9f2370f222be969ea1da)
Zbigniew Jędrzejewski-Szmek [Wed, 3 Mar 2021 23:36:24 +0000 (00:36 +0100)]
core: fix mtime calculation of dropin files
Nominally, the bug was in unit_load_dropin(), which just took the last mtime
instead of calculating the maximum. But instead of adding code to wrap the
loop, this patch goes in the other direction.
All (correct) callers of config_parse() followed a very similar pattern to
calculate the maximum mtime. So let's simplify things by making config_parse()
assume that mtime is initialized and update it to the maximum. This makes all
the callers that care about mtime simpler and also fixes the issue in
unit_load_dropin().
config_parse_many_nulstr() and config_parse_many() are different, because it
makes sense to call them just once, and current ret_mtime behaviour make sense.
Fixes #17730, https://bugzilla.redhat.com/show_bug.cgi?id=
1933137.
(cherry picked from commit
da46a1bc3cd28ac36114002c216196dae004b05c)
(cherry picked from commit
b29181eaa50a0fd9cefc4bcfbd0e6949038b65c9)
Martin Wilck [Thu, 25 Feb 2021 16:09:03 +0000 (17:09 +0100)]
sd-device: don't use BPF filtering for kernel monitors
BPF filtering accesses fields in the netlink header that are
only filled in by libudev, never by the kernel. Therefore adding
BPF filters for kernel monitors is pointless. Even false filtering
of kernel events might be possible; at least it's hard to prove that
it can't occur.
(cherry picked from commit
d8ce385fe3e5be91b6f414415e10f8897e41d942)
(cherry picked from commit
8f67d7ba3af72b1b3750530c123702246f35987f)
Lennart Poettering [Thu, 25 Feb 2021 14:04:25 +0000 (15:04 +0100)]
udev: when btrfs.ko is not available consider btrfs filesystems not ready
Let's add a special tweak to the btrfs builtin: if /dev/btrfs-control is
not there, let's consider all btrfs file systems as SYSTEMD_READY=0.
This is useful in initrds, where btrfs.ko might be missing. After the
initrd → host transition we can then retigger the device and undo the
SYSTEMD_READY=0 marking.
(cherry picked from commit
97e535c7248cc0457395e2d62b6e7d6c342a0bd2)
(cherry picked from commit
3f94149a9bdf7267453f614aa85f1735913d91a2)
Lennart Poettering [Wed, 24 Feb 2021 16:49:32 +0000 (17:49 +0100)]
cgroup: don't generate BPF firewall unsupported warning on wrong unit
Let's generate the warning on a unit that actually needs the BPF
firewall, and not confusingly already for a sibling of one.
(cherry picked from commit
a437c5e4da666d16f15649461ce45e0e6d735148)
(cherry picked from commit
6349fb59858618bf9b92e4abb77dc4027b2fd35f)
Yu Watanabe [Wed, 24 Feb 2021 04:16:15 +0000 (13:16 +0900)]
timedate: do not ignore fix_system argument in SetLocalRTC method
Fixes #18391.
(cherry picked from commit
2be6c4758e3c27a3f502735881a355e5bfae97b0)
(cherry picked from commit
9b9627b8bc276ea1c1b388dbebec4b907726a86a)
Lennart Poettering [Tue, 23 Feb 2021 14:02:33 +0000 (15:02 +0100)]
bootspec: assume that the root dir is at the top of its file system
Fixes: #17746
(cherry picked from commit
eceb61112c8ece03adfb4fcbc83e357875ca0ceb)
(cherry picked from commit
5c978c4371cbd2550f742b9f72be655020300c9d)
Lennart Poettering [Tue, 23 Feb 2021 13:16:08 +0000 (14:16 +0100)]
efi stub: accept it if our loaded image has no FilePath field set
The firmware spec doesn't really say whether FilePath of the LoadedImage
protocol may be NULL or not. So far we assumed it to be non-NULL, but
apparently the FreeBSD UEFI chainloader sets it to NULL. Handle this
gracefully.
(Noticed and tracked down by Alexander Schreiber)
Fixes: #18733
(cherry picked from commit
685097b9cadf92d21dfa857c3a7ddc1ba115088e)
(cherry picked from commit
151c62b5bcb7124ec43fbd7e21872974e1d9e500)
Lennart Poettering [Mon, 22 Feb 2021 16:38:02 +0000 (17:38 +0100)]
cryptsetup: unescape ID_PART_ENTRY_NAME udev property before using it
Fixes: #18729
(cherry picked from commit
fadd34dd5af9a26edf2906b237ac212169d39f0c)
(cherry picked from commit
01459676644e7d358176963d58a6f8022eaf1ff5)
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 18:02:38 +0000 (19:02 +0100)]
sysctl.d: silence warning if net.core.default_qdisc cannot be set
Kernels can be compiled without the attribute. It's fine if this is not
set, so silence the warning.
(cherry picked from commit
fa98c99ea7f7c5bec3962fa52f4d3496a9777024)
(cherry picked from commit
46c271feee9d660e79f93ae8ffc29955ebd8c61f)
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 08:50:09 +0000 (09:50 +0100)]
xdg-autostart-generator: ignore DBusActivatable=true
See https://wiki.gnome.org/HowDoI/DBusApplicationLaunching and
https://wiki.gnome.org/Initiatives/GnomeGoals/DBusActivatable for a description
of this key:
> Instead of the typical UNIX-style fork()/exec() approach to process creation,
> launching an application is done by sending a D-Bus message to the well-known
> name of that application, causing a D-Bus activation.
>
> Starting processes with D-Bus activation ensures that each application gets
> started in its own pristine environment, as a direct descendent of the
> session -- not in the environment of whatever its parent happened to be. This
> is important for ensuring the app ends up in the correct cgroup, for example.
So this motivation is not important for us: we launch stuff ourselves better.
This fixes warnings during boot:
systemd-xdg-autostart-generator[2274]: /etc/xdg/autostart/org.freedesktop.problems.applet.desktop:92: Unknown key name 'DBusActivatable' in section 'Desktop Entry', ignoring.
(cherry picked from commit
36290e0b97ba032cbd71723f2255917924eadc05)
(cherry picked from commit
8e444ad2e2b9c1940bf54dceb2ac74c909abd286)
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 08:47:32 +0000 (09:47 +0100)]
xdg-autostart-generator: reindent
(cherry picked from commit
9f11f565556410f9484db9e4991f6c04eeafffc7)
(cherry picked from commit
8479eb96c1d6c3039acb4e986cb59ef283aa67e9)
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 09:48:08 +0000 (10:48 +0100)]
rfkill: use short writes and accept long reads
I'm seeing the following with kernel-core-5.10.16-200.fc33.x86_64:
$ sudo SYSTEMD_LOG_LEVEL=debug build/systemd-rfkill
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 0 and type bluetooth.
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Found container virtualization none.
rfkill0: Operating on rfkill device 'tpacpi_bluetooth_sw'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/platform-thinkpad_acpi:bluetooth.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 1 and type wwan.
rfkill1: Operating on rfkill device 'tpacpi_wwan_sw'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/platform-thinkpad_acpi:wwan.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 2 and type bluetooth.
rfkill2: Operating on rfkill device 'hci0'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/pci-0000:00:14.0-usb-0:7:1.0:bluetooth.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 3 and type wlan.
rfkill3: Operating on rfkill device 'phy0'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/pci-0000:04:00.0:wlan.
All events read and idle, exiting.
We were expecting a read of exactly RFKILL_EVENT_SIZE_V1==8 bytes. But the
structure has 9 after [1].
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=
14486c82612a177cb910980c70ba900827ca0894
For some reason the kernel does not accept the full structure size, but cuts
the write short after 8 bytes:
static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
{
struct rfkill_event ev;
/* we don't need the 'hard' variable but accept it */
if (count < RFKILL_EVENT_SIZE_V1 - 1)
return -EINVAL;
/*
* Copy as much data as we can accept into our 'ev' buffer,
* but tell userspace how much we've copied so it can determine
* our API version even in a write() call, if it cares.
*/
count = min(count, sizeof(ev));
if (copy_from_user(&ev, buf, count))
return -EFAULT;
... so it should accept the full size. I'm not sure what is going on here.
But we don't care about the extra fields, so let's accept a write as long as
it's at least RFKILL_EVENT_SIZE_V1.
Fixes #18677.
(cherry picked from commit
a71c09685021cbcecb7566a00342421f635cc002)
(cherry picked from commit
310c58b1db09ed20bbb284f8b7f5fac5a169f16f)
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 09:40:16 +0000 (10:40 +0100)]
rfkill: improve error logging
If we get something of unexpected size, log the sizes. Also, don't log twice.
(cherry picked from commit
6c7afdeab010025c80508effd2b0039bc5181b82)
(cherry picked from commit
c0e60c3079efa8d1d24ab83966b30da90d3d2ae0)
Lennart Poettering [Wed, 17 Feb 2021 22:11:42 +0000 (23:11 +0100)]
journald: when we fail to add a new entry to a journal, return the seqno
Fixes: #18005
(cherry picked from commit
0eaee8281d4699903b8b2cce18c836d4a144aee3)
(cherry picked from commit
06cd0295b94a23ed879697752d85339f815a7788)
Richard Laager [Thu, 18 Feb 2021 07:11:53 +0000 (01:11 -0600)]
Remove outdated disable_ipv6 docs
This was changed in commit
482efedc081b0c4bf2e77a3dee6b979d9c9a5765,
which was released in v243, to only enable and never disable IPv6.
Signed-off-by: Richard Laager <rlaager@wiktel.com>
(cherry picked from commit
f542f3b2ed3cf3e71692d1736f3fdd0ebdc226ef)
(cherry picked from commit
807d6dd157e67648dfb7ad8f8ff85a0b0a3db829)
Vito Caputo [Sun, 29 Nov 2020 00:28:08 +0000 (16:28 -0800)]
journal-file: fix archiving offline journals
The existing set_offline() short-circuit erroneously included
when f->archive was true and header->state was STATE_OFFLINE.
This commit makes the short-circuit f->archive aware, so it will
only catch scenarios where there's not an offlining in progress
and the header state matches the target state of either archived
or offline.
Fixes https://github.com/systemd/systemd/issues/17770
(cherry picked from commit
bb1296b55a222cbab24d533006e730529009258c)
(cherry picked from commit
50e6c3b2e547aa29d1c5e160f9e5aa4dc9e07168)
Luca Boccassi [Mon, 18 Jan 2021 20:15:03 +0000 (20:15 +0000)]
stat-util: fix dir_is_empty_at without path
Use the right FD, and do a fd_reopen instead of a dup, since the
latter will still share the internal pointer which then gets
moved by FOREACH_DIRENT, affecting the caller's FD.
(cherry picked from commit
b8f762f2fe59c94323c95d2aadea68612dca2b04)
(cherry picked from commit
67e03400e881929ca0c940a4a51e76d3c68b6c29)
Lennart Poettering [Mon, 15 Feb 2021 22:31:54 +0000 (23:31 +0100)]
journalctl: rotation is not a reason to warn, but certainly noteworthy
Downgrade the phrasing, since it is a bit misleading.
Fixes: #18465
(cherry picked from commit
71311efe2377d7e37a6af76f110882eed2332f4e)
(cherry picked from commit
884202fc1dcf1600c801ca68311530feee2fc1c2)
Alan Perry [Sat, 13 Feb 2021 03:08:28 +0000 (19:08 -0800)]
no blkid for mmcblk[0-9]boot[0-9]
Don't run blkid on mmcblk[0-9]boot[0-9] devices because they contain
bootloaders or boot parameters, and not partitions or file systems.
(cherry picked from commit
8db704b28b4fd4d13e376cf3495005010443937e)
(cherry picked from commit
584a36e9f7c30d5ace1d734c2e1c4ed19b8393cb)
Lennart Poettering [Fri, 12 Feb 2021 20:16:27 +0000 (21:16 +0100)]
udev: make net_setup_link builtin quiet when link vanishes while we operate on it
Fixes: #16175
(cherry picked from commit
3ec2f7f2e3fc04699d8de27d3cc2e5eecf9a3698)
(cherry picked from commit
cf2d102df9d5e3e389c8527c6f14b4937ba2a3da)
Yu Watanabe [Wed, 3 Feb 2021 15:52:28 +0000 (00:52 +0900)]
network: dhcp6: fix condtion check
(cherry picked from commit
b54aed29c61b9b86dc9cfa214c946586ea1f4972)
(cherry picked from commit
8f2c4ebba2dff6b05b622cda0b1b83d30c20abcb)
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 11:00:09 +0000 (12:00 +0100)]
homework: fix unitialized variable
Coverity CID#
1444703.
(cherry picked from commit
a4aa5742f75f0753c4dfa812059af608c9bab7b6)
(cherry picked from commit
9240155edf57e77dc1a4d85f46e42364021688d8)
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 08:50:49 +0000 (09:50 +0100)]
fsck: make sure we don't read an unitialized variable
This use on %n was completely unnecessary: fprintf returns the number of
characters written. And the issue was that if fprintf failed for whatever
reason, it would not process the %n and m would be unitialized. Rework the
code a bit to simplify it.
Coverity CID#
1444708.
(cherry picked from commit
333ab199a12c7b060d3a3f4d50a8f73ee4fd5ebd)
(cherry picked from commit
dd04760980a0116267d33713348ae8c0f73a6052)
Zbigniew Jędrzejewski-Szmek [Thu, 11 Feb 2021 08:35:52 +0000 (09:35 +0100)]
sd-journal: add forgotten unmap in error path
Bug introduced in
4b5bc5396c090ee41c45cab9052372d296c4a2f4 :(
Coverity CID#
1444709.
(cherry picked from commit
363729c4704b9838f351eaba3acb8b1ed16fae0e)
(cherry picked from commit
530dcf9bb22f18d37d4011940b6b7b6d9c759d6b)
Lennart Poettering [Tue, 9 Feb 2021 14:03:46 +0000 (15:03 +0100)]
inhibit: cut off overly long "who" fields
systemd-inhibit when invoked with a command line will put the whole
command line in the "who" field of the inhibitor lock. This can get
extremely long for shell expressions, making the table "systemd-inhibit
--list" shows ridiculously weirdly formatted. Let's put a limit on the
column width: half of the screen, not more.
(cherry picked from commit
619b0c077cbb12b85c9d752779095b99cfd2c66c)
(cherry picked from commit
b5fc252d26beaab7aec7a51442db81001a5322e9)
Lennart Poettering [Tue, 9 Feb 2021 14:02:21 +0000 (15:02 +0100)]
format-table: don't hit assert if column got less width than it asked for
If one field in a specific column has a maximum size limit, other fields
in the same column might affected by it and get less than they asked
for. Let's make sure we can handle this, and don't assert on this
because surprisingly we got less than what we asked for.
(cherry picked from commit
2cd9f773e29873df1b9f9b09c6c4f78853b16215)
(cherry picked from commit
db3aaa0a661c993994194a60f1a24a1495496bab)
Zbigniew Jędrzejewski-Szmek [Thu, 4 Feb 2021 08:48:19 +0000 (09:48 +0100)]
core: map io.bfq.weight to 1..1000
Aaargh. See the comment in the code.
Apparently the range is like that:
$ sudo bash -c 'echo "default 1001" >/sys/fs/cgroup/user.slice/io.bfq.weight'
bash: line 0: echo: write error: Numerical result out of range
$ uname -r
5.11.0-0.rc4.129.fc34.x86_64
(cherry picked from commit
29eb0eefd14afc9a2424781a28b376db47c3c570)
(cherry picked from commit
c3ba9cb8f1b3ea0211123e1ae8e00bf7494ba233)
Luca Boccassi [Fri, 5 Mar 2021 14:53:20 +0000 (14:53 +0000)]
portablectl: start/stop path/timer units too
Partial backport from:
https://github.com/systemd/systemd/commit/
e26fe5f91158a0d9133e61347650dfb73aadd6bb
Lennart Poettering [Wed, 10 Feb 2021 22:05:51 +0000 (23:05 +0100)]
sd-netlink: spread out sequence numbers a bit
An (imperfect) fix for #14760.
This makes collisions unlikely, but still theoretically possible.
Fixes: #14760
(cherry picked from commit
ac3bc1b819b66f925145629a5c2ccb0a098f0446)
Lennart Poettering [Wed, 10 Feb 2021 17:12:58 +0000 (18:12 +0100)]
sd-netlink: reduce indentation levels a bit
(cherry picked from commit
baf78f1a51793c3dbbeb2b420783573d627f85a8)
Lennart Poettering [Wed, 10 Feb 2021 17:11:20 +0000 (18:11 +0100)]
sd-netlink: use getsockopt_int() where appropriate
(cherry picked from commit
13ec9f103b53ecc555a16048c3901d3320b26ef3)
Lennart Poettering [Wed, 10 Feb 2021 16:59:46 +0000 (17:59 +0100)]
sd-netlink: revamp message serial handling
Let's use uint32_t everywhere to maintain the seqno, since that's what
the kernel does. Prviously in the reply_callback logic we used 64bit,
for no apparent reason.
Using 32bit also provides us with the benefit that we can avoid using
uint64_hash_ops, and can use trivial_hash_ops instead for the reply
hashmap, so that we can store the seqno in the key pointer directly.
While we are at it, let's make sure we never run into serial collisions
internally (32bit is a lot, but not that much), and let's put a limit on
outstanding serials, to catch programming errors.
(cherry picked from commit
b522c4b92a1a8999e008002f0a30acbaf58b55e4)
Lennart Poettering [Mon, 16 Nov 2020 11:41:39 +0000 (12:41 +0100)]
socket-util: add getsockopt_int() helper
(cherry picked from commit
4e25d4cf0f78ef7c960f2b77c941e3d8751535df)
Lennart Poettering [Tue, 10 Nov 2020 13:48:13 +0000 (14:48 +0100)]
resolved: gracefully handle with packets with too large RR count
Apparently, there are plenty routers in place that report an incorrect
RR count in the packets: they declare more RRs than are actually
included.
Let's accept these responses, but let's downgrade them to baseline, i.e.
let's suppress OPT in this case: if they don't even get the RR count
right, let's operate on the absolute baseline, and not bother with
anything fancier such as EDNS.
Prompted-by: https://github.com/systemd/systemd/issues/12841#issuecomment-724063973
Fixes: #3980
Most likely fixes: #12841
(cherry picked from commit
18674159ebbf622a9e6e5a45cc36b38f74dae315)
(cherry picked from commit
fdfffdaf20a18a50c9a6d858359cf4af6d2f4c8b)
Zbigniew Jędrzejewski-Szmek [Fri, 29 Jan 2021 15:21:08 +0000 (16:21 +0100)]
resolved: use reference counting for DnsQueryCandidate objects
Follow-up for
4ea8b443de. The logic that manages DnsQueryCandidate is rather
complicated: a calls to dns_query_complete() that wants to destroy a
DnsQueryCandidate can be nested inside a deep chain of calls. Using reference
counts seems like the simplest approach.
DnsSearchDomain already uses reference counting.
This patch effectively brings dns_query_candidate_go() to the state before
4ea8b443de, but wraps the iteration over DnsQueryCandidate.transactions in
dns_query_candidate_ref+dns_query_candidate_unref.
(cherry picked from commit
0e0fd08fc832b8f42e567d722d388eba086da5ff)
(cherry picked from commit
ab9f7e1a51005f12d3bac83b86716d9d33048eb7)
Zbigniew Jędrzejewski-Szmek [Fri, 29 Jan 2021 15:18:12 +0000 (16:18 +0100)]
resolved: minor cleanups
(cherry picked from commit
c805014a350da7c32eb2bdb408a9fa643c191dee)
(cherry picked from commit
91ba2eac4b6b463026b3a93e5a139923e8f2cfe4)
Zbigniew Jędrzejewski-Szmek [Sun, 17 Jan 2021 18:51:28 +0000 (19:51 +0100)]
resolved: fix use-after-free with queries hitting the cache
When dns_transaction_complete() manages to resolve a query, it invalidates the
query candidate object. It shall not be accessed afterwards.
We have the following chain of calls:
dns_query_candidate_go → dns_transaction_go → dns_transaction_prepare → dns_cache_lookup (success: 1)
→ dns_transaction_complete
After returning back to dns_query_candidate_go(), we'd attempt to continue
iteration over the list of transactions attached to the query candidate,
accessing already freed (and overwritten) memory:
(gdb) bt
0 0x00007f637297cf47 in hashmap_iterate_entry (i=0x7ffe7e15cc90, h=0x706f746b73656465) at ../src/basic/hashmap.c:703
1 _hashmap_iterate (h=0x706f746b73656465, i=i@entry=0x7ffe7e15cc90, value=value@entry=0x7ffe7e15cc88,
key=key@entry=0x0) at ../src/basic/hashmap.c:712
2 0x00007f637297d01b in set_iterate (s=<optimized out>, i=i@entry=0x7ffe7e15cc90, value=value@entry=0x7ffe7e15cc88)
at ../src/basic/hashmap.c:733
hence we crash
3 0x0000557bc99eb80f in dns_query_candidate_go (c=c@entry=0x557bcaf86890) at ../src/resolve/resolved-dns-query.c:139
...but c is not valid here in the second iteration of the loop
4 0x0000557bc99eb720 in dns_query_candidate_notify (c=0x557bcaf86890) at ../src/resolve/resolved-dns-query.c:271
c was valid here at entry...
5 0x0000557bc99efe28 in dns_transaction_complete (t=0x557bcac072f0, state=<optimized out>)
at ../src/resolve/resolved-dns-transaction.c:350
t is a valid transaction (11481 in the backtrace below)
6 0x0000557bc99f1efb in dns_transaction_process_reply (t=0x557bcac072f0, p=<optimized out>)
at ../src/resolve/resolved-dns-transaction.c:1171
7 0x0000557bc99f2d41 in on_dns_packet (s=<optimized out>, fd=<optimized out>, revents=<optimized out>,
userdata=0x557bcac072f0) at ../src/resolve/resolved-dns-transaction.c:1223
8 0x00007f6372a25217 in source_dispatch (s=s@entry=0x557bcb162c50) at ../src/libsystemd/sd-event/sd-event.c:3181
9 0x00007f6372a254fd in sd_event_dispatch (e=0x557bcb15b050) at ../src/libsystemd/sd-event/sd-event.c:3620
10 0x00007f6372a267c8 in sd_event_run (e=e@entry=0x557bcb15b050, timeout=timeout@entry=
18446744073709551615)
at ../src/libsystemd/sd-event/sd-event.c:3678
11 0x00007f6372a269ef in sd_event_loop (e=0x557bcb15b050) at ../src/libsystemd/sd-event/sd-event.c:3700
12 0x0000557bc99ddc14 in run (argc=<optimized out>, argv=<optimized out>) at ../src/resolve/resolved.c:92
13 0x0000557bc99d260a in main (argc=<optimized out>, argv=<optimized out>) at ../src/resolve/resolved.c:99
xxx.name.net systemd-resolved[31705]: Got message type=method_call sender=:1.3644 destination=org.freedesktop.resolve1 path=/org/freedesktop/resolve1 interface=org.freedesktop.resolve1.Manager member=ResolveHostname cookie=2 reply_cookie=0 signature=isit error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: idn2_lookup_u8: xxx → xxx
xxx.name.net systemd-resolved[31705]: Looking up RR for xxx IN A.
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=AddMatch cookie=1102 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=GetNameOwner cookie=1103 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.3324 path=n/a interface=n/a member=n/a cookie=
4294967295 reply_cookie=1103 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Cache miss for xxx.name.net IN A
xxx.name.net systemd-resolved[31705]: Transaction 11481 for <xxx.name.net IN A> scope dns on enp42s0/*.
xxx.name.net systemd-resolved[31705]: Using feature level UDP for transaction 11481.
xxx.name.net systemd-resolved[31705]: Using DNS server 192.168.1.1 for transaction 11481.
xxx.name.net systemd-resolved[31705]: Sending query packet with id 11481 of size 35.
xxx.name.net systemd-resolved[31705]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.3324 path=n/a interface=n/a member=n/a cookie=
4294967295 reply_cookie=1102 signature= error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Match type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0=':1.3644' successfully installed.
xxx.name.net systemd-resolved[31705]: Processing incoming packet on transaction 11481 (rcode=NXDOMAIN).
xxx.name.net systemd-resolved[31705]: Not caching negative entry without a SOA record: xxx.name.net IN A
xxx.name.net systemd-resolved[31705]: Transaction 11481 for <xxx.name.net IN A> on scope dns on enp42s0/* now complete with <rcode-failure> from network (unsigned).
xxx.name.net systemd-resolved[31705]: Positive cache hit for xxx.lan IN A
xxx.name.net systemd-resolved[31705]: Transaction 64364 for <xxx.lan IN A> on scope dns on enp42s0/* now complete with <success> from cache (unsigned).
xxx.name.net systemd-resolved[31705]: Sent message type=method_return sender=n/a destination=:1.3644 path=n/a interface=n/a member=n/a cookie=1104 reply_cookie=2 signature=a(iiay)st error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RemoveMatch cookie=1105 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Freeing transaction 64364.
xxx.name.net systemd[1]: systemd-resolved.service: Main process exited, code=dumped, status=11/SEGV
xxx.name.net systemd[1]: systemd-resolved.service: Failed with result 'core-dump'.
Fixes #16168, https://bugzilla.redhat.com/show_bug.cgi?id=
1895937.
(cherry picked from commit
4ea8b443de8be0f7a932f325dfafa1ee2a843795)
(cherry picked from commit
64317106aed94a6fb758ab6b08ba490873fc5227)
Lennart Poettering [Thu, 17 Dec 2020 15:19:09 +0000 (16:19 +0100)]
test: fix fd_is_mount_point() check
So the currentl and only fd_is_mount_point() check is actually entirely
bogus: it passes "/" as filename argument, but that's not actually a
a valid filename, but an absolute path.
fd_is_mount_point() is written in a way tha the fd refers to a directory
and the specified path is a file directly below it that shall be
checked. The test call actually violated that rule, but still expected
success.
Let's fix this, and check for this explicitly, and refuse it.
Let's extend the test and move it to test-mountpoint-util.c where the
rest of the tests for related calls are placed.
Replaces: #18004
Fixes: #17950
(cherry picked from commit
95231c7215c3ff14c491eb1d2a93312a8fe0c4f6)
(cherry picked from commit
551dd873b0bdfb9e7e47431b2933c8b910228f0c)
Lennart Poettering [Tue, 19 Jan 2021 20:34:20 +0000 (21:34 +0100)]
tree-wide: ignore messages with too long control data
Apparently SELinux inserts control data into AF_UNIX datagrams where we
don't expect it, thus miscalculating the control data. This looks like
something to fix in SELinux, but we still should handle this gracefully
and just drop the offending datagram and continue.
recvmsg_safe() actually already drops the datagram, it's just a matter
of actually ignoring EXFULL (which it generates if control data is too
large) in the right places.
This does this wherever an AF_UNIX/SOCK_DGRAM socket is used with
recvmsg_safe() that is not just internal communication.
Fixes: #17795
Follow-up for:
3691bcf3c5eebdcca5b4f1c51c745441c57a6cd1
(cherry picked from commit
741bfd7f4e60fdc07ecaadbd93f1196dbee657ca)
(cherry picked from commit
b7e0ac754eba3c91b76dc7b92802716144b569b8)
Zbigniew Jędrzejewski-Szmek [Fri, 15 Jan 2021 09:31:00 +0000 (10:31 +0100)]
rpm: expose $systemd_util_dir also as rpm macro
This variable (a.k.a. rootlibexecdir), was exposed through the .pc file, but
not as rpm macro.
The .pc file must be located in the package that provides libraries, which
pulls in a lot of dependencies. In Fedora, the macros are split out to a
separate package so that other packages which need to refer to some systemd
path but don't otherwise require it, can only pull in the (much smaller and
dependency-less) macros package. zram-generator uses the path to specify the
location of systemd-makefs, so by using the rpm macro we'll be able to use
a much smaller buildroot.
(cherry picked from commit
3bc66bfa0136e370a8f7b06c3b69a52f5636ef82)
(cherry picked from commit
490b9ae9dd786e0924cab59d578bb3d69a174079)
Yu Watanabe [Mon, 11 Jan 2021 14:36:42 +0000 (23:36 +0900)]
wifi-util: do not ignore wifi iftype when SSID is not set
Previously, if an interface does not have SSID, e.g. run in mesh-point
type, then the wifi iftype obtained by the netlink call was ignored.
Fixes #18059.
(cherry picked from commit
a66a402da471f6230ab8674fd2c1df6d918773b5)
(cherry picked from commit
fc4eae72f8dd34a334b2707614d9c07974d4d604)
Yu Watanabe [Mon, 11 Jan 2021 14:26:54 +0000 (23:26 +0900)]
wifi-util: cleanup header inclusion
(cherry picked from commit
a5330078158cbd5070e42fd3f91ecb570e210359)
(cherry picked from commit
3885103672047e52c22c8d338baec8598208ca4a)
igo95862 [Mon, 11 Jan 2021 13:04:33 +0000 (16:04 +0300)]
docs: `mesonconf` is not a valid command, `meson configure` is
Meson documentation for `meson configure`
https://mesonbuild.com/Commands.html#configure
(cherry picked from commit
5adfb06d5582adf09421d189b5e2fc6b93fa23e8)
(cherry picked from commit
b81e441b617f77c67d9023fdc803c3ab94345db6)
Luca Boccassi [Sun, 10 Jan 2021 15:36:31 +0000 (15:36 +0000)]
bpf: do not use structured initialization for bpf_attr
It looks like zero'ing the struct is not enough, and with some level
of optimizations there is still non-zero padding left over.
Switch to member-by-member initialization. Also convert all remaining
bpf_attr variables in other files.
(cherry picked from commit
9ca600e2bfacc52a65c89f3485723b2c27394e55)
(cherry picked from commit
95ee2c6b481b7a1f953cb720c35df568b7a6cb70)
Lennart Poettering [Sat, 9 Jan 2021 15:32:55 +0000 (16:32 +0100)]
test-xattr-util: don't insist that /usr supports xattrs
(apparently overlayfs has issues with xattrs, hence don't require that
/usr supports xattrs)
(cherry picked from commit
84319c5c07e7283f31930c799dfd948d251d9b73)
(cherry picked from commit
3dcf950663f906db8a9baa465bd2ac384e832a46)
Luca Boccassi [Fri, 8 Jan 2021 23:47:03 +0000 (23:47 +0000)]
bpf: zero bpf_attr before initialization
When building with Clang and using structured initialization, the
bpf_attr union is not zero-padded, so the kernel misdetects it as
an unsupported extension.
zero it until Clang's behaviour matches GCC. Do not skip the test
on Github Actions anymore.
(cherry picked from commit
28abf5ad3483a417d3d4de561533d282493a7f2a)
(cherry picked from commit
94bb28590b21f37bcd9b831029af05a8a78f49ef)
Zbigniew Jędrzejewski-Szmek [Tue, 5 Jan 2021 11:34:28 +0000 (12:34 +0100)]
shell-completion: fix systemctl set/unset/import-environment
unset-environment is completed with variable names in the environment block.
set-environment the same, but suffixed with "=".
import-environment is completed with variable names in the client environment.
(cherry picked from commit
341992081b6ece1adba270e239f96c9840884885)
(cherry picked from commit
6db2ae66185d8feffe5a19841cff64835afae136)
Lennart Poettering [Wed, 6 Jan 2021 17:05:56 +0000 (18:05 +0100)]
stat-util: don't try to open path on path_is_temporary_fs()
I mean, the old code at least used O_PATH, but still, we shouldn't
allocate/close an fd if we don't have to.
(cherry picked from commit
15308e5083391f6a1b9ce25c5b7323f37544eab8)
(cherry picked from commit
a2f0da2de006c74bca64b3ce5b023e99bcca4498)
Luca Boccassi [Tue, 5 Jan 2021 13:44:26 +0000 (13:44 +0000)]
systemctl: have is-enabled return success for aliases when calling into pid1 too
commit
15d7ab87c4e5917f5788f1f8dce327a1e272bea3 introduced the
change to add an 'alias' state, but it was wired to systemctl
only when running in 'client-side' mode. Return success as
expected and documented also when running in 'server-mode'.
Fixes https://github.com/systemd/systemd/issues/18134
(cherry picked from commit
bf3b428f73eb51f4abb64a80ea5be346b9eeb2fe)
(cherry picked from commit
7c63e5ed58fc5d0cf2653e614fee2765b495085a)
Yu Watanabe [Tue, 29 Dec 2020 16:48:35 +0000 (01:48 +0900)]
resolve: field size in dns resource record may be zero
(cherry picked from commit
b652cccab9ed4091ec347f6e924be131105279e9)
(cherry picked from commit
310fd03e0721eea0e01c090eebb445b5929c85f2)
Yu Watanabe [Tue, 29 Dec 2020 16:44:04 +0000 (01:44 +0900)]
siphash: introduce siphash24_compress_safe()
(cherry picked from commit
0b71a7e01d8d04a3668c349e2320c42c786f2382)
(cherry picked from commit
9401ed294dd491c10fb7e8b4e9097c86d02227ad)
Dmitry Borodaenko [Wed, 23 Dec 2020 01:54:04 +0000 (17:54 -0800)]
man/systemd-nspawn: document hashing machine name for uid base
Explicitly document the behavior introduced in #7437: when picking a new
UID shift base with "-U", a hash of the machine name will be tried
before falling back to fully random UID base candidates.
(cherry picked from commit
68709a636c838e0754b49caa6ff2d4168e3c99c8)
(cherry picked from commit
4032a1358897ecaf4e485399b03c6186fb2c90e9)
Yu Watanabe [Mon, 21 Dec 2020 07:33:20 +0000 (16:33 +0900)]
journal-importer: ignore invalid field at one more place
Fixes oss-fuzz#28817.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28817
(cherry picked from commit
8786d4bbe43b5f6493982bcb5211e010f99deb57)
(cherry picked from commit
cefb123e8ab65772a2a609081ca34ac6ea1267d6)
Luca BRUNO [Mon, 21 Dec 2020 09:55:04 +0000 (09:55 +0000)]
man/localtime: document default timezone
This explicitly documents the default `UTC` timezone which is used
by systemd and (other softwares) when `/etc/localtime` is not present.
Ref: https://github.com/systemd/systemd/blob/v247/src/basic/time-util.c#L1460-L1469
(cherry picked from commit
3d909037e3bb86bb14ceef98325b2759b938a4b3)
(cherry picked from commit
a580023f1da331bd454ea72cad146215b255e0d0)
Florian Klink [Sun, 20 Dec 2020 17:24:05 +0000 (18:24 +0100)]
man/systemd.netdev: clarify the wireguard AllowedIPs= setting
`AllowedIPs=` only affects "routing inside the network interface
itself", as in, which wireguard peer packets with a specific destination
address are sent to, and what source addresses are accepted from which
peer.
To cause packets to be sent via wireguard in first place, a route via
that interface needs to be added - either in the `[Routes]` section on
the `.network` matching the wireguard interface, or outside of networkd.
This is a common cause of misunderstanding, because tools like wg-quick
also add routes to the interface. However, those tools are meant as a
"extremely simple script for easily bringing up a WireGuard interface,
suitable for a few common use cases (from their manpage).
Networkd also should support other usecases - like setting AllowedIPs to
0.0.0.0/0 and ::/0 and having a dynamic routing protocol setting more
specific routes (or the user manually setting them).
Reported-In: https://github.com/systemd/systemd/issues/14176
(cherry picked from commit
c6b90e5c5e54e98b6aed38677f77d8491f2e49c8)
(cherry picked from commit
14475e0e793be33bfad371c6d3545c7448f78730)
Yu Watanabe [Tue, 15 Dec 2020 19:50:39 +0000 (04:50 +0900)]
logs-show: refuse data which contain invalid fields
(cherry picked from commit
805d67c565d57e0915162164f7e5e3026a29a2c5)
(cherry picked from commit
2a76d510d9c50dd8f4bd21194cf3f457760aea52)
Yu Watanabe [Tue, 15 Dec 2020 19:44:31 +0000 (04:44 +0900)]
journal: refuse data which contain invalid fields
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25353.
(cherry picked from commit
f2bd032044ca3cd4b454dd0ba86719effcf34dc0)
(cherry picked from commit
2c53886b4f6d987aca180e725064e59bbdaec714)
Yu Watanabe [Tue, 15 Dec 2020 19:36:14 +0000 (04:36 +0900)]
journal: move journal_field_valid() to journal_file.c
(cherry picked from commit
adce225a104d0b7503aa7322db15d1c6dd8b8093)
(cherry picked from commit
b7f69284f1eb21c51cb659a96685cffc6c472ffd)
Christian Ehrhardt [Tue, 15 Dec 2020 11:05:14 +0000 (12:05 +0100)]
test: use modern qemu numa arguments
Upgrading to qemu 5.2 breaks TEST-36-NUMAPOLICY like:
qemu-system-x86_64: total memory for NUMA nodes (0x0) should
equal RAM size (0x20000000)
Use the new (as in >=2014) form of memdev in test 36:
-object memory-backend-ram,id=mem0,size=512M -numa node,memdev=mem0,nodeid=0
Since some target systems are as old as qemu 1.5.3 (CentOS7) but the new
kind to specify was added in qemu 2.1 this needs to add version parsing and
add the argument only when qemu is >=5.2.
Fixes #17986.
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
(cherry picked from commit
43b49470d1f2808555c07f64cd0a1529b7ddd559)
(cherry picked from commit
b7171ae4bdb5c827c1ab0c97934b75f3169af8bb)
Lennart Poettering [Mon, 14 Dec 2020 15:36:00 +0000 (16:36 +0100)]
bus-util: improve logging when we can't connect to the bus
Previously, we'd already have explicit logging for the case where
$XDG_RUNTIME_DIR is not set. Let's also add some explicit logging for
the EPERM/ACCESS case. Let's also in both cases suggest the
--machine=<user>@.host syntax.
And while we are at it, let's remove side-effects from the macro.
By checking for both the EPERM/EACCES case and the $XDG_RUNTIME_DIR case
we will now catch both the cases where people use "su" to issue a
"systemctl --user" operation, and those where they (more correctly, but
still not good enough) call "su -".
Fixes: #17901
(cherry picked from commit
1ecb46724cae151606bc825f0e39f14d4dfe1a0e)
(cherry picked from commit
36bc4a18fd8117cab0d4ff02eac89579a86cd399)
Lennart Poettering [Mon, 14 Dec 2020 12:16:39 +0000 (13:16 +0100)]
sd-bus: make credential acquisition more graceful
So far when asked for augmented bus credentials and the process was
already gone we'd fail fatally. Let's make this graceful instead, and
never allow augmenting fail due to PID having vanished — unless the
augmenting is the explicit and only purpose of the requested operation.
This should be safe as clients have to explicitly query the acquired
creds anyway and handle if they couldn't be acquired. Moreover we
already handle permission problems gracefully, thus clients must be
ready to deal with missing creds.
This is useful to make selinux authorization work for short-lived client
proceses. PReviously we'd augment creds to have more info to log about
(the selinux decision would not be based on augmented data however,
because that'd be unsafe), and would fail if we couldn't get it. Now,
we'll try to acquire the data, but if we cannot acquire it, we'll still
do the selinux check, except that logging will be more limited.
(cherry picked from commit
f8ecc2c00df7bd810557f3056ec12f6a0730812d)
(cherry picked from commit
a1b1ef65a4371e8aec4b0df1326e4cb5de005e80)
Lennart Poettering [Mon, 14 Dec 2020 12:20:28 +0000 (13:20 +0100)]
sd-bus: 'ret' parameter to sd_bus_query_sender_creds() is not optional, check for it
(cherry picked from commit
1ca37419b13b836d7fb2b9815d5efb6dccc62134)
(cherry picked from commit
a62421591e3edb47fa2a85499e4d721eeff73c42)
Owen W. Taylor [Wed, 13 Jan 2021 13:34:21 +0000 (08:34 -0500)]
Fix nss-resolve to properly fallback in a Flatpak sandbox
For unknown reasons, sd-bus has trouble connecting to the filtered
D-Bus system proxy exported by Flatpak and the connection to the
bus is closed during authentication. Don't mistake this for a remote
error - that was causing a hard "not found" failure rather than a fallback.
See: https://bugzilla.redhat.com/show_bug.cgi?id=
1912131 for background.
Jonathan G. Underwood [Tue, 22 Dec 2020 20:04:52 +0000 (20:04 +0000)]
cryptsetup: add support for workqueue options
This commit adds support for disabling the read and write
workqueues with the new crypttab options no-read-workqueue
and no-write-workqueue. These correspond to the cryptsetup
options --perf-no_read_workqueue and --perf-no_write_workqueue
respectively.
(cherry picked from commit
227acf0009bde2cd7f8bc371615b05e84137847d)
Zbigniew Jędrzejewski-Szmek [Wed, 16 Dec 2020 14:56:44 +0000 (15:56 +0100)]
test-login: skip consistency checks when logind is not active
There are two ways in swich sd_login_* functions acquire data:
some are derived from the cgroup path, but others use the data serialized
by logind.
When the tests are executed under Fedora's mock, without systemd-spawn
but instead in a traditional chroot, test-login gets confused:
the "outside" cgroup path is visible, so sd_pid_get_unit() and
sd_pid_get_session() work, but sd_session_is_active() and other functions
that need logind data fail.
Such a buildroot setup is fairly bad, but it can be encountered in the wild, so
let's just skip the tests in that case.
/* Information printed is from the live system */
sd_pid_get_unit(0, …) → "session-237.scope"
sd_pid_get_user_unit(0, …) → "n/a"
sd_pid_get_slice(0, …) → "user-1000.slice"
sd_pid_get_session(0, …) → "237"
sd_pid_get_owner_uid(0, …) → 1000
sd_pid_get_cgroup(0, …) → "/user.slice/user-1000.slice/session-237.scope"
sd_uid_get_display(1000, …) → "(null)"
sd_uid_get_sessions(1000, …) → [0] ""
sd_uid_get_seats(1000, …) → [0] ""
Assertion 'r >= 0' failed at src/libsystemd/sd-login/test-login.c:104, function test_login(). Aborting.
(cherry picked from commit
ac5644635dba54ce5eb0ff394fc0bc772a984849)
(based on
4275f1c95e730ca9422463be29747ad4b6b1fb91)
Christian Göttsche [Tue, 1 Sep 2020 13:48:53 +0000 (15:48 +0200)]
selinux: create unit invocation links with default SELinux context
(cherry picked from commit
a3f5fd964bc9fcac82315f8c82d4ca575afdd1b7)
Yu Watanabe [Mon, 16 Nov 2020 07:25:43 +0000 (16:25 +0900)]
network: honor M or O flag in RA even if IPv6AcceptRA.DHCPv6Cleint=always
Follow-up for
ac24e418d9bc988ecf114c464701b35934948178.
The original motivation of the commit and RFE #15339 is to start dhcpv6
client in managed mode when neither M nor O flag is set in the RA.
But, previously, if the setting is set to "always", then the DHCPv6
client is always started in managed mode even if O flag is set in the
RA. Such the behavior breaks RFC 7084.
(cherry picked from commit
0e686feaff71465e3220f234871f66a39f0f57ad)
shenyangyang4 [Thu, 10 Dec 2020 11:44:31 +0000 (06:44 -0500)]
journalctl: don't skip the entries that have the same seqnum
These two judgement can't judge that two entries are repeating fully.
So i think seqnum is needed to make full judgement.
(cherry picked from commit
b17f651a17cd6ec0ceac7835f2f8607fbd9ddb95)
(cherry picked from commit
60fc09f5db900d622aa956fdc98283f149b4a8b2)
Lennart Poettering [Fri, 11 Dec 2020 11:04:11 +0000 (12:04 +0100)]
sd-bus: use SOCK_CLOEXEC on one more socket
(cherry picked from commit
68a3d9153883b90c99ea2aec20075146ce58beaa)
(cherry picked from commit
4657ed6f93c2e2edd47e65035edfea21fcaa26dd)
Ondrej Mosnacek [Mon, 14 Dec 2020 15:36:27 +0000 (16:36 +0100)]
resolved: create stub-resolv.conf symlink with correct security label
Use symlink_atomic_label() instead of symlink_atomic() as the symlink
may need a different label than the parent directory.
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
(cherry picked from commit
7b87bece5ded3e8f068df8402901198c069ab5cf)
(cherry picked from commit
029331f56a1b6e4fb2823a56a108f741a576d7af)
Andrew Balmos [Fri, 11 Dec 2020 03:15:24 +0000 (22:15 -0500)]
efi: Only use arm flags if supported
Support gcc 8 on arm
(cherry picked from commit
361f41645cdf920d431e2d68dcfa3f98088c2e03)
(cherry picked from commit
cb17e9874fb881d0147d44b29163e35471cf00f6)