Commit Graph

35551 Commits

Author SHA1 Message Date
Lennart Poettering 65f95765d0 tree-wide: various ubsan zero size memory fixes
Fixes: #10346
2018-10-10 12:00:56 +02:00
Zbigniew Jędrzejewski-Szmek c09edc79ab meson: c++ is required for the fuzzer builds
The configuration would fail with an error about cpp being an unknown language
anyway, but it's nicer to fail early and explicitly.

https://github.com/systemd/systemd/pull/10339#issuecomment-428279175
2018-10-10 11:56:45 +02:00
Zbigniew Jędrzejewski-Szmek 9b0ca01903 meson: rename cpp_cmd to cxx_cmd
cpp is a really bad alias for c++ because it's also the name of the
preprocessor. Let's rename the variable.
2018-10-10 11:50:57 +02:00
Lennart Poettering 92a40e20bf sd-bus: call cap_last_cap() only once in has_cap()
Also, use the same type everywhere for dealing with it.
2018-10-10 11:13:00 +02:00
Lennart Poettering 3cae6c21e7 sd-bus: use size_t when dealing with memory offsets 2018-10-10 11:12:22 +02:00
Lennart Poettering 5f00c5684f capability: introduce CAP_TO_MASK_CORRECTED() macro replacing CAP_TO_MASK()
linux/capability.h's CAP_TO_MASK potentially shifts a signed int "1"
(i.e. 32bit wide) left by 31 which means it becomes negative. That's
just weird, and ubsan complains about it. Let's introduce our own macro
CAP_TO_MASK_CORRECTED which doesn't fall into this trap, and make use of
it.

Fixes: #10347
2018-10-10 11:11:48 +02:00
Evgeny Vereshchagin 6315d12bba tests: add a fuzzer for the json parser and dumper 2018-10-10 10:13:30 +02:00
Lennart Poettering 788c34be32 json: add test 2018-10-10 10:13:30 +02:00
Lennart Poettering cd0b6c5390 json: add a nice JSON parser
As preparation for OCI support in nspawn, let's add a JSON parser.

The json.h file contains an explanation why this is new code instead of
just us linking against an existing JSON library.
2018-10-10 10:13:30 +02:00
Asbjørn Apeland ca92fe36e0 man: fix typo 2018-10-10 09:57:57 +02:00
Yu Watanabe 0ae286e697 network: make netlink callbacks return 1
This is not necessary. But most of netlink callbacks in networkd
return 1.
2018-10-10 14:43:05 +09:00
Yu Watanabe c8ee637e7f network: use '_handler' suffix for netlink callbacks 2018-10-10 14:43:05 +09:00
Yu Watanabe c6de4729b1 network: rename ndisc_netlink_handler() to ndisc_route_handler() 2018-10-10 14:43:05 +09:00
Yu Watanabe 26d6b2147e network: drop break line in comment 2018-10-10 14:43:05 +09:00
Yu Watanabe e6bf77744a network: make netlink callback not return negative value
Fixes #10320.
2018-10-10 14:43:05 +09:00
Yu Watanabe e8d1666687 network: drop route_expire_callback() as it is duplicate of link_route_remove_handler() 2018-10-10 14:43:05 +09:00
Yu Watanabe fdb20b7c59 network: make manager_dhcp6_prefix_remove() static 2018-10-10 14:43:05 +09:00
Yu Watanabe 09dd32eea7 network: make netdev_enslave() static 2018-10-10 14:43:05 +09:00
Yu Watanabe 17e57d3cae networkd: drop unused element from AddressLabel struct 2018-10-10 14:43:05 +09:00
Yu Watanabe 9bcb210ebc network: add missing set_free() for Manager.dirty_links 2018-10-10 14:43:05 +09:00
Yu Watanabe 1046bf9b1a network: add destroy callbacks for asynchronous netlink calls 2018-10-10 14:43:05 +09:00
Yu Watanabe 0d0f02cd15 test: add tests for destroy callback of asynchronous netlink call 2018-10-10 14:43:05 +09:00
Yu Watanabe 545bab1f0a sd-netlink: add destroy_callback argument to sd_netlink_call_async() 2018-10-10 14:43:05 +09:00
Yu Watanabe 2fea60901d sd-netlink: use structured initializers 2018-10-10 14:43:05 +09:00
Yu Watanabe f6bdbd9e00 sd-netlink: fix error handling in sd_netlink_call_async() 2018-10-10 14:43:05 +09:00
Lennart Poettering 3316429f19
Merge pull request #10062 from rgushchin/device
Support cgroup v2 bpf-based device controller
2018-10-09 23:29:27 +02:00
Zbigniew Jędrzejewski-Szmek 1b2acaa7a6 meson: we cannot call get_compiler('cpp') if we didn't "add" it
Follow-up for f6d783ac3d.
2018-10-09 21:12:00 +02:00
Lennart Poettering 13711093ef bpf-firewall: always use log_unit_xyz() insteadof log_xyz()
That way it's easier to figure out what the various messages belong to
2018-10-09 21:11:41 +02:00
Lennart Poettering 4cf997befa device: clean up DeviceFound flags set
No need to avoid bit 0. Also the U suffix has no effect, don't use it.
2018-10-09 21:11:22 +02:00
Lennart Poettering 5f616d5feb core: add missing 'continue' statement 2018-10-09 21:11:06 +02:00
Lennart Poettering eb523bfb51 core: include environment generator runtime in generator timestamps
Currently they aren't covered and it probably isn't worth adding another
kind of timestamp just for this, hence simply include it in the regular
generator timestamps.
2018-10-09 19:43:43 +02:00
Lennart Poettering 5ce5e1ad08 core: add a common helper call manager_ready() sharing some common code between manager_reload() and manager_startup()
Just sharing some common code. No functional changes
2018-10-09 19:43:43 +02:00
Lennart Poettering 5197be06e0 core: turn our four vacuum calls into a new helper function
Just share some code. No functional changes.
2018-10-09 19:43:43 +02:00
Lennart Poettering 1fb70e6648 core: rework how we set the objective to MANAGER_OK
Let's do so already when we are about to complete startup/reload, so
that manager_catchup() is run in a context where MANAGER_IS_RUNNING()
returns true, as the intention is.

