]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
4 years agooomd: "downgrade" level of message 18915/head
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 08:21:25 +0000 (09:21 +0100)] 
oomd: "downgrade" level of message

PID1 already logs about the service being started, so this line isn't necessary
in normal use. Also, by the time it is emitted, the service has already
signalled readiness, so let's not say "starting" but "started".

4 years agovarlink: avoid using dangling ref in varlink_close_unref()
Zbigniew Jędrzejewski-Szmek [Sun, 7 Mar 2021 15:42:35 +0000 (16:42 +0100)] 
varlink: avoid using dangling ref in varlink_close_unref()

Fixes #18025, https://bugzilla.redhat.com/show_bug.cgi?id=1931034.

We drop the reference stored in Manager.managed_oom_varlink_request in two code paths:
vl_disconnect() which is installed as a disconnect callback, and in manager_varlink_done().
But we also make a disconnect from manager_varlink_done(). So we end up with the following
call stack:

(gdb) bt
 0  vl_disconnect (s=0x112c7b0, link=0xea0070, userdata=0xe9bcc0) at ../src/core/core-varlink.c:414
 1  0x00007f1366e9d5ac in varlink_detach_server (v=0xea0070) at ../src/shared/varlink.c:1210
 2  0x00007f1366e9d664 in varlink_close (v=0xea0070) at ../src/shared/varlink.c:1228
 3  0x00007f1366e9d6b5 in varlink_close_unref (v=0xea0070) at ../src/shared/varlink.c:1240
 4  0x0000000000524629 in manager_varlink_done (m=0xe9bcc0) at ../src/core/core-varlink.c:479
 5  0x000000000048ef7b in manager_free (m=0xe9bcc0) at ../src/core/manager.c:1357
 6  0x000000000042602c in main (argc=5, argv=0x7fff439c43d8) at ../src/core/main.c:2909

When we enter vl_disconnect(), m->managed_oom_varlink_request.n_ref==1.
When we exit from vl_discconect(), m->managed_oom_varlink_request==NULL. But
varlink_close_unref() has a copy of the pointer in *v. When we continue executing
varlink_close_unref(), this pointer is dangling, and the call to varlink_unref()
is done with an invalid pointer.

4 years agopid1: return varlink error on the right connection
Zbigniew Jędrzejewski-Szmek [Sat, 6 Mar 2021 18:06:08 +0000 (19:06 +0100)] 
pid1: return varlink error on the right connection

4 years agoMerge pull request #18930 from anitazha/oomdfixleak
Luca Boccassi [Tue, 9 Mar 2021 11:37:10 +0000 (11:37 +0000)] 
Merge pull request #18930 from anitazha/oomdfixleak

oomd: fix memory leak

4 years agooomd: wrap paths in oomd_insert_cgroup_context with empty_to_root 18930/head
Anita Zhang [Mon, 8 Mar 2021 18:21:37 +0000 (10:21 -0800)] 
oomd: wrap paths in oomd_insert_cgroup_context with empty_to_root

4 years agoMerge pull request #18932 from poettering/filename-max
Yu Watanabe [Tue, 9 Mar 2021 05:15:49 +0000 (14:15 +0900)] 
Merge pull request #18932 from poettering/filename-max

Drop use of FILENAME_MAX

4 years agotimedated: fix skipping of comments in config file
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

