Commit Graph

45489 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek ceb17827fa resolved: simplify allocation failure handling in dns_stub_process_query()
Old code was correct, but let's make things more explicit.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek b8b46b1ce5 basic/set,hashmap: pass through allocation info in more cases 2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek fcc1d0315d basic/set: add set_ensure_consume()
This combines set_ensure_allocated() with set_consume(). The cool thing is that
because we know the hash ops, we can correctly free the item if appropriate.
Similarly to set_consume(), the goal is to simplify handling of the case where
the item needs to be freed on error and if already present in the set.
2020-06-24 10:38:15 +02:00
Jay Burger a1ba8c5b71 feature to honor first shutdown request to completion
Create unit tests per established norm at position 52

check in_set first before getting unit
2020-06-24 09:42:01 +02:00
Lennart Poettering 7bf6babfa2
Merge pull request #16112 from poettering/nss-systemd-block-fix
rework nss-systemd recursion lock
2020-06-24 08:39:44 +02:00
Lennart Poettering bc8d57f290
Merge pull request #16223 from cgzones/user_selinux
Initialize SELinux in user instances
2020-06-24 08:39:13 +02:00
Christian Göttsche 3d9fbea43e selinux: update mac_selinux_free()
* Drop mac_selinux_use() condition from mac_selinux_free(): if the
  passed pointer holds memory we want to free it even if SELinux is
  disabled

* Drop NULL-check cause man:freecon(3) states that freecon(NULL) is a
  well-defined NOP

* Assert that on non-SELinux builds the passed pointer is always NULL,
  to avoid memory leaks
