1
0
mirror of https://github.com/systemd/systemd.git synced 2025-08-19 17:49:52 +03:00
Commit Graph

50012 Commits

Author SHA1 Message Date
f76e564437 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.
2021-03-08 12:00:22 +01:00
cf5366387b 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.
2021-03-08 11:59:09 +01:00
23d24b76f3 homed: wrap some very long lines 2021-03-08 11:53:22 +01:00
a96a2591a1 Merge pull request #18907 from mrc0mmand/test-dissect-sanitizers
test: fix TEST-50-DISSECT under sanitizers
2021-03-07 12:46:15 +01:00
05e8862806 Merge pull request #18910 from yuwata/socket-util-initialize-variable
socket-util: initialize variable with cleanup attribute
2021-03-06 22:37:01 -08:00
f96f5d54b8 socket-util: initialize variable with cleanup attribute
Follow-up for 83e03c4fc2.

Fixes CID#1448460.
2021-03-07 10:32:36 +09:00
9f6235e1b4 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.
2021-03-06 22:44:00 +01:00
648fd18924 test: tidy up the ASan-related stuff 2021-03-06 22:43:58 +01:00
edf1b5ec92 Merge pull request #18892 from poettering/cname-tweaks
resolved: properly handle stub replies for chains of multiple CNAMEs
2021-03-07 03:03:27 +09:00
f91861e49f dissect: fix memleak
Fixes #18903.
2021-03-07 03:02:47 +09:00
57f69536a8 Manual page fixes (#18906) 2021-03-07 02:54:33 +09:00
47f9f84ca9 Merge pull request #18891 from keszybz/size_t-cast-removal
size_t cast removal
2021-03-06 14:32:46 +01:00
5d7da51ee1 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.
2021-03-06 14:04:21 +01:00
b97fc57178 resolved: fully follow CNAMEs in the DNS stub after all
In 2f4d8e577c 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.
2021-03-06 14:04:21 +01:00
39005e1870 resolved: split out helper that checks whether we shall reply with EDNS0 DO
Just some refactoring, no actual code changes.
2021-03-06 14:04:21 +01:00
4838dc4f2b 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
2021-03-06 14:04:10 +01:00
d29958261a 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)
2021-03-06 13:33:50 +01:00
e0ae456a55 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)
2021-03-06 13:33:50 +01:00
2541462f1b Merge pull request #18890 from keszybz/fuzz-bus-match
Add fuzzers for bus match parsing code
2021-03-06 20:35:38 +09:00
7a39ec2e3e 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').
2021-03-06 09:32:18 +01:00
48eb2af68a docs: document fuzzer variables 2021-03-06 09:32:18 +01:00
c1c9510c9b fuzz-main: allow the number of runs to be overridden
This is useful when debugging.
2021-03-06 09:32:18 +01:00
8df3f44c90 sd-bus: fix memleak in failure path in bus_match_parse() 2021-03-06 09:32:18 +01:00
f92d8e4446 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
2021-03-06 09:32:18 +01:00
84f11eda20 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.
2021-03-06 09:32:18 +01:00
dd2e9b7658 test-bus-match: small modernization 2021-03-06 09:32:18 +01:00
c25eb44aef sd-bus: avoid alloc and missing oom check in bus_match_dump() 2021-03-06 09:32:18 +01:00
fc561c8eac sd-bus: let bus_match_dump() take an output file 2021-03-06 09:32:18 +01:00
5963e6f43c 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.
2021-03-06 09:32:18 +01:00
49ba1522fc 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.
2021-03-06 09:27:09 +01:00
4ff42f8327 bus/bus-match: use "ret_" prefix for output parameters 2021-03-06 09:26:57 +01:00
fd5b9b8473 bus/bus-match: inline iterator variable declarations 2021-03-06 09:24:47 +01:00
f6b54e5280 format-table: fix potentail memleak and invalid-free 2021-03-06 09:23:38 +01:00
5a12d1ca1a fstab-generator: fix typo 2021-03-06 08:52:43 +01:00
996c83903d 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.
2021-03-06 15:33:05 +09:00
c2cbe05708 Merge pull request #18896 from poettering/no-localhost-ipv6
if ipv6 is turned off, don't synthesize localhost as ::1 ever
2021-03-06 11:28:38 +09:00
3b5fc147d6 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.
2021-03-06 11:27:04 +09:00
4f67a5d923 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.
2021-03-06 11:26:41 +09:00
07a7441a1c socket-util: refuse "all" and "default" as valid ifnames
Let's avoid collisions with special sysctls.
2021-03-06 11:26:18 +09:00
5d5b6442a2 Merge pull request #18875 from keszybz/localed-error
localed: return error when setting a non-installed keymap
2021-03-05 22:50:41 +00:00
39815435d0 Update 60-sensor.hwdb (#18884)
added support for the Lenovo IdeaPad D330-10IGM screen orientation
2021-03-06 06:11:26 +09:00
747b596ff8 resolved: never return ::1 when localhost or local hostname is resolved while IPv6 is off in the kernel
Fixes: #18812
2021-03-05 20:51:43 +01:00
83e03c4fc2 socket-util: add helper for checking if IPv6 is enabled 2021-03-05 20:51:43 +01:00
571ec995fe socket-util: cache result of socket_ipv6_is_supported()
And while we are at it, log about unexpected errors.
2021-03-05 20:51:43 +01:00
b0ffd2760c 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/
2021-03-05 20:41:07 +01:00
4b30f2e135 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.
2021-03-05 20:38:51 +01:00
6f0647d503 Drop some (size_t) casts
Upcasts of the same type are automatic, so no need for an explicit cast.
2021-03-05 19:27:23 +01:00
fd4e991dfd Drop parens from around already-parenthesized defines 2021-03-05 19:27:23 +01:00
6d12f1b787 network-wait-online: use sd_event_add_time_relative() 2021-03-05 19:27:23 +01:00
63dc82d378 Merge pull request #18852 from yuwata/tree-wide-use-UINT64_MAX
tree-wide: use UINT64_MAX or friends
2021-03-05 17:51:34 +01:00