:(

4 years agoMerge pull request #18927 from poettering/dissect-alloca-fix
Luca Boccassi [Mon, 8 Mar 2021 22:42:55 +0000 (22:42 +0000)] 
Merge pull request #18927 from poettering/dissect-alloca-fix

dissect-image: don't mix two forms of stack allocation in one line

4 years agooomd: move TAKE_PTR to end of oomd_insert_cgroup_context()
Anita Zhang [Mon, 8 Mar 2021 18:35:31 +0000 (10:35 -0800)] 
oomd: move TAKE_PTR to end of oomd_insert_cgroup_context()

Fixes #18926

4 years agooomd: add unit test to repro #18926
Anita Zhang [Mon, 8 Mar 2021 18:51:12 +0000 (10:51 -0800)] 
oomd: add unit test to repro #18926

4 years agotest: output FILENAME_MAX vs. PATH_MAX sizes 18932/head
Lennart Poettering [Mon, 8 Mar 2021 21:45:03 +0000 (22:45 +0100)] 
test: output FILENAME_MAX vs. PATH_MAX sizes

Also, make sure our assumption that FILENAME_MAX == PATH_MAX holds.

4 years agomountpoint-util: replace our last use of FILENAME_MAX by PATH_MAX
Lennart Poettering [Mon, 8 Mar 2021 21:44:35 +0000 (22:44 +0100)] 
mountpoint-util: replace our last use of FILENAME_MAX by PATH_MAX

4 years agofs-util: replace use of FILENAME_MAX by PATH_MAX in readlinkat_malloc()
Lennart Poettering [Mon, 8 Mar 2021 21:43:50 +0000 (22:43 +0100)] 
fs-util: replace use of FILENAME_MAX by PATH_MAX in readlinkat_malloc()

While we are at it, let's also add an overflow check and do other
modernizations.

4 years agodocs: reference NAME_MAX where we talk about filenames
Lennart Poettering [Mon, 8 Mar 2021 21:43:41 +0000 (22:43 +0100)] 
docs: reference NAME_MAX where we talk about filenames

4 years agodocs: document not to use FILENAME_MAX in our codebase
Lennart Poettering [Mon, 8 Mar 2021 21:43:07 +0000 (22:43 +0100)] 
docs: document not to use FILENAME_MAX in our codebase

It's a weird thing. Let's explain why.

4 years agoefi-loader: make efi_loader_entry_name_valid() check a bit stricter
Lennart Poettering [Mon, 8 Mar 2021 21:27:05 +0000 (22:27 +0100)] 
efi-loader: make efi_loader_entry_name_valid() check a bit stricter

Previously we'd just check if the ID was no-empty an no longer than
FILENAME_MAX. The latter was probably a mistake, given the comment next
to it. Instead of fixing that to check for NAME_MAX let's instead  just
switch over to filename_is_valid() which odes a similar check, plus a
some minor additional checks. After all we do want that valid EFI boot
menu entry ids are usable as filenames.

4 years agobasic: tighten two filename length checks
Lennart Poettering [Mon, 8 Mar 2021 20:44:39 +0000 (21:44 +0100)] 
basic: tighten two filename length checks

This fixes two checks where we compare string sizes when validating with
FILENAME_MAX. In both cases the check apparently wants to check if the
name fits in a filename, but that's not actually what FILENAME_MAX can
be used for, as it — in contrast to what the name suggests — actually
encodes the maximum length of a path.

In both cases the stricter change doesn't actually change much, but the
use of FILENAME_MAX is still misleading and typically wrong.

4 years agoformat-table: simplify table_set_display_all() and keep it private
Lennart Poettering [Thu, 4 Mar 2021 19:50:34 +0000 (20:50 +0100)] 
format-table: simplify table_set_display_all() and keep it private

4 years agoMerge pull request #18918 from yuwata/man-no-new-priv-18914
Luca Boccassi [Mon, 8 Mar 2021 20:57:32 +0000 (20:57 +0000)] 
Merge pull request #18918 from yuwata/man-no-new-priv-18914

man: update documents about NoNewPrivileges=

4 years agodissect-image: don#t mix two forms of stack allocation in one expression 18927/head
Lennart Poettering [Mon, 8 Mar 2021 16:31:47 +0000 (17:31 +0100)] 
dissect-image: don#t mix two forms of stack allocation in one expression

It's not necessarily safe to do this, hence don't.

4 years agodissect-image: remove unnecessary parens
Lennart Poettering [Mon, 8 Mar 2021 16:31:35 +0000 (17:31 +0100)] 
dissect-image: remove unnecessary parens

4 years agoMerge pull request #18925 from keszybz/hwdb-news-syscalls-update
Lennart Poettering [Mon, 8 Mar 2021 16:01:40 +0000 (17:01 +0100)] 
Merge pull request #18925 from keszybz/hwdb-news-syscalls-update

Update of hwdb & news & syscalls for v248

4 years agoMerge pull request #18921 from yuwata/seccomp-syscallfilter-18916
Lennart Poettering [Mon, 8 Mar 2021 16:01:23 +0000 (17:01 +0100)] 
Merge pull request #18921 from yuwata/seccomp-syscallfilter-18916

seccomp: fix issue in system call filter with errno

4 years agoMerge pull request #18924 from keszybz/homed-inotify-crash
Lennart Poettering [Mon, 8 Mar 2021 14:12:30 +0000 (15:12 +0100)] 
Merge pull request #18924 from keszybz/homed-inotify-crash

Homed inotify crash

4 years agotest: fix the last subtest of TEST-50-DISSECT under sanitizers
Frantisek Sumsal [Mon, 8 Mar 2021 10:28:40 +0000 (11:28 +0100)] 
test: fix the last subtest of TEST-50-DISSECT under sanitizers

Follow-up to 9f6235e1b4490ce7abbd125ed975343de6bcb9cd.

4 years agohwdb: update for v248 18925/head
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 12:13:27 +0000 (13:13 +0100)] 
hwdb: update for v248