2020-06-24 08:38:34 +02:00
Gigadoc2 1cdc42f283
hwdb: add another Logitech G502 Hero variant (#16256)
The commit 67551ea already adds the G502 Hero mouse, but apparently
there are multiple variants with the same ID but different names.
2020-06-24 09:46:46 +10:00
Zbigniew Jędrzejewski-Szmek 0d0248c665
Merge pull request #16246 from benzea/benzea/xdg-autostart
Minor xdg-autostart changes
2020-06-23 21:13:07 +02:00
Zbigniew Jędrzejewski-Szmek 21856e3462
Merge pull request #16213 from yuwata/network-cleanup-link-state-file
network: cleanup link state file
2020-06-23 21:09:24 +02:00
Luca Boccassi 87d25bdead make-autosuspend-rules: restore compatibility with Python3 < 3.6
The f'...' format was introduced in Python 3.6 ( https://www.python.org/dev/peps/pep-0498/ )
and returns an error when systemd is built on a system with an older Python3 version:

<...>
  File /home/bluca/git/systemd/tools/make-autosuspend-rules.py, line 15
    print(f'pci:v{vendor:08X}d{device:08X}*')
                                           ^
SyntaxError: invalid syntax
[2/388] Generating version.h with a custom command.
ninja: build stopped: subcommand failed.
$ python3 --version
Python 3.5.6

Use an older format to keep backward compatibility.
2020-06-23 21:02:15 +02:00
Zbigniew Jędrzejewski-Szmek db3b8d5d41 fuzz-udev-rules: rewrite to not require root privileges
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20142.

It turns out we don't need to do all this preparatory work if we want to parse
just one file.
2020-06-23 20:53:19 +02:00
Christian Göttsche a9ba0e328f Make failures of mac_selinux_init() fatal 2020-06-23 19:10:07 +02:00
Christian Göttsche a11bfc17dc Initialize SELinux in user instances
Call mac_selinux_init() to setup the label cache, so objects can be
created with default SELinux context.

Fixes: #8004
2020-06-23 19:10:03 +02:00
Zbigniew Jędrzejewski-Szmek c238a1f5f1 udev: split rules object creation and loading
The only functional change is to downgrade the log line to avoid double
logging.
2020-06-23 18:04:18 +02:00
Lennart Poettering 037b0a47b0 userdb: replace recursion lock
Previously we'd used the existance of a specific AF_UNIX socket in the
abstract namespace as lock for disabling lookup recursions. (for
breaking out of the loop: userdb synthesized from nss → nss synthesized
from userdb → userdb synthesized from nss → …)

I did it like that because it promised to work the same both in static
and in dynmically linked environments and is accessible easily from any
programming language.

However, it has a weakness regarding reuse attacks: the socket is
securely hashed (siphash) from the thread ID in combination with the
AT_RANDOM secret. Thus it should not be guessable from an attacker in
advance. That's only true if a thread takes the lock only once and
keeps it forever. However, if a thread takes and releases it multiple
times an attacker might monitor that and quickly take the lock
after the first iteration for follow-up iterations.

It's not a big issue given that userdb (as the primary user for this)
never released the lock and we never made the concept a public
interface, and it was only included in one release so far, but it's
something that deserves fixing. (moreover it's a local DoS only, only
permitting to disable native userdb lookups)

With this rework the libnss_systemd.so.2 module will now export two
additional symbols. These symbols are not used by glibc, but can be used
by arbitrary programs: one can be used to disable nss-systemd, the other
to check if it is currently disabled.

The lock is per-thread. It's slightly less pretty, since it requires
people to manually link against C code via dlopen()/dlsym(), but it
should work safely without the aforementioned weakness.
2020-06-23 17:24:24 +02:00
Lennart Poettering 6e78726e20 nss-systemd: skip /etc/gshadow look-ups when we just need the GID of a group 2020-06-23 17:24:24 +02:00
Lennart Poettering 88d775b734 util: add dlfcn-util.h
This just adds a _cleanup_ helper call encapsulating dlclose().

This also means libsystemd-shared is linked against libdl now. I don't
think this is much of an issue, since libdl is part of glibc anyway, and
anything from exotic. It's not an optional part of the OS (think: NSS
requires dynamic linking), hence this pulls in no deps and is almost
certainly loaded into all process' memory anyway.

[zj: use DEFINE_TRIVIAL_CLEANUP_FUNC().]
2020-06-23 17:23:27 +02:00
Lennart Poettering 21385e639a man: replace perl bug tracker link that went away with link to paper
Fixes: #16245
2020-06-23 17:19:05 +02:00
Lennart Poettering 92d64d1444 man: s/PROGRAMM/PROGRAM/ 2020-06-23 17:13:26 +02:00
Zbigniew Jędrzejewski-Szmek 311a0e2ee6 Revert "cgroup: Allow empty assignments of Memory{Low,Min}="
This reverts commit 53aa85af24.
The reason is that that patch changes the dbus api to be different than
the types declared by introspection api.

Replaces #16122.
2020-06-23 16:54:23 +02:00
Susant Sahani 3d0c8750c5 networkctl: display DHCPv4 server address 2020-06-23 19:13:06 +09:00
Yu Watanabe fd1f3b3eed dhcp: fix entry name in parsing lease file 2020-06-23 19:13:06 +09:00
Yu Watanabe 46986251d6 network: drop duplicated information from link state file
Those entries are already in DHCP4 lease file, and not used anymore.
2020-06-23 19:13:05 +09:00
Yu Watanabe 5202be27ee sd-network: drop unused functions 2020-06-23 19:13:05 +09:00
Yu Watanabe 862e710820 networkctl: use lease file to get DHCPv4 client ID 2020-06-23 19:13:05 +09:00
Yu Watanabe d41fa6ee91 networkctl: use lease file to get DHCPv4 address 2020-06-23 19:13:05 +09:00
Yu Watanabe 35cab5f99d networkctl: load DHCPv4 lease file and use timezone data from the lease file 2020-06-23 19:13:05 +09:00
Yu Watanabe ef0daa1129 libsystemd-network: move prototypes of dhcp_lese_save/load() to network-internal.h 2020-06-23 19:13:05 +09:00
Dave Reisner cc479760b4 Revert "job: Don't mark as redundant if deps are relevant"
This reverts commit 097537f07a.

At least Fedora and Debian have already reverted this at the distro
level because it causes more problems than it solves. Arch is debating
reverting it as well [0] but would strongly prefer that this happens
upstream first. Fixes #15188.

[0] https://bugs.archlinux.org/task/66458
2020-06-23 11:42:45 +02:00
Benjamin Berg 9d9a9500cd xdg-autostart: Ignore all files with GNOME autostart phase
If an autostart file for GNOME has a phase specified, then this implies
it is a session service that needs to be started at a specific time.

We have no way of handling the ordering, and while it does make sense
to explicitly hide these services with X-systemd-skip, there is no point
in even trying to handle them.
2020-06-23 11:20:27 +02:00
Benjamin Berg 566cb7e23b xdg-autostart: Fix info message if Type= is not Application
The message was copy-pasted and not changed to correctly specify what
the problem was.
2020-06-23 11:04:44 +02:00
Luca Boccassi 0389f4fa81 core: add RootHash and RootVerity service parameters
Allow to explicitly pass root hash (explicitly or as a file) and verity
device/file as unit options. Take precedence over implicit checks.
2020-06-23 10:50:09 +02:00
Lennart Poettering 6fe01ced0e nspawn: mkdir selinux mount point once, but not twice
Since #15533 we didn't create the mount point for selinuxfs anymore.

Before it we created it twice because we mount selinuxfs twice: once the
superblock, and once we remount its bind mound read-only. The second
mkdir would mean we'd chown() the host version of selinuxfs (since
there's only one selinuxfs superblock kernel-wide).

The right time to create mount point point is once: before we mount the
selinuxfs. But not a second time for the remount.

Fixes: #16032
2020-06-23 10:17:36 +02:00
Zbigniew Jędrzejewski-Szmek 75ae672bb2
Merge pull request #16196 from mrc0mmand/travis-simplification
travis: use a matrix for similar jobs
2020-06-23 10:16:18 +02:00
Zbigniew Jędrzejewski-Szmek 5c9918aca0
Merge pull request #16216 from nabijaczleweli/make-a-fuss
man/sd-makefs: mention that mkswap can also be run and fix deadlink to btrfs-man5(5)
2020-06-23 10:12:47 +02:00
Lennart Poettering 65804d6aff selinux-util: tweak log_enforcing_errno() to return the errno passed in or 0 when in non-enforcing mode
Also, some other, minor modernizations.
2020-06-23 07:48:44 +02:00
Elisei Roca 9e1732924d
test-functions: read /usr/etc/nsswitch.conf if /etc/nsswitch.conf does not exist (#16195)
See this for more info why and since when this change is needed: https://build.opensuse.org/request/show/807179.
2020-06-23 07:42:15 +02:00
наб affa893da0
man/sd-makefs: link to btrfs.wiki.kernel.org for btrfs-man5, since the man-pages link is dead
This also adds a <citerefentry project="url"> type,
since the other btrfs manpages use man-pages/die-net and are alive,
and btrfs.w.k.o won't be used anywhere else
2020-06-22 23:12:13 +02:00
Zbigniew Jędrzejewski-Szmek 2edc494216
Merge pull request #16237 from keszybz/revert-message-type-check
Revert "bus-message: immediately reject messages with invalid type"
2020-06-22 22:46:13 +02:00
Lennart Poettering c2c193f79a
Merge pull request #16179 from keszybz/auto-suspend-hwdb
Convert autosuspend rules to hwdb
2020-06-22 17:38:42 +02:00
Zbigniew Jędrzejewski-Szmek b98f393d88 bus-message: add macro for calculation of offset from the page 2020-06-22 17:18:35 +02:00
Zbigniew Jędrzejewski-Szmek b17af3e503 bus-message: avoid dereferencing a NULL pointer
We'd try to map a zero-byte buffer from a NULL pointer, which is undefined behaviour.

src/systemd/src/libsystemd/sd-bus/bus-message.c:3161:60: runtime error: applying zero offset to null pointer
    #0 0x7f6ff064e691 in find_part /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:3161:60
    #1 0x7f6ff0640788 in message_peek_body /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:3283:16
    #2 0x7f6ff064e8db in enter_struct_or_dict_entry /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:3967:21
    #3 0x7f6ff06444ac in bus_message_enter_struct /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:4009:13
    #4 0x7f6ff0641dde in sd_bus_message_enter_container /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:4136:21
    #5 0x7f6ff0619874 in sd_bus_message_dump /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-dump.c:178:29
    #6 0x4293d9 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-bus-message.c:39:9
    #7 0x441986 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:558:15
    #8 0x44121e in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:470:3
    #9 0x443164 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__1::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/libfuzzer/FuzzerLoop.cpp:770:7
    #10 0x4434bc in fuzzer::Fuzzer::Loop(std::__1::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/libfuzzer/FuzzerLoop.cpp:799:3
    #11 0x42d2bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:846:6
    #12 0x42978a in main /src/libfuzzer/FuzzerMain.cpp:19:10
    #13 0x7f6fef13c82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #14 0x407808 in _start (out/fuzz-bus-message+0x407808)
2020-06-22 17:09:49 +02:00
Zbigniew Jędrzejewski-Szmek a9c9f79ece Revert "bus-message: immediately reject messages with invalid type"
This reverts commit a2dd991d0f.
Creation of such messages is evidently useful, and at least sdbus-c++ test
suite depends on that.

Fixes #16193.
2020-06-22 16:54:15 +02:00
Zbigniew Jędrzejewski-Szmek 6cd55d6f74 shared/bus-util: fix misleading error handling
set_put()/set_ensure_put() return 0, not -EEXIST, if the entry is already
found in the set. In this case this does not make any difference, but let's
not confuse the reader.
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek e2ab8e09c8 udevadm-monitor: simplify creation of arg_tag_filter set
This version is more efficient, which doesn't matter, but it allows us
to remove a bunch of error handling, which is always nice.
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek 804a436582 fuzz-netdev-parser: add test case for earlier version of preceding patches
AddressSanitizer:DEADLYSIGNAL
=================================================================
==12==ERROR: AddressSanitizer: ABRT on unknown address 0x00000000000c (pc 0x7f0a518b3428 bp 0x7fffa463bfd0 sp 0x7fffa463be68 T0)
SCARINESS: 10 (signal)
    #0 0x7f0a518b3428 in raise (/lib/x86_64-linux-gnu/libc.so.6+0x35428)
    #1 0x7f0a518b5029 in abort (/lib/x86_64-linux-gnu/libc.so.6+0x37029)
    #2 0x7f0a52ca635a in log_assert_failed_realm /work/build/../../src/systemd/src/basic/log.c:819:9
    #3 0x4eea92 in config_parse_wireguard_endpoint /work/build/../../src/systemd/src/network/netdev/wireguard.c:808:9
    #4 0x7f0a52b2f74e in next_assignment /work/build/../../src/systemd/src/shared/conf-parser.c:133:32
    #5 0x7f0a52b2954e in parse_line /work/build/../../src/systemd/src/shared/conf-parser.c:242:16
    #6 0x7f0a52b28911 in config_parse /work/build/../../src/systemd/src/shared/conf-parser.c:377:21
    #7 0x7f0a52b29ec6 in config_parse_many_files /work/build/../../src/systemd/src/shared/conf-parser.c:439:21
    #8 0x7f0a52b2a5a6 in config_parse_many /work/build/../../src/systemd/src/shared/conf-parser.c:507:16
    #9 0x4d8d6c in netdev_load_one /work/build/../../src/systemd/src/network/netdev/netdev.c:732:13
    #10 0x4d3e2b in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/network/fuzz-netdev-parser.c:23:16
    #11 0x6b3266 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:558:15
    #12 0x6af860 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:470:3
    #13 0x6b6970 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__1::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/libfuzzer/FuzzerLoop.cpp:770:7
    #14 0x6b7376 in fuzzer::Fuzzer::Loop(std::__1::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/libfuzzer/FuzzerLoop.cpp:799:3
    #15 0x67573f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:846:6
    #16 0x667097 in main /src/libfuzzer/FuzzerMain.cpp:19:10
    #17 0x7f0a5189e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #18 0x4295a8 in _start (out/fuzz-netdev-parser+0x4295a8)

DEDUP_TOKEN: raise--abort--log_assert_failed_realm
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: ABRT (/lib/x86_64-linux-gnu/libc.so.6+0x35428) in raise
==12==ABORTING
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek 44e9342078 netdev/wireguard: do not invalidate peer on invalid syntax
We would say "ignoring", but invalidate the peer anyway.
Let's only do that if we modified the peer irreperably.

Also add comments explaining allocation handling.
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek de7fef4b6e tree-wide: use set_ensure_put()
Patch contains a coccinelle script, but it only works in some cases. Many
parts were converted by hand.

Note: I did not fix errors in return value handing. This will be done separate
to keep the patch comprehensible. No functional change is intended in this
patch.
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek 0f9ccd9552 basic/set: add set_ensure_put()
It's such a common operation to allocate the set and put an item in it,
that it deserves a helper. set_ensure_put() has the same return values
as set_put().

Comes with tests!
2020-06-22 16:32:37 +02:00