Fixes: #9518
2018-10-09 19:43:43 +02:00
Lennart Poettering 3ca4d0b3eb core: make use of manager_loop()'s return value
The objective is returned in the return value, let's make use of that,
instead of reaching into the object.
2018-10-09 19:43:43 +02:00
Lennart Poettering 7a35fa24ff core: try to recover from failed reloads
Let's simply continue with everything we loaded, in the hope it's
somewhat useful.
2018-10-09 19:43:43 +02:00
Lennart Poettering 3ad2afb6a2 core: bring manager_startup() and manager_reload() more inline
Both functions do partly the same, let's make sure they do it in the
same order, and that we don't miss some calls.

This makes a number of changes:

1. Moves exec_runtime_vacuum() two calls down in manager_startup(). This
   should not have any effect but makes manager_startup() more like
   manager_reload().

2. Calls manager_recheck_journal(), manager_recheck_dbus(),
   manager_enqueue_sync_bus_names() in manager_startup() too. This is a
   good idea since during reeexec we pass through manager_startup() and
   hence can't assume dbus and journald weren't up yet, hence let's
   check if they are ready to be connected to.

3. Include manager_enumerate_perpetual() in manager_reload(), too. This
   is not strictly necessary, since these units are included in the
   serialization anyway, but it's still a nice thing, in particular as
   theoretically the deserialization could fail.
2018-10-09 19:43:43 +02:00
Lennart Poettering 6eb3af7a6e core: break lines in comments 2018-10-09 19:43:43 +02:00
Lennart Poettering 572986ca14 core: log in all cases in manager_startup()
We missed some cases where we'd fail without any logging at all. Let's
fix that.
2018-10-09 19:43:43 +02:00
Lennart Poettering 6a33af40da manager: rework error handling and logging in manager_reload()
let's clean up error handling and logging in manager_reload() a bit.
Specifically: make sure we log about every error we might encounter at
least and at most once.

When we encounter an error before the "point of no return" then log at
LOG_ERR about it and propagate it. Otherwise, eat it up, but warn about
it and proceed, it's the best we can do.
2018-10-09 19:43:43 +02:00
Lennart Poettering eb10d0bf8a core: add comments about n_reloading to manager_deserialize() 2018-10-09 19:43:43 +02:00
Lennart Poettering 18869883f2 core: handle OOM during deserialization always the same way
OOM failures we consider fatal, while other failures we generally skip
over.
2018-10-09 19:43:43 +02:00
Lennart Poettering b2a8a3dd10 core: clean up deserialization log messages a bit
Always, say that we ignore these kind of issues. We already say that for
many fields, but for a few this was missing.
2018-10-09 19:43:43 +02:00
Lennart Poettering 7eb4f32612 core: make sure manager_run_generators() logs about all errors
Since it's mostly a wrapper around execute_directories() it already logs
in most cases, but a few were missing. Fix that.
2018-10-09 19:43:43 +02:00
Lennart Poettering 4daf832afa core: allow manager_serialize() to fail correctly
If manager_serialize() fails in the middle (which it hopefully doesn't)
make sure to fix up m->n_reloading correctly again so that we don't
leave it > 0 when it really shouldn't be.
2018-10-09 19:43:43 +02:00
Lennart Poettering fc37d875a1 path-lookup: downgrade logging in lookup_paths_init() a bit
So far lookup_paths_init() did not log on its own beyond LOG_DEBUG,
fix one exception, in order to avoid duplicate logging.
2018-10-09 19:43:43 +02:00
Lennart Poettering 638cece45d core: clean up test run flags
Let's make them typesafe, and let's add a nice macro helper for checking
if we are in a test run, which should make testing for this much easier
to read for most cases.
2018-10-09 19:43:43 +02:00
Lennart Poettering c52b19d65f manager: normalize /run disk space checks
Let's avoid using a variable needlessly. More importantly, special case
the error, not the regular case.
2018-10-09 19:43:43 +02:00
Lennart Poettering 86036b26a1 core: tiny tweak for cgroup trimming during manager_free()
Instead of blacklisting when not to trim the cgroup tree, let's instead
whitelist when to do it, as an excercise of being careful when being
destructive.

This should not change behaviour with exception that during switch roots
we now won't attempt to trim the cgroup tree anymore. Which is more
correct behaviour after all we serialize/deserialize during the
transition and should be needlessly destructive.
2018-10-09 19:43:43 +02:00
Lennart Poettering 3ad228ce75 core: use structure initialization for Manager
No changes in behaviour, just a nicer way to fill in the Manager
initially.
2018-10-09 19:43:43 +02:00