Seems to be additions and corrections as usual.
Includes an update of the chromiumos autosuspend rules.

4 years agoNEWS: add items since -rc2
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 12:12:10 +0000 (13:12 +0100)] 
NEWS: add items since -rc2

4 years agocore/execute: sort conditions to make them match documentation 18918/head
Yu Watanabe [Mon, 8 Mar 2021 01:37:43 +0000 (10:37 +0900)] 
core/execute: sort conditions to make them match documentation

4 years agoman: update document about NoNewPrivileges=
Yu Watanabe [Mon, 8 Mar 2021 01:36:49 +0000 (10:36 +0900)] 
man: update document about NoNewPrivileges=

Fixes #18914.

4 years agotest: add one more test for system call filter with errno 18921/head
Yu Watanabe [Mon, 8 Mar 2021 03:06:09 +0000 (12:06 +0900)] 
test: add one more test for system call filter with errno

4 years agoseccomp: do not ignore deny-listed syscalls with errno when list is allow-list
Yu Watanabe [Mon, 8 Mar 2021 03:00:32 +0000 (12:00 +0900)] 
seccomp: do not ignore deny-listed syscalls with errno when list is allow-list

Previously, if the hashmap is allow-list and a new deny-listed syscall
is added, seccomp_parse_syscall_filter() simply drop the new syscall
from hashmap even if error number is specified.

This makes 'allow-list' hashmap store two types of entries:
- allow-listed syscalls, which are stored with negative value (-1).
- deny-listed syscalls, which are stored with specified errno.

Fixes #18916.

4 years agoseccomp: use FLAGS_SET() macro
Yu Watanabe [Mon, 8 Mar 2021 02:58:58 +0000 (11:58 +0900)] 
seccomp: use FLAGS_SET() macro

4 years agocore,seccomp: refuse to specify errno for allow-listed syscalls
Yu Watanabe [Mon, 8 Mar 2021 02:57:59 +0000 (11:57 +0900)] 
core,seccomp: refuse to specify errno for allow-listed syscalls

4 years agocore: drop meaningless parse_syscall_and_errno() calls
Yu Watanabe [Mon, 8 Mar 2021 02:54:05 +0000 (11:54 +0900)] 
core: drop meaningless parse_syscall_and_errno() calls

parse_syscall_and_errno() does not check the validity of syscall name or
syscall group name, but it just split into syscall name and errno.
So, it is not necessary to call it for SystemCallLog=.

4 years agoseccomp: fix comment and change variable name
Yu Watanabe [Mon, 8 Mar 2021 02:10:54 +0000 (11:10 +0900)] 
seccomp: fix comment and change variable name

4 years agotest: parse_syscall_and_errno() accepts zero errno
Yu Watanabe [Mon, 8 Mar 2021 02:10:26 +0000 (11:10 +0900)] 
test: parse_syscall_and_errno() accepts zero errno

4 years agotest: move test_parse_syscall_and_errno() to test-seccomp.c
Yu Watanabe [Mon, 8 Mar 2021 02:09:37 +0000 (11:09 +0900)] 
test: move test_parse_syscall_and_errno() to test-seccomp.c

4 years agomissing-syscalls: do not generate trailing empty line
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 11:39:50 +0000 (12:39 +0100)] 
missing-syscalls: do not generate trailing empty line

The generated .h file was already like this, but what the generator generated
did not match. So we only need to update the generator.

4 years agosyscalls: update tables
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 11:31:46 +0000 (12:31 +0100)] 
syscalls: update tables

bfin_spinlock and cache_sync are dropped from the table, but didn't have
numbers assigned.

mount_setattr was added in v5.11-rc4-35-g2a1867219c.

4 years agohomed: unref the sd_event object after the sources 18924/head
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 10:52:09 +0000 (11:52 +0100)] 
homed: unref the sd_event object after the sources

Shouldn't make any difference, but let's first flush any pending messages, then
unref the reference-counted stuff, and only at the end do the direct free calls.

4 years agohomed: disable event sources before unreffing them
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.

4 years agohomed: wrap some very long lines
Zbigniew Jędrzejewski-Szmek [Mon, 8 Mar 2021 10:28:19 +0000 (11:28 +0100)] 
homed: wrap some very long lines

4 years agohwdb: 60-keyboard:: Update Dell Privacy Micmute Hotkey Map
Perry Yuan [Mon, 8 Mar 2021 02:50:49 +0000 (21:50 -0500)] 
hwdb: 60-keyboard:: Update Dell Privacy Micmute Hotkey Map

Dell new Privacy feature provide new hardware level privacy
protect for users
This patch remaps scancode 0x120001 to key code F20 micmute
The old matching string cannot cover some other Dell products
which have the privacy feature,expand the string to all the system
that can load the privacy driver,privacy driver already detect the
system if it can support this feature. So here we can safely just
map the micmute key to scancode 0x120001

Signed-off-by: Perry Yuan <perry_yuan@dell.com>
4 years agoMerge pull request #18908 from mrc0mmand/fix-packit
Zbigniew Jędrzejewski-Szmek [Sun, 7 Mar 2021 20:31:31 +0000 (21:31 +0100)] 
Merge pull request #18908 from mrc0mmand/fix-packit

ci: correctly drop patches with non four digit indexes

4 years agoMerge pull request #18911 from keszybz/coverity-inspired-fixes
Luca Boccassi [Sun, 7 Mar 2021 15:12:08 +0000 (15:12 +0000)] 
Merge pull request #18911 from keszybz/coverity-inspired-fixes

Coverity inspired fixes

4 years agoMerge pull request #18907 from mrc0mmand/test-dissect-sanitizers
Zbigniew Jędrzejewski-Szmek [Sun, 7 Mar 2021 11:46:15 +0000 (12:46 +0100)] 
Merge pull request #18907 from mrc0mmand/test-dissect-sanitizers

test: fix TEST-50-DISSECT under sanitizers

4 years agoTEST-15-DROPINS: improve check 18911/head
Zbigniew Jędrzejewski-Szmek [Sun, 7 Mar 2021 11:27:55 +0000 (12:27 +0100)] 
TEST-15-DROPINS: improve check

https://github.com/systemd/systemd/pull/18579#discussion_r588983813

4 years agobasic/namespae-util: avoid one allocation
Zbigniew Jędrzejewski-Szmek [Sun, 7 Mar 2021 11:22:28 +0000 (12:22 +0100)] 
basic/namespae-util: avoid one allocation

4 years agobasic/os-util: adjust indentation
Zbigniew Jędrzejewski-Szmek [Sun, 7 Mar 2021 11:15:42 +0000 (12:15 +0100)] 
basic/os-util: adjust indentation

4 years agojournal-remote: check return value from MHD_add_response_header
Zbigniew Jędrzejewski-Szmek [Sun, 7 Mar 2021 11:08:06 +0000 (12:08 +0100)] 
journal-remote: check return value from MHD_add_response_header

Sadly, the API does not allow us to distinguish oom from invalid settings.
If the call fails, let's assume oom happened.

Coverity CID#1444714.

4 years agocore: fix netns/ipcns socket confusion
Zbigniew Jędrzejewski-Szmek [Sun, 7 Mar 2021 10:52:40 +0000 (11:52 +0100)] 
core: fix netns/ipcns socket confusion

Fixup for a70581ffb5c13c91c76ff73ba6f5f3ff59c5a915. Coverity CID#1448383.

4 years agoci: revert back to --werror instead of -Dc_args=-Werror 18908/head
Frantisek Sumsal [Sat, 6 Mar 2021 22:17:01 +0000 (23:17 +0100)] 
ci: revert back to --werror instead of -Dc_args=-Werror

-Dc_args=/-Dcpp_args= don't play well with the RPM hardening macros
using $CFLAGS/$CPPFLAGS, since they're mutually exclusive.

4 years agoMerge pull request #18910 from yuwata/socket-util-initialize-variable
Anita Zhang [Sun, 7 Mar 2021 06:37:01 +0000 (22:37 -0800)] 
Merge pull request #18910 from yuwata/socket-util-initialize-variable

socket-util: initialize variable with cleanup attribute

4 years agosocket-util: initialize variable with cleanup attribute 18910/head
Yu Watanabe [Sun, 7 Mar 2021 01:31:26 +0000 (10:31 +0900)] 
socket-util: initialize variable with cleanup attribute

Follow-up for 83e03c4fc23dae0cbb3fd4e7c2f9ef533fc26160.

Fixes CID#1448460.

4 years agoci: correctly drop patches with non four digit indexes
Frantisek Sumsal [Sat, 6 Mar 2021 21:53:09 +0000 (22:53 +0100)] 
ci: correctly drop patches with non four digit indexes

4 years agotest: fix TEST-50-DISSECT under sanitizers 18907/head
Frantisek Sumsal [Sat, 6 Mar 2021 21:22:32 +0000 (22:22 +0100)] 
test: fix TEST-50-DISSECT under sanitizers

This test would normally get stuck when trying to mount the verity image
due to:

systemd-udevd[299]: dm-0: '/usr/sbin/dmsetup udevflags 6293812'(err) '==371==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.'
systemd-udevd[299]: dm-0: Process '/usr/sbin/dmsetup udevflags 6293812' failed with exit code 1
...
systemd-udevd[299]: dm-0: '/usr/sbin/dmsetup udevcomplete 6293812'(err) '==372==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.'
systemd-udevd[299]: dm-0: Process '/usr/sbin/dmsetup udevcomplete 6293812' failed with exit code 1.
systemd-udevd[299]: dm-0: Command "/usr/sbin/dmsetup udevcomplete 6293812" returned 1 (error), ignoring.

so let's add a simple udev rule which sets $LD_PRELOAD for the block
subsystem.

Also, install the ASan library along with necessary dependencies into
the verity minimal image, to get rid of the annoying (yet harmless)
errors about missing library from $LD_LIBRARY.

4 years agotest: tidy up the ASan-related stuff
Frantisek Sumsal [Sat, 6 Mar 2021 21:21:30 +0000 (22:21 +0100)] 
test: tidy up the ASan-related stuff

4 years agoMerge pull request #18892 from poettering/cname-tweaks
Yu Watanabe [Sat, 6 Mar 2021 18:03:27 +0000 (03:03 +0900)] 
Merge pull request #18892 from poettering/cname-tweaks

resolved: properly handle stub replies for chains of multiple CNAMEs

4 years agodissect: fix memleak
Yu Watanabe [Sat, 6 Mar 2021 15:05:03 +0000 (00:05 +0900)] 
dissect: fix memleak

Fixes #18903.

4 years agoManual page fixes (#18906)
Carlo Wood [Sat, 6 Mar 2021 17:54:33 +0000 (18:54 +0100)] 
Manual page fixes (#18906)

4 years agoMerge pull request #18891 from keszybz/size_t-cast-removal
Lennart Poettering [Sat, 6 Mar 2021 13:32:46 +0000 (14:32 +0100)] 
Merge pull request #18891 from keszybz/size_t-cast-removal

size_t cast removal

4 years agoresolved: when synthesizing stub replies from multiple upstream packet, let's avoid... 18892/head
Lennart Poettering [Fri, 5 Mar 2021 17:20:59 +0000 (18:20 +0100)] 
resolved: when synthesizing stub replies from multiple upstream packet, let's avoid RR duplicates

If we synthesize a stub reply from multiple upstream packet (i.e. a
series of CNAME/DNAME redirects), it might happen that we add the same
RR to a different reply section at a different CNAME/DNAME redirect
chain element. Let's clean this up once we are about to send the reply
message to the client: let's remove sections from "lower-priority"
sections when they are already listed in a "higher-priority" section.

4 years agoresolved: fully follow CNAMEs in the DNS stub after all
Lennart Poettering [Fri, 5 Mar 2021 15:50:04 +0000 (16:50 +0100)] 
resolved: fully follow CNAMEs in the DNS stub after all

In 2f4d8e577ca7bc51fb054b8c2c8dd57c2e188a41 I argued that following
CNAMEs in the stub is not necessary anymore. However, I think it' better
to revert to the status quo ante and follow it after all, given it is
easy for us and makes sure our D-Bus/varlink replies are more similar to
our DNS stub replies that way, and we save clients potential roundtrips.

Hence, whenever we hit a CNAME/DNAME redirect, let's restart the query
like we do for the D-Bus/Varlink case, and collect replies as we go.

4 years agoresolved: split out helper that checks whether we shall reply with EDNS0 DO
Lennart Poettering [Fri, 5 Mar 2021 17:01:27 +0000 (18:01 +0100)] 
resolved: split out helper that checks whether we shall reply with EDNS0 DO

Just some refactoring, no actual code changes.

4 years agoresolved: handle multiple CNAME redirects in a single reply from upstream
Lennart Poettering [Fri, 5 Mar 2021 16:53:31 +0000 (17:53 +0100)] 
resolved: handle multiple CNAME redirects in a single reply from upstream

www.netflix.com responds with a chain of CNAMEs in the same packet.
Let's handle that properly (so far we only followed CNAMEs a single step
when in the same packet)

Fixes: #18819
4 years agoresolved: tighten checks in dns_resource_record_get_cname_target()
Lennart Poettering [Fri, 5 Mar 2021 16:48:43 +0000 (17:48 +0100)] 
resolved: tighten checks in dns_resource_record_get_cname_target()

Let's refuse to consider CNAME/DNAME replies matching for RR types where
that is not really conceptually allow (i.e. on CNAME/DNAME lookups
themselves).

(And add a similar check to dns_resource_key_match_cname_or_dname() too,
which implements a smilar match)

4 years agodns-query: export CNAME_MAX, so that we can use it in other files, too
Lennart Poettering [Fri, 5 Mar 2021 16:47:45 +0000 (17:47 +0100)] 
dns-query: export CNAME_MAX, so that we can use it in other files, too

Let's rename it a bit, to be more explanatory while exporting it.

(And let's bump the CNAME limit to 16 — 8 just sounded so little)

4 years agoMerge pull request #18890 from keszybz/fuzz-bus-match
Yu Watanabe [Sat, 6 Mar 2021 11:35:38 +0000 (20:35 +0900)] 
Merge pull request #18890 from keszybz/fuzz-bus-match

Add fuzzers for bus match parsing code

4 years agosd-bus: remove unnecessary variable 18890/head
Zbigniew Jędrzejewski-Szmek [Fri, 5 Mar 2021 15:36:37 +0000 (16:36 +0100)] 
sd-bus: remove unnecessary variable

Also use structued initialization in one more place, use '\0' for NUL bytes,
and move variable to the right block (the code was OK, but it is strange to
have 'char *value' defined in a different scope then 'size_t value_allocated').

4 years agodocs: document fuzzer variables
Zbigniew Jędrzejewski-Szmek [Fri, 5 Mar 2021 15:06:15 +0000 (16:06 +0100)] 
docs: document fuzzer variables

4 years agofuzz-main: allow the number of runs to be overridden
Zbigniew Jędrzejewski-Szmek [Fri, 5 Mar 2021 15:01:50 +0000 (16:01 +0100)] 
fuzz-main: allow the number of runs to be overridden

This is useful when debugging.

4 years agosd-bus: fix memleak in failure path in bus_match_parse()
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()

4 years agofuzz-bus-match: add example from bugzilla#1935084
Zbigniew Jędrzejewski-Szmek [Fri, 5 Mar 2021 16:10:53 +0000 (17:10 +0100)] 
fuzz-bus-match: add example from bugzilla#1935084

The fuzzer seems to have no trouble with this sample. It seems that the
problem reported in the bug is not caused by the match parsing code. But
let's add the sample just in case.

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

4 years agofuzz-bus-match: new fuzzer
Zbigniew Jędrzejewski-Szmek [Thu, 4 Mar 2021 20:29:48 +0000 (21:29 +0100)] 
fuzz-bus-match: new fuzzer

This fuzzer is based on test-bus-match. Even the initial corpus is
derived entirely from it.

https://bugzilla.redhat.com/show_bug.cgi?id=1935084 shows an crash
in bus_match_parse(). I checked the coverage stats on oss-fuzz, and
sadly existing fuzzing did not cover this code at all.

4 years agotest-bus-match: small modernization
Zbigniew Jędrzejewski-Szmek [Thu, 4 Mar 2021 20:25:14 +0000 (21:25 +0100)] 
test-bus-match: small modernization

4 years agosd-bus: avoid alloc and missing oom check in bus_match_dump()
Zbigniew Jędrzejewski-Szmek [Thu, 4 Mar 2021 20:22:47 +0000 (21:22 +0100)] 
sd-bus: avoid alloc and missing oom check in bus_match_dump()

4 years agosd-bus: let bus_match_dump() take an output file
Zbigniew Jędrzejewski-Szmek [Thu, 4 Mar 2021 20:20:00 +0000 (21:20 +0100)] 
sd-bus: let bus_match_dump() take an output file

4 years agosd-bus: fix memstream buffer extraction
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.

4 years agofuzz-bus-message: move sources to src/libsystemd/
Zbigniew Jędrzejewski-Szmek [Thu, 4 Mar 2021 13:40:55 +0000 (14:40 +0100)] 
fuzz-bus-message: move sources to src/libsystemd/

There's also fuzz-bus-label, but despite the name, it tests code that is in
src/shared/, so it shouldn't move.

4 years agobus/bus-match: use "ret_" prefix for output parameters
Zbigniew Jędrzejewski-Szmek [Thu, 4 Mar 2021 13:35:46 +0000 (14:35 +0100)] 
bus/bus-match: use "ret_" prefix for output parameters

4 years agobus/bus-match: inline iterator variable declarations
Zbigniew Jędrzejewski-Szmek [Thu, 4 Mar 2021 13:33:42 +0000 (14:33 +0100)] 
bus/bus-match: inline iterator variable declarations

4 years agoformat-table: fix potentail memleak and invalid-free
Yu Watanabe [Sat, 6 Mar 2021 01:10:31 +0000 (10:10 +0900)] 
format-table: fix potentail memleak and invalid-free

4 years agofstab-generator: fix typo
Yu Watanabe [Sat, 6 Mar 2021 01:12:55 +0000 (10:12 +0900)] 
fstab-generator: fix typo

4 years agoudev: run link_update() with increased retry count in second invocation
Michal Sekletar [Thu, 4 Mar 2021 16:35:22 +0000 (17:35 +0100)] 
udev: run link_update() with increased retry count in second invocation

In PR #17431 we have introduced retry loop in link_update() in order to
maximize the chance that we end up with correct target when there are
multiple contenders for given symlink.

Number of iterations in retry loop is either 1 or
LINK_UPDATE_MAX_RETRIES, depending on the value of 'initialized' db
flag. When device appears for the first time we need to set the
flag before calling link_update() via update_devnode() for the second
time to make sure we run the second invocation with higher retry loop
counter.

4 years agoMerge pull request #18896 from poettering/no-localhost-ipv6
Yu Watanabe [Sat, 6 Mar 2021 02:28:38 +0000 (11:28 +0900)] 
Merge pull request #18896 from poettering/no-localhost-ipv6

if ipv6 is turned off, don't synthesize localhost as ::1 ever

4 years agotest: disable at_exit LSan check for dbus.service
Frantisek Sumsal [Fri, 5 Mar 2021 22:20:45 +0000 (23:20 +0100)] 
test: disable at_exit LSan check for dbus.service

When running integration tests under sanitizers D-Bus fails to
shutdown cleanly, causing unnecessary noise in the logs:

```
dbus-daemon[272]: ==272==LeakSanitizer has encountered a fatal error.
dbus-daemon[272]: ==272==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
dbus-daemon[272]: ==272==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
```

Since we're not "sanitizing" D-Bus anyway let's disable LSan's at_exit
check for the dbus.service to get rid of this error.

4 years agodissect: avoid overflow access by NULLSTR_FOREACH
Luca Boccassi [Fri, 5 Mar 2021 20:19:44 +0000 (20:19 +0000)] 
dissect: avoid overflow access by NULLSTR_FOREACH

NULLSTR_FOREACH expects two terminating NULs, but the joined string
for extension-release.d only had the canonical one.
Use a placeholder when joining and fix it manually.

4 years agosocket-util: refuse "all" and "default" as valid ifnames
Lennart Poettering [Fri, 5 Mar 2021 19:33:15 +0000 (20:33 +0100)] 
socket-util: refuse "all" and "default" as valid ifnames

Let's avoid collisions with special sysctls.

4 years agoMerge pull request #18875 from keszybz/localed-error
Luca Boccassi [Fri, 5 Mar 2021 22:50:41 +0000 (22:50 +0000)] 
Merge pull request #18875 from keszybz/localed-error

localed: return error when setting a non-installed keymap

4 years agoUpdate 60-sensor.hwdb (#18884)
ChopperRob [Fri, 5 Mar 2021 21:11:26 +0000 (22:11 +0100)] 
Update 60-sensor.hwdb (#18884)

added support for the Lenovo IdeaPad D330-10IGM screen orientation

4 years agoresolved: never return ::1 when localhost or local hostname is resolved while IPv6... 18896/head
Lennart Poettering [Fri, 5 Mar 2021 17:47:10 +0000 (18:47 +0100)] 
resolved: never return ::1 when localhost or local hostname is resolved while IPv6 is off in the kernel

Fixes: #18812
4 years agosocket-util: add helper for checking if IPv6 is enabled
Lennart Poettering [Fri, 5 Mar 2021 19:37:24 +0000 (20:37 +0100)] 
socket-util: add helper for checking if IPv6 is enabled

4 years agosocket-util: cache result of socket_ipv6_is_supported()
Lennart Poettering [Fri, 5 Mar 2021 17:46:31 +0000 (18:46 +0100)] 
socket-util: cache result of socket_ipv6_is_supported()

And while we are at it, log about unexpected errors.

4 years agobasic: move shared/sysctl-util.[ch] → basic/
Lennart Poettering [Fri, 5 Mar 2021 19:39:58 +0000 (20:39 +0100)] 
basic: move shared/sysctl-util.[ch] → basic/

This is self-contained ans allows us later to use the provided APIs from
other code in src/basic/

4 years agosysctl-util: use read_full_virtual_file() for reading sysctls
Lennart Poettering [Fri, 5 Mar 2021 19:34:16 +0000 (20:34 +0100)] 
sysctl-util: use read_full_virtual_file() for reading sysctls

Given these files are part of procfs, let's use the correct API calls
for reading them.

This changes one occasion of read_one_line_file() to
read_full_virtual_file(), which superficially is a different thing, but
shouldn't actually be a difference, since sysctls can't be longer than
4K anyway, and the piecemeal logic behind read_one_line_file() cannot
work with the special semantics of procfs anyway.

4 years agoDrop some (size_t) casts 18891/head
Zbigniew Jędrzejewski-Szmek [Fri, 5 Mar 2021 17:02:28 +0000 (18:02 +0100)] 
Drop some (size_t) casts

Upcasts of the same type are automatic, so no need for an explicit cast.

4 years agoDrop parens from around already-parenthesized defines
Zbigniew Jędrzejewski-Szmek [Fri, 5 Mar 2021 16:57:14 +0000 (17:57 +0100)] 
Drop parens from around already-parenthesized defines

4 years agonetwork-wait-online: use sd_event_add_time_relative()
Zbigniew Jędrzejewski-Szmek [Fri, 5 Mar 2021 16:53:34 +0000 (17:53 +0100)] 
network-wait-online: use sd_event_add_time_relative()

4 years agoMerge pull request #18852 from yuwata/tree-wide-use-UINT64_MAX
Zbigniew Jędrzejewski-Szmek [Fri, 5 Mar 2021 16:51:34 +0000 (17:51 +0100)] 
Merge pull request #18852 from yuwata/tree-wide-use-UINT64_MAX

tree-wide: use UINT64_MAX or friends

4 years agoMerge pull request #18885 from yuwata/udev-fix-import-program-rhbz-1935062
Frantisek Sumsal [Fri, 5 Mar 2021 13:19:21 +0000 (14:19 +0100)] 
Merge pull request #18885 from yuwata/udev-fix-import-program-rhbz-1935062

udev: fix importing program result