systemd/.git
6 years agobus-message: use define
Zbigniew Jędrzejewski-Szmek [Tue, 24 Jul 2018 19:24:53 +0000 (21:24 +0200)]
bus-message: use define

(cherry picked from commit f22c308aff556bf5c6599ffcb61e637e366ab232)

Resolves: #1696224

6 years agobus-message: rename function for clarity
Zbigniew Jędrzejewski-Szmek [Tue, 24 Jul 2018 18:14:39 +0000 (20:14 +0200)]
bus-message: rename function for clarity

There's already message_free_last_container(), so rename to match.

(cherry picked from commit 9c65778d614588d21645163dea97a5fe2c1c4ca5)

Resolves: #1696224

6 years agobus-message: let's always use -EBADMSG when the message is bad
Zbigniew Jędrzejewski-Szmek [Mon, 9 Jul 2018 09:12:33 +0000 (11:12 +0200)]
bus-message: let's always use -EBADMSG when the message is bad

-EINVAL means the arguments were somehow wrong, so translate the code we get
internally into -EBADMSG when returning.

(cherry picked from commit 69bd42ca072dfb2f7603b1f82053063293ab54b5)

Resolves: #1696224

6 years agobus-message: avoid an infinite loop on empty structures
Zbigniew Jędrzejewski-Szmek [Mon, 9 Jul 2018 08:52:51 +0000 (10:52 +0200)]
bus-message: avoid an infinite loop on empty structures

The alternative would be to treat gvariant and !gvariant messages differently.
But this is a problem because we check signatures is variuos places before we
have an actual message, for example in sd_bus_add_object_vtable(). It seems
better to treat things consistent (i.e. follow the lowest common denominator)
and disallow empty structures everywhere.

(cherry picked from commit ec6bda56cbca9509b1abde1122645630caca877c)

Resolves: #1696224

6 years agobus-message: use structured initialization to avoid use of unitialized memory
Zbigniew Jędrzejewski-Szmek [Mon, 9 Jul 2018 05:38:10 +0000 (07:38 +0200)]
bus-message: use structured initialization to avoid use of unitialized memory

As far as I can see, we would either reuse some values from a previously exited
container or just random bytes from the heap.

Should fix #10127.

(cherry picked from commit cf81c68e96aa29d0c28b5d3a26d1de9aa1b53b85)

Resolves: #1696224

6 years agofuzz-bus-message: add fuzzer for message parsing
Zbigniew Jędrzejewski-Szmek [Sat, 7 Jul 2018 17:30:25 +0000 (19:30 +0200)]
fuzz-bus-message: add fuzzer for message parsing

As with other fuzzers, SYSTEMD_FUZZ_OUTPUT=1 and SYSTEMD_LOG_LEVEL=debug can be
used for debugging.

(cherry picked from commit 56b560c26339c4b282c06038316a91509eae75fd)

Resolves: #1696224

6 years agomeson: treat all fuzz cases as unit tests
Zbigniew Jędrzejewski-Szmek [Fri, 10 Aug 2018 15:15:05 +0000 (17:15 +0200)]
meson: treat all fuzz cases as unit tests

318/365 fuzz-bus-message:crash-26bba7182dedc8848939931d9fcefcb7922f2e56:address  OK       0.03 s
319/365 fuzz-bus-message:crash-29ed3c202e0ffade3cad42c8bbeb6cc68a21eb8e:address  OK       0.03 s
320/365 fuzz-bus-message:crash-b88ad9ecf4aacf4a0caca5b5543953265367f084:address  OK       0.03 s
321/365 fuzz-bus-message:crash-c1b37b4729b42c0c05b23cba4eed5d8102498a1e:address  OK       0.03 s
322/365 fuzz-bus-message:crash-d8f3941c74219b4c03532c9b244d5ea539c61af5:address  OK       0.03 s
323/365 fuzz-bus-message:crash-e1b811da5ca494e494b77c6bd8e1c2f2989425c5:address  OK       0.03 s
324/365 fuzz-bus-message:leak-c09c0e2256d43bc5e2d02748c8d8760e7bc25d20:address  OK       0.04 s
325/365 fuzz-bus-message:message1:address       OK       0.03 s
326/365 fuzz-bus-message:timeout-08ee8f6446a4064db064e8e0b3d220147f7d0b5b:address  OK       0.03 s
327/365 fuzz-dhcp-server:discover-existing:address  OK       0.04 s
328/365 fuzz-dhcp-server:discover-new:address   OK       0.03 s
329/365 fuzz-dhcp-server:release:address        OK       0.04 s
330/365 fuzz-dhcp-server:request-existing:address  OK       0.03 s
331/365 fuzz-dhcp-server:request-new:address    OK       0.03 s
332/365 fuzz-dhcp-server:request-reboot:address  OK       0.03 s
333/365 fuzz-dhcp-server:request-renew:address  OK       0.03 s
334/365 fuzz-dns-packet:issue-7888:address      OK       0.03 s
335/365 fuzz-dns-packet:oss-fuzz-5465:address   OK       0.03 s
336/365 fuzz-journal-remote:crash-5a8f03d4c3a46fcded39527084f437e8e4b54b76:address  OK       0.06 s
337/365 fuzz-journal-remote:crash-96dee870ea66d03e89ac321eee28ea63a9b9aa45:address  OK       0.04 s
338/365 fuzz-journal-remote:invalid-ts.txt:address  OK       0.04 s
339/365 fuzz-journal-remote:oss-fuzz-8659:address  OK       0.06 s
340/365 fuzz-journal-remote:oss-fuzz-8686:address  OK       0.04 s
341/365 fuzz-journal-remote:sample.txt:address  OK       0.07 s
342/365 fuzz-unit-file:directives.service:address  OK       0.03 s
343/365 fuzz-unit-file:empty.scope:address      OK       0.04 s
344/365 fuzz-unit-file:machine.slice:address    OK       0.03 s
345/365 fuzz-unit-file:oss-fuzz-6884:address    OK       0.05 s
346/365 fuzz-unit-file:oss-fuzz-6885:address    OK       0.03 s
347/365 fuzz-unit-file:oss-fuzz-6886:address    OK       0.04 s
348/365 fuzz-unit-file:oss-fuzz-6892:address    OK       0.03 s
349/365 fuzz-unit-file:oss-fuzz-6897:address    OK       0.05 s
350/365 fuzz-unit-file:oss-fuzz-6897-evverx:address  OK       0.04 s
351/365 fuzz-unit-file:oss-fuzz-6908:address    OK       0.05 s
352/365 fuzz-unit-file:oss-fuzz-6917:address    OK       0.06 s
353/365 fuzz-unit-file:oss-fuzz-6977:address    OK       0.08 s
354/365 fuzz-unit-file:oss-fuzz-6977-unminimized:address  OK       0.10 s
355/365 fuzz-unit-file:oss-fuzz-7004:address    OK       0.03 s
356/365 fuzz-unit-file:oss-fuzz-8064:address    OK       0.03 s
357/365 fuzz-unit-file:oss-fuzz-8827:address    OK       0.50 s
358/365 fuzz-unit-file:proc-sys-fs-binfmt_misc.automount:address  OK       0.03 s
359/365 fuzz-unit-file:syslog.socket:address    OK       0.03 s
360/365 fuzz-unit-file:systemd-ask-password-console.path:address  OK       0.03 s
361/365 fuzz-unit-file:systemd-machined.service:address  OK       0.03 s
362/365 fuzz-unit-file:systemd-resolved.service:address  OK       0.03 s
363/365 fuzz-unit-file:systemd-tmpfiles-clean.timer:address  OK       0.03 s
364/365 fuzz-unit-file:timers.target:address    OK       0.03 s
365/365 fuzz-unit-file:var-lib-machines.mount:address  OK       0.04 s

This gives us slightly nicer coverage in the normal test run.

When in a git repo, git ls-files is used to get a list of files known to git.
This mirrors what update-man-rules does for man files. Only looking at files
known to git makes it easier to not forget to commit the test file to git,
and also makes bisecting easier if some files are left in repo.

When outside of a git repo, we expect to be unpacked from a tarball, so just
using all files reported by ls is OK.

(cherry picked from commit e6bad6746151c79a5f408e95714ffa5cea290ab0)

Resolves: #1696224

6 years agomeson: use .source_root() in more places
Zbigniew Jędrzejewski-Szmek [Fri, 10 Aug 2018 14:50:07 +0000 (16:50 +0200)]
meson: use .source_root() in more places

In the main meson.build file, .source_root() and .current_source_dir() are
equivalent, but it seems more appropriate to use .source_root() when we are appending
a path which is by design relative to repo root.

(cherry picked from commit 243e5cecc3a211519544ccba01c44edc827ac517)

Resolves: #1696224

6 years agomeson: drop duplicated condition
Zbigniew Jędrzejewski-Szmek [Tue, 7 Aug 2018 16:10:53 +0000 (18:10 +0200)]
meson: drop duplicated condition

The generic check suffices for those four.

(cherry picked from commit 6bd2bc8e16a6d515f8a21c47fd6b833d7fcfdd1c)

Resolves: #1696224

6 years agomeson: allow building resolved and machined without nss modules
Yu Watanabe [Wed, 18 Jul 2018 00:25:57 +0000 (09:25 +0900)]
meson: allow building resolved and machined without nss modules

This adds -Dnss-resolve= and -Dnss-mymachines= meson options.
By using this option, e.g., resolved can be built without nss-resolve.
When no nss modules are built, then test-nss is neither built.

Also, This changes the option name -Dmyhostname= to -Dnss-myhostname=
for consistency to other nss related options.

Closes #9596.

(cherry picked from commit 08540a9591efe105439be81fc43d6dc65b715978)

Resolves: #1696224

6 years agomeson: add -Dlog-trace to set LOG_TRACE
Zbigniew Jędrzejewski-Szmek [Tue, 7 Aug 2018 15:34:47 +0000 (17:34 +0200)]
meson: add -Dlog-trace to set LOG_TRACE

The justification is the same as for -Dvalgrind: setting config in
meson in this way is easier, because when the value is changed stuff
that should be rebuilt is rebuilt.

(cherry picked from commit fd5dec9adf76591d713f163d43d04e3beb76893e)

Resolves: #1696224

6 years agotest-bus-marshal: use cescaping instead of hexmem
Zbigniew Jędrzejewski-Szmek [Sat, 7 Jul 2018 17:08:52 +0000 (19:08 +0200)]
test-bus-marshal: use cescaping instead of hexmem

It is easier to see the contents this way by eye.

(cherry picked from commit 3ddf3d439463ab2c76391a4d22b54166be2dbe94)

Resolves: #1696224

6 years agofuzz: unify the "fuzz-regressions" directory with the main corpus
Zbigniew Jędrzejewski-Szmek [Sat, 7 Jul 2018 16:09:21 +0000 (18:09 +0200)]
fuzz: unify the "fuzz-regressions" directory with the main corpus

There isn't really much need to keep them separate. Anything which is a good
corpus entry can be used as a smoke test, and anything which which is a
regression test can just as well be inserted into the corpus.

The only functional difference from this patch (apart from different paths in
output) is that the regression tests are now zipped together with the rest of
the corpus.

$ meson configure build -Dslow-tests=true && ninja -C build test
...
307/325 fuzz-dns-packet:issue-7888:address      OK       0.06 s
308/325 fuzz-dns-packet:oss-fuzz-5465:address   OK       0.04 s
309/325 fuzz-journal-remote:crash-5a8f03d4c3a46fcded39527084f437e8e4b54b76:address  OK       0.07 s
310/325 fuzz-journal-remote:crash-96dee870ea66d03e89ac321eee28ea63a9b9aa45:address  OK       0.05 s
311/325 fuzz-journal-remote:oss-fuzz-8659:address  OK       0.05 s
312/325 fuzz-journal-remote:oss-fuzz-8686:address  OK       0.07 s
313/325 fuzz-unit-file:oss-fuzz-6884:address    OK       0.06 s
314/325 fuzz-unit-file:oss-fuzz-6885:address    OK       0.05 s
315/325 fuzz-unit-file:oss-fuzz-6886:address    OK       0.05 s
316/325 fuzz-unit-file:oss-fuzz-6892:address    OK       0.05 s
317/325 fuzz-unit-file:oss-fuzz-6897:address    OK       0.05 s
318/325 fuzz-unit-file:oss-fuzz-6897-evverx:address  OK       0.06 s
319/325 fuzz-unit-file:oss-fuzz-6908:address    OK       0.07 s
320/325 fuzz-unit-file:oss-fuzz-6917:address    OK       0.07 s
321/325 fuzz-unit-file:oss-fuzz-6977:address    OK       0.13 s
322/325 fuzz-unit-file:oss-fuzz-6977-unminimized:address  OK       0.12 s
323/325 fuzz-unit-file:oss-fuzz-7004:address    OK       0.05 s
324/325 fuzz-unit-file:oss-fuzz-8064:address    OK       0.05 s
325/325 fuzz-unit-file:oss-fuzz-8827:address    OK       0.52 s

(cherry picked from commit c74a3f973e3e0bac13d66a28728a47f10046b71f)

Resolves: #1696224

6 years agotest: add testcase for issue 10007 by oss-fuzz
Yu Watanabe [Wed, 22 Aug 2018 03:39:40 +0000 (12:39 +0900)]
test: add testcase for issue 10007 by oss-fuzz

(cherry picked from commit a1a605f144e5635fdae57125a92032b3e5ebeca9)

Resolves: #1696224

6 years agofuzz: rename "fuzz-corpus" directory to just "fuzz"
Zbigniew Jędrzejewski-Szmek [Sat, 7 Jul 2018 15:43:40 +0000 (17:43 +0200)]
fuzz: rename "fuzz-corpus" directory to just "fuzz"

Also, all corpus subdirectories are named exactly the same as the fuzzer they
are for. This makes the paths a bit longer, but easier.

(cherry picked from commit 93b575b26605c347a717b2aa24ddf9cad08b8080)

Resolves: #1696224

6 years agotests: add a reproducer for another infinite loop in ndisc_handle_datagram
Evgeny Vereshchagin [Wed, 26 Sep 2018 18:09:09 +0000 (18:09 +0000)]
tests: add a reproducer for another infinite loop in ndisc_handle_datagram

(cherry picked from commit bbb393877b2cfcbe2f205c902ca7d9f7ce91f1a1)

Resolves: #1696224

6 years agotests: add a reproducer for an infinite loop in ndisc_handle_datagram
Evgeny Vereshchagin [Wed, 26 Sep 2018 15:10:21 +0000 (15:10 +0000)]
tests: add a reproducer for an infinite loop in ndisc_handle_datagram

=0  ndisc_router_parse (rt=0x60d000000110) at ../src/libsystemd-network/ndisc-router.c:126
=1  0x000055555558dc67 in ndisc_handle_datagram (nd=0x608000000020, rt=0x60d000000110) at ../src/libsystemd-network/sd-ndisc.c:170
=2  0x000055555558e65d in ndisc_recv (s=0x611000000040, fd=4, revents=1, userdata=0x608000000020) at ../src/libsystemd-network/sd-ndisc.c:233
=3  0x00007ffff63913a8 in source_dispatch (s=0x611000000040) at ../src/libsystemd/sd-event/sd-event.c:3042
=4  0x00007ffff6395eab in sd_event_dispatch (e=0x617000000080) at ../src/libsystemd/sd-event/sd-event.c:3455
=5  0x00007ffff6396b12 in sd_event_run (e=0x617000000080, timeout=18446744073709551615) at ../src/libsystemd/sd-event/sd-event.c:3512
=6  0x0000555555583f5c in LLVMFuzzerTestOneInput (data=0x6060000000e0 "\206", size=53) at ../src/fuzz/fuzz-ndisc-rs.c:422
=7  0x0000555555586356 in main (argc=2, argv=0x7fffffffe3d8) at ../src/fuzz/fuzz-main.c:33

(cherry picked from commit df30e78e02f653c9e6ee6677b7ccaea21d3dcd7d)

Resolves: #1696224

6 years agotests: add reproducers for several issues uncovered with fuzz-journald-syslog
Evgeny Vereshchagin [Sun, 2 Sep 2018 18:13:31 +0000 (18:13 +0000)]
tests: add reproducers for several issues uncovered with fuzz-journald-syslog

This is a follow-up to a70f343cacf03ac51cdefb0d2e.

(cherry picked from commit 3311c74d0560e4aa6a223f5e288a5fbf2404d3fa)

Resolves: #1696224

6 years agondisc: fix two infinite loops
Yu Watanabe [Fri, 28 Sep 2018 10:28:05 +0000 (19:28 +0900)]
ndisc: fix two infinite loops

(cherry picked from commit f3241c61f12dbd8f0ed37419ae272e291d09461d)

Resolves: #1696224

6 years agotests: add a fuzzer for sd-ndisc
Evgeny Vereshchagin [Wed, 26 Sep 2018 15:04:26 +0000 (15:04 +0000)]
tests: add a fuzzer for sd-ndisc

(cherry picked from commit 0f0a1dad7d69802a7e6c7fc9aba350f0e87c1952)

Resolves: #1696224

6 years agotests: add a fuzzer for server_process_native_message
Evgeny Vereshchagin [Mon, 3 Sep 2018 07:05:48 +0000 (07:05 +0000)]
tests: add a fuzzer for server_process_native_message

(cherry picked from commit 9cdea02db57a36442ad9e9afcd67760ca319173a)

Resolves: #1696224

6 years agojournald: make server_process_native_message compatible with fuzz_journald_processing...
Evgeny Vereshchagin [Mon, 3 Sep 2018 07:03:10 +0000 (07:03 +0000)]
journald: make server_process_native_message compatible with fuzz_journald_processing_function

(cherry picked from commit 21acb27b71f6284a57e4e9f3ac5f0d38721ef4eb)

Resolves: #1696224

6 years agotests: rework the code fuzzing journald
Evgeny Vereshchagin [Mon, 3 Sep 2018 06:46:24 +0000 (06:46 +0000)]
tests: rework the code fuzzing journald

This should make it easier to add a new fuzzer without a lot of
duplication.

(cherry picked from commit b1bd453f36b9428b6bf9feba31fa0a2b36143e9c)

Resolves: #1696224

6 years agojournald: free the allocated memory before returning from dev_kmsg_record
Evgeny Vereshchagin [Fri, 10 Aug 2018 12:52:07 +0000 (12:52 +0000)]
journald: free the allocated memory before returning from dev_kmsg_record

This fixes a minor memory leak.

(cherry picked from commit 30eddcd51b8a472e05d3b8d1f0b89fbd3e094d71)

Resolves: #1696224

6 years agojournald: make it clear that dev_kmsg_record modifies the string passed to it
Evgeny Vereshchagin [Fri, 10 Aug 2018 12:45:42 +0000 (12:45 +0000)]
journald: make it clear that dev_kmsg_record modifies the string passed to it

The function replaces a couple commas, a semicolon and the final newline with
zero bytes in the string passed to it. The 'const' seems to have been added
by accident during a bulk edit (more specifically 3b3154df7e2773332bb814).

(cherry picked from commit 1e0c5fc2a76e4f3d508331f410899c50493e1fc9)

Resolves: #1696224

6 years agotests: add a rudimentary fuzzer for server_process_syslog_message (#9979)
Evgeny Vereshchagin [Mon, 3 Sep 2018 03:18:26 +0000 (06:18 +0300)]
tests: add a rudimentary fuzzer for server_process_syslog_message (#9979)

(cherry picked from commit a70f343cacf03ac51cdefb0d2e7651b04fd2e23a)

Resolves: #1696224

6 years agoanalyze: add new security verb
Lennart Poettering [Thu, 8 Nov 2018 08:32:17 +0000 (09:32 +0100)]
analyze: add new security verb

(cherry picked from commit ec16f3b6dd8b03e3ce6eff1fa9f21432208ef42b)

Conflicts:
src/analyze/analyze.c

Resolves: #1689832

6 years agolocale-util: add logic to output smiley emojis at various happiness levels
Lennart Poettering [Tue, 6 Nov 2018 16:59:58 +0000 (17:59 +0100)]
locale-util: add logic to output smiley emojis at various happiness levels

(cherry picked from commit 5f1b0cc6d064f7847982e7b680cab3d080aef52e)

Conflicts:
doc/ENVIRONMENT.md
src/basic/locale-util.c
src/basic/locale-util.h
src/test/test-locale-util.c

Related: #1689832

6 years agoformat-table: never try to reuse cells that have color/url/uppercase set
Lennart Poettering [Mon, 3 Dec 2018 20:39:39 +0000 (21:39 +0100)]
format-table: never try to reuse cells that have color/url/uppercase set

The table cell reusing code is supposed to be an internal memory
optimization, and not more. This means behaviour should be the same as
if we wouldn't reuse cells.

(cherry picked from commit 94a80afed42a8b36d69a229bf44ba690f8f59a78)

Related: #1689832

6 years agoformat-table: add option to uppercase cells on display
Lennart Poettering [Mon, 3 Dec 2018 20:36:26 +0000 (21:36 +0100)]
format-table: add option to uppercase cells on display

This adds a per-cell option for uppercasing displayed strings.
Implicitly turn this on for the header row. The fact that we format the
table header in uppercase is a formatting thing after all, hence should
be applied by the formatter, i.e. the table display code.

Moreover, this provides us with the benefit that we can more nicely
reuse the specified table headers as JSON field names, like we already
do: json field names are usually not uppercase.

(cherry picked from commit 359abf6dd05aa6bca3438e9c969ed904bd3d447d)

Related: #1689832

6 years agoformat-table: use right field for display
Lennart Poettering [Mon, 3 Dec 2018 19:28:15 +0000 (20:28 +0100)]
format-table: use right field for display

Since .timespan and .timestamp are unionized on top of each other this
doesn't actually matter, but it is still more correct to address it
under it's correct name.

(cherry picked from commit c93d372d7ceda0b080487fa35d3638ef3d8507cb)

Related: #1689832

6 years agoformat-table: make sure we never call memcmp() with NULL parameters
Lennart Poettering [Wed, 14 Nov 2018 17:39:37 +0000 (18:39 +0100)]
format-table: make sure we never call memcmp() with NULL parameters

(cherry picked from commit 88db94fa57c9a5b1a0b926c49d3624fc84c88090)

Related: #1689832

6 years agoformat-table: add calls to query the data in a specific cell
Lennart Poettering [Fri, 9 Nov 2018 10:38:12 +0000 (11:38 +0100)]
format-table: add calls to query the data in a specific cell

(cherry picked from commit 62d99b39709f903f8a66a9aae757deb5546a53eb)

Related: #1689832

6 years agoformat-table: always underline header line
Lennart Poettering [Thu, 8 Nov 2018 20:39:28 +0000 (21:39 +0100)]
format-table: always underline header line

(cherry picked from commit 30d98de00c68440ff4d77d851b4b3323c34027da)

Related: #1689832

6 years agoformat-table: add an API for getting the cell at a specific row/column
Lennart Poettering [Thu, 8 Nov 2018 20:21:09 +0000 (21:21 +0100)]
format-table: add an API for getting the cell at a specific row/column

(cherry picked from commit 9314ead7853a1479fc60eb2ae7e3d0a77b7eba7c)

Related: #1689832

6 years agoformat-table: add table_update() to update existing entries
Lennart Poettering [Thu, 8 Nov 2018 20:17:47 +0000 (21:17 +0100)]
format-table: add table_update() to update existing entries

(cherry picked from commit 27e730e6d0a7709c17ccef170f10846e92dca2a0)

Related: #1689832

6 years agoformat-table: optionally allow reversing the sort order for a column
Lennart Poettering [Wed, 7 Nov 2018 16:41:32 +0000 (17:41 +0100)]
format-table: optionally allow reversing the sort order for a column

(cherry picked from commit a2c73e2d3823e878de7a7ee193631108c5fc5be0)

Related: #1689832

6 years agoformat-table: add option to store/format percent and uint64_t values in cells
Lennart Poettering [Wed, 7 Nov 2018 14:25:51 +0000 (15:25 +0100)]
format-table: add option to store/format percent and uint64_t values in cells

(cherry picked from commit a4661181fa702a8bff4644210ba7ea14bea51a4a)

Related: #1689832

6 years agoformat-table: before outputting a color, check if colors are available
Lennart Poettering [Tue, 6 Nov 2018 17:37:21 +0000 (18:37 +0100)]
format-table: before outputting a color, check if colors are available

This is in many cases redundant, as a similar check is done by various
callers already, but in other cases (where we read the color from a
static table for example), it's nice to let the color check be done by
the table code itself, and since it doesn't hurt in the other cases just
do it again.

(cherry picked from commit a22318e55492af721879d8692ed039144696bb08)

Related: #1689832

6 years agoformat-table: optionally make specific cells clickable links
Lennart Poettering [Tue, 6 Nov 2018 11:06:14 +0000 (12:06 +0100)]
format-table: optionally make specific cells clickable links

(cherry picked from commit 165ca5663e9859083c70d793a6b4aa4f3b2af24c)

Related: #1689832

6 years agoformat-table: when duplicating a cell, also copy the color
Lennart Poettering [Thu, 8 Nov 2018 20:16:23 +0000 (21:16 +0100)]
format-table: when duplicating a cell, also copy the color

(cherry picked from commit 13b0d4d7bdb674d0e51a6d595abd1e7bf2691bf9)

Related: #1689832

6 years agoseccomp: reduce logging about failure to add syscall to seccomp
Zbigniew Jędrzejewski-Szmek [Mon, 24 Sep 2018 14:59:12 +0000 (16:59 +0200)]
seccomp: reduce logging about failure to add syscall to seccomp

Our logs are full of:
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldstat() / -10037, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call get_thread_area() / -10076, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call set_thread_area() / -10079, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldfstat() / -10034, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldolduname() / -10036, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldlstat() / -10035, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call waitpid() / -10073, ignoring: Numerical argument out of domain
...
This is pointless and makes debug logs hard to read. Let's keep the logs
in test code, but disable it in nspawn and pid1. This is done through a function
parameter because those functions operate recursively and it's not possible to
make the caller to log meaningfully.

There should be no functional change, except the skipped debug logs.

(cherry-picked from commit b54f36c604472ffe08830ec4306fa2885b4a5424)

Resolves: #1658691

6 years agonss: unportect errno before writing to NSS' *errnop
Lennart Poettering [Fri, 18 Jan 2019 19:13:55 +0000 (20:13 +0100)]
nss: unportect errno before writing to NSS' *errnop

Fixes: #11321
(cherry picked from commit cdccd29f39cd20cb2a8b71e50445eb839f076331)

Resolves: #1691691

6 years agoutil.h: add new UNPROTECT_ERRNO macro
Lennart Poettering [Fri, 18 Jan 2019 19:04:13 +0000 (20:04 +0100)]
util.h: add new UNPROTECT_ERRNO macro

THis is inspired by #11395, but much simpler.

(cherry picked from commit 840f606d88fef2f5d240b2d759ce7b951354d5bb)

Resolves: #1691691

6 years agonss: do not modify errno when NSS_STATUS_NOTFOUND or NSS_STATUS_SUCCESS
Yu Watanabe [Sun, 15 Jul 2018 14:00:00 +0000 (23:00 +0900)]
nss: do not modify errno when NSS_STATUS_NOTFOUND or NSS_STATUS_SUCCESS

This also adds PROTECT_ERRNO for all nss module functions.

C.f. glibc NSS documents https://www.gnu.org/software/libc/manual/html_node/NSS-Modules-Interface.html
and discussion in https://sourceware.org/bugzilla/show_bug.cgi?id=23410.

Fixes #9585.

(cherry picked from commit 06202b9e659e5cc72aeecc5200155b7c012fccbc)

Resolves: #1691691

6 years agounits: add [Install] section to tmp.mount
Jan Synacek [Tue, 22 Jan 2019 09:28:42 +0000 (10:28 +0100)]
units: add [Install] section to tmp.mount

rhel-only

Resolves: #1667065

6 years agologs-show: use grey color for de-emphasizing journal log output
Lennart Poettering [Wed, 5 Dec 2018 17:42:32 +0000 (18:42 +0100)]
logs-show: use grey color for de-emphasizing journal log output

(cherry picked from commit 67df9b7a06d749fdd84f19f7d75ccf0d743f6d72)

Resolves: #1695601

6 years agojournal: don't enable systemd-journald-audit.socket by default
Jan Synacek [Thu, 2 May 2019 12:11:54 +0000 (14:11 +0200)]
journal: don't enable systemd-journald-audit.socket by default

Resolves: #1699287

6 years agoRevert "journal: remove journal audit socket"
Jan Synacek [Thu, 2 May 2019 12:08:39 +0000 (14:08 +0200)]
Revert "journal: remove journal audit socket"

This reverts commit 8618ef2fb30b4139c9bec4e45fb499cd8192a87f.

Resolves: #1699287

6 years agounit: enqueue cgroup empty check event if the last ref on a unit is dropped
Lennart Poettering [Fri, 5 Oct 2018 21:04:51 +0000 (23:04 +0200)]
unit: enqueue cgroup empty check event if the last ref on a unit is dropped

(cherry picked from commit e5c36295d81971ef75d9c6f98f0890b92a4a353f)

Resolves: #1697893

6 years agonspawn: rework how we allocate/kill scopes
Lennart Poettering [Fri, 5 Oct 2018 20:56:40 +0000 (22:56 +0200)]
nspawn: rework how we allocate/kill scopes

Fixes: #6347
(cherry picked from commit 1d78fea2d6230e0aafa2603abc8f1f51966ef134)

Resolves: #1697893

6 years agonspawn: merge two variable declaration lines
Lennart Poettering [Fri, 5 Oct 2018 20:56:20 +0000 (22:56 +0200)]
nspawn: merge two variable declaration lines

(cherry picked from commit df61bc5e4aa19f9b211dbe8414343b44361e442c)

Resolves: #1697893

6 years agonspawn: simplify machine terminate bus call
Lennart Poettering [Fri, 5 Oct 2018 20:54:57 +0000 (22:54 +0200)]
nspawn: simplify machine terminate bus call

We have the machine name anyway, let's use TerminateMachine() on
machined's Manager object directly with it. That way it's a single
method call only, instead of two, to terminate the machine.

(cherry picked from commit 11d81e506ed68c6c5cebe319dc57a9a2fc4319c5)

Resolves: #1697893

6 years agotree-wide: shorten error logging a bit
Yu Watanabe [Tue, 7 Aug 2018 01:14:30 +0000 (10:14 +0900)]
tree-wide: shorten error logging a bit

Continuation of 4027f96aa08c73f109aa46b89842ca0e25c9c0e9.

(cherry picked from commit 4ae25393f37b96b2b753562a349d68947ab1ad3d)

Resolves: #1697893

6 years agoRevert "core: one step back again, for nspawn we actually can't wait for cgroups... v239-14
Lukas Nykryn [Thu, 25 Jun 2015 07:20:59 +0000 (09:20 +0200)]
Revert "core: one step back again, for nspawn we actually can't wait for cgroups running empty since systemd will get exactly zero notifications about it"

This reverts commit 743970d2ea6d08aa7c7bff8220f6b7702f2b1db7.

RHEL-only
https://bugzilla.redhat.com/show_bug.cgi?id=1141137
https://github.com/systemd/systemd/pull/350

Resolves: #1703485

6 years agomeson: drop misplaced -Wl,--undefined argument
Jussi Pakkanen [Sat, 6 Apr 2019 19:59:06 +0000 (21:59 +0200)]
meson: drop misplaced -Wl,--undefined argument

Ld's man page says the following:

  -u symbol
  --undefined=symbol

  Force symbol to be entered in the output file as an undefined symbol. Doing
  this may, for example, trigger linking of additional modules from standard
  libraries. -u may be repeated with different option arguments to enter
  additional undefined symbols. This option is equivalent to the "EXTERN"
  linker script command.

  If this option is being used to force additional modules to be pulled into
  the link, and if it is an error for the symbol to remain undefined, then the
  option --require-defined should be used instead.

This would imply that it always requires an argument, which this does not
pass. Thus it will grab the next argument on the command line as its
argument. Before it took one of the many -lrt args (presumably) and now it
grabs something other random linker argument and things break.

[zj: this line was added in the first version of the meson configuration back
in 5c23128daba7236a6080383b2a5649033cfef85c. AFAICT, this was a mistake. No
such flag appeared in Makefile.am at the time.]

https://github.com/mesonbuild/meson/issues/5113
(cherry picked from commit 700805f6c546f2adb79059614f3747f7b5474325)

6 years agosd-bus: if we receive an invalid dbus message, ignore and proceeed
Lennart Poettering [Wed, 13 Feb 2019 15:51:22 +0000 (16:51 +0100)]
sd-bus: if we receive an invalid dbus message, ignore and proceeed

dbus-daemon might have a slightly different idea of what a valid msg is
than us (for example regarding valid msg and field sizes). Let's hence
try to proceed if we can and thus drop messages rather than fail the
connection if we fail to validate a message.

Hopefully the differences in what is considered valid are not visible
for real-life usecases, but are specific to exploit attempts only.

(cherry-picked from commit 6d586a13717ae057aa1b4127400c3de61cd5b9e7)

Related: #1678641

6 years agoAllocate temporary strings to hold dbus paths on the heap
Riccardo Schirone [Mon, 4 Feb 2019 13:29:28 +0000 (14:29 +0100)]
Allocate temporary strings to hold dbus paths on the heap

Paths are limited to BUS_PATH_SIZE_MAX but the maximum size is anyway too big
to be allocated on the stack, so let's switch to the heap where there is a
clear way to understand if the allocation fails.

(cherry-picked from commit f519a19bcd5afe674a9b8fc462cd77d8bad403c1)

Related: #1678641

6 years agoRefuse dbus message paths longer than BUS_PATH_SIZE_MAX limit.
Riccardo Schirone [Mon, 4 Feb 2019 13:29:09 +0000 (14:29 +0100)]
Refuse dbus message paths longer than BUS_PATH_SIZE_MAX limit.

Even though the dbus specification does not enforce any length limit on the
path of a dbus message, having to analyze too long strings in PID1 may be
time-consuming and it may have security impacts.

In any case, the limit is set so high that real-life applications should not
have a problem with it.

(cherry-picked from commit 61397a60d98e368a5720b37e83f3169e3eb511c4)

Related: #1678641

6 years agobus-socket: Fix line_begins() to accept word matching full string
Filipe Brandenburger [Tue, 17 Jul 2018 18:32:40 +0000 (11:32 -0700)]
bus-socket: Fix line_begins() to accept word matching full string

The switch to memory_startswith() changed the logic to only look for a space or
NUL byte after the matched word, but matching the full size should also be
acceptable.

This changed the behavior of parsing of "AUTH\r\n", where m will be set to 4,
since even though the word will match, the check for it being followed by ' '
or NUL will make line_begins() return false.

Tested:

- Using netcat to connect to the private socket directly:
  $ echo -ne '\0AUTH\r\n' | sudo nc -U /run/systemd/private
  REJECTED EXTERNAL ANONYMOUS

- Running the Ignition blackbox test:
  $ sudo sh -c 'PATH=$PWD/bin/amd64:$PATH ./tests.test'
  PASS

Fixes: d27b725abf64a19a6b2f99332b663f17ad046771
(cherry picked from commit 3f10c66270b74530339b3f466c43874bb40c210f)

Resolves: #1692991

6 years agotest: don't overwrite TESTDIR if already set
Frantisek Sumsal [Tue, 12 Mar 2019 21:44:25 +0000 (22:44 +0100)]
test: don't overwrite TESTDIR if already set

(cherry picked from commit 3f50fff536d715aee5e5195ec60e2af047b73c7f)

6 years agotests: also run TEST-01-BASIC in an unprivileged container (#9957)
Evgeny Vereshchagin [Thu, 30 Aug 2018 04:01:18 +0000 (07:01 +0300)]
tests: also run TEST-01-BASIC in an unprivileged container (#9957)

This should make it much easier to catch regressions like
https://github.com/systemd/systemd/issues/9914 and
https://github.com/systemd/systemd/issues/8535.

(cherry picked from commit 746fbd9c34af5ed8b6d9aa7a9cbd7cac63a3afce)

6 years agotests: allow passing additional arguments to nspawn via NSPAWN_ARGUMENTS
Evgeny Vereshchagin [Thu, 5 Jul 2018 16:30:52 +0000 (16:30 +0000)]
tests: allow passing additional arguments to nspawn via NSPAWN_ARGUMENTS

(cherry picked from commit 57916ea352b85153ecbed803d52861ca8b933dd3)

6 years agotests: use the asan wrapper to boot a VM/container if systemd is built with ASAN
Evgeny Vereshchagin [Thu, 5 Jul 2018 15:14:07 +0000 (15:14 +0000)]
tests: use the asan wrapper to boot a VM/container if systemd is built with ASAN

(cherry picked from commit 016fa3b9e8c3550d49f659c49b5ff4d93337aefe)

6 years agotests: redirect ASAN reports on journald to a file
Evgeny Vereshchagin [Tue, 3 Jul 2018 19:29:42 +0000 (19:29 +0000)]
tests: redirect ASAN reports on journald to a file

Otherwise, they will end up in /dev/null.

(cherry picked from commit 88ed0f261ba8164a689395ddee8b92d00e073515)

6 years agotests: add a wrapper for when systemd is built with ASAN
Evgeny Vereshchagin [Tue, 3 Jul 2018 03:25:53 +0000 (03:25 +0000)]
tests: add a wrapper for when systemd is built with ASAN

(cherry picked from commit 1786fae3668fa94359ee58a8c11031dc46459255)

6 years agotests: create the asan wrapper automatically if systemd has been built with ASAN
Evgeny Vereshchagin [Thu, 5 Jul 2018 04:09:30 +0000 (04:09 +0000)]
tests: create the asan wrapper automatically if systemd has been built with ASAN

(cherry picked from commit ec9181d2ce4c0ad8b1c70b16a2b02a2667b1cc05)

6 years agotest: add TEST-24-UNIT-TESTS running all basic tests under containers
Yu Watanabe [Wed, 19 Sep 2018 05:30:29 +0000 (14:30 +0900)]
test: add TEST-24-UNIT-TESTS running all basic tests under containers

(cherry picked from commit 3f6f58e03a7d22154aabe036439e7f2fb4849570)

6 years agorules: add the rule that adds elevator= kernel command line parameter
Lukas Nykryn [Tue, 26 Feb 2019 14:22:38 +0000 (15:22 +0100)]
rules: add the rule that adds elevator= kernel command line parameter

rhel-only
Resolves: #1670126

6 years agolgtm: drop redundant newlines
Evgeny Vereshchagin [Fri, 26 Oct 2018 10:25:36 +0000 (10:25 +0000)]
lgtm: drop redundant newlines

(cherry picked from commit 845702c63863add5606a7a7f00a959ffdcf89635)

6 years agolgtm: add a custom query for catching the use of fgets
Evgeny Vereshchagin [Fri, 26 Oct 2018 09:19:09 +0000 (09:19 +0000)]
lgtm: add a custom query for catching the use of fgets

As everybody knows, nodoby really reads CODING_STYLE (especially
the last paragraph :-)) so let's utilize LGTM to help us catch the
use of fgets.

(cherry picked from commit f86c1da28340f2a2afd34d72c9f416a2a94219a8)

6 years agotools: use print function in Python 3 code
Lucas Werkmeister [Sat, 25 Aug 2018 16:41:42 +0000 (18:41 +0200)]
tools: use print function in Python 3 code

This GDB script was converted to use Python 3 along with all other
Python scripts in commit b95f5528cc, but still used the Python 2 print
statement syntax instead of the Python 3 print function. Fix that.

We also add the Python 2 compatibility statement, just in case some GDB
still uses Python 2 instead of Python 3.

6 years agolgtm: use python3
Yu Watanabe [Sat, 8 Dec 2018 11:51:56 +0000 (20:51 +0900)]
lgtm: use python3

(cherry picked from commit fc1c09e1dfd2073fb49c4e7bb87102c88a551876)

6 years agoLGTM: make LGTM.com use meson from pip
Yu Watanabe [Mon, 23 Jul 2018 16:37:29 +0000 (01:37 +0900)]
LGTM: make LGTM.com use meson from pip

(cherry picked from commit 55d651d8f69919b98cdc062e312e4454c34428ef)

6 years agorules: implement new memory hotplug policy
Jan Synacek [Wed, 30 Jan 2019 09:36:53 +0000 (10:36 +0100)]
rules: implement new memory hotplug policy

Our new policy is based on following motivations (assumptions),
  * we want to allow the system to use hotplugged memory
  * we want memory ballon inflation to work as expected in VMs (going for small
  to big in terms of memory footprint)
  * we want to allow memory hotplug and memory hot-unplug on high-end
  enterprise server (we assume that node0 will have sufficient memory
  resources and marking all memory as movable shouldn't be a problem)

Policy:
  * nevert online memory on s390 (on both physical and z/VM)
  * mark memory as "online_movable" on physical machines
  * mark memory as "online" in VMs

If you have the feeling that all this is very wrong and we shouldn't
encode complex policies in udev rules you are absolutely right. However,
for now, we don't have any better place where to put it. In ideal world
we would have a user-space daemon that would be able to configure the
system wrt. to currently present HW and user-defined policy.

Resolves: #1670728

6 years agorule-syntax-check: allow PROGRAM as an assignment
Jan Synacek [Wed, 30 Jan 2019 11:22:41 +0000 (12:22 +0100)]
rule-syntax-check: allow PROGRAM as an assignment

(cherry picked from commit ed2dc503da57b0110819563e0d1c85d023435e07)

6 years agorules: add elevator= kernel command line parameter v239-12
Lukas Nykryn [Tue, 12 Feb 2019 15:58:16 +0000 (16:58 +0100)]
rules: add elevator= kernel command line parameter

Kernel removed the elevator= option, so let's reintroduce
it for rhel8 via udev rule.

rhel-only
Resolves: #1670126

6 years agotest-network: ignore tunnel devices automatically added by kernel
Yu Watanabe [Wed, 6 Feb 2019 11:02:15 +0000 (12:02 +0100)]
test-network: ignore tunnel devices automatically added by kernel

Fixes #10934.

(cherry picked from commit e327272d795453f68a4c30ba21eb0e887516cf68)

6 years agotest: replace echo with socat
Frantisek Sumsal [Tue, 29 Jan 2019 18:33:15 +0000 (19:33 +0100)]
test: replace echo with socat

The original version of the test used netcat along with a standard
AF_UNIX socket, which caused issues across different netcat
implementations. The AF_UNIX socket was then replaced by a FIFO with a
simple echo, which, however, suffers from the same issue (some echo
implementations don't check if the write() was successful).

Let's revert back to the AF_UNIX socket, but replace netcat with socat,
which, hopefully, resolves the main issue.

Relevant commit: 9b45c2bf02a43e3e1b42de1ab0c3fe29c64dc5f5

(cherry picked from commit b35d6d828b3216d022e565820d9971cb0f7746c1)

6 years agojournald: correctly attribute log messages also with cgroupsv1
Michal Sekletar [Fri, 14 Dec 2018 14:17:27 +0000 (15:17 +0100)]
journald: correctly attribute log messages also with cgroupsv1

With cgroupsv1 a zombie process is migrated to root cgroup in all
hierarchies. This was changed for unified hierarchy and /proc/PID/cgroup
reports cgroup to which process belonged before it exited.

Be more suspicious about cgroup path reported by the kernel and use
unit_id provided by the log client if the kernel reports that process is
running in the root cgroup.

Users tend to care the most about 'log->unit_id' mapping so systemctl
status can correctly report last log lines. Also we wouldn't be able to
infer anything useful from "/" path anyway.

See: https://github.com/torvalds/linux/commit/2e91fa7f6d451e3ea9fec999065d2fd199691f9d

(cherry picked from commit 672773b63a4ebf95242b27e63071b93073ebc1f5)

Resolves: #1658115

6 years agojournal-remote: set a limit on the number of fields in a message
Zbigniew Jędrzejewski-Szmek [Fri, 7 Dec 2018 09:48:10 +0000 (10:48 +0100)]
journal-remote: set a limit on the number of fields in a message

Existing use of E2BIG is replaced with ENOBUFS (entry too long), and E2BIG is
reused for the new error condition (too many fields).

This matches the change done for systemd-journald, hence forming the second
part of the fix for CVE-2018-16865
(https://bugzilla.redhat.com/show_bug.cgi?id=1653861).

(cherry-picked from commit ef4d6abe7c7fab6cbff975b32e76b09feee56074)

Resolves: #1664977

6 years agojournal-remote: verify entry length from header
Zbigniew Jędrzejewski-Szmek [Fri, 7 Dec 2018 11:47:14 +0000 (12:47 +0100)]
journal-remote: verify entry length from header

Calling mhd_respond(), which ulimately calls MHD_queue_response() is
ineffective at point, becuase MHD_queue_response() immediately returns
MHD_NO signifying an error, because the connection is in state
MHD_CONNECTION_CONTINUE_SENT.

As Christian Grothoff kindly explained:
> You are likely calling MHD_queue_repsonse() too late: once you are
> receiving upload_data, HTTP forces you to process it all. At this time,
> MHD has already sent "100 continue" and cannot take it back (hence you
> get MHD_NO!).
>
> In your request handler, the first time when you are called for a
> connection (and when hence *upload_data_size == 0 and upload_data ==
> NULL) you must check the content-length header and react (with
> MHD_queue_response) based on this (to prevent MHD from automatically
> generating 100 continue).

If we ever encounter this kind of error, print a warning and immediately
abort the connection. (The alternative would be to keep reading the data,
but ignore it, and return an error after we get to the end of data.
That is possible, but of course puts additional load on both the
sender and reciever, and doesn't seem important enough just to return
a good error message.)

Note that sending of the error does not work (the connection is always aborted
when MHD_queue_response is used with MHD_RESPMEM_MUST_FREE, as in this case)
with libµhttpd 0.59, but works with 0.61:
https://src.fedoraproject.org/rpms/libmicrohttpd/pull-request/1

(cherry-picked from commit 7fdb237f5473cb8fc2129e57e8a0039526dcb4fd)

Related: #1664977

6 years agoµhttpd: use a cleanup function to call MHD_destroy_response
Zbigniew Jędrzejewski-Szmek [Fri, 7 Dec 2018 11:13:10 +0000 (12:13 +0100)]
µhttpd: use a cleanup function to call MHD_destroy_response

(cherry-picked from commit d101fb24eb1c58c97f2adce1f69f4b61a788933a)

Related: #1664977

6 years agojournald: lower the maximum entry size limit to ½ for non-sealed fds
Zbigniew Jędrzejewski-Szmek [Wed, 5 Dec 2018 21:52:53 +0000 (22:52 +0100)]
journald: lower the maximum entry size limit to ½ for non-sealed fds

We immediately read the whole contents into memory, making thigs much more
expensive. Sealed fds should be used instead since they are more efficient
on our side.

(cherry-picked from commit 6670c9de196c8e2d5e84a8890cbb68f70c4db6e3)

Related: #1664977

6 years agojournald: when processing a native message, bail more quickly on overbig messages
Zbigniew Jędrzejewski-Szmek [Wed, 5 Dec 2018 21:50:39 +0000 (22:50 +0100)]
journald: when processing a native message, bail more quickly on overbig messages

We'd first parse all or most of the message, and only then consider if it
is not too large. Also, when encountering a single field over the limit,
we'd still process the preceding part of the message. Let's be stricter,
and check size limits early, and let's refuse the whole message if it fails
any of the size limits.

(cherry-picked from commit 964ef920ea6735d39f856b05fd8ef451a09a6a1d)

Related: #1664977

6 years agojournald: set a limit on the number of fields (1k)
Zbigniew Jędrzejewski-Szmek [Wed, 5 Dec 2018 21:45:02 +0000 (22:45 +0100)]
journald: set a limit on the number of fields (1k)

We allocate a iovec entry for each field, so with many short entries,
our memory usage and processing time can be large, even with a relatively
small message size. Let's refuse overly long entries.

CVE-2018-16865
https://bugzilla.redhat.com/show_bug.cgi?id=1653861

What from I can see, the problem is not from an alloca, despite what the CVE
description says, but from the attack multiplication that comes from creating
many very small iovecs: (void* + size_t) for each three bytes of input message.

(cherry-picked from commit 052c57f132f04a3cf4148f87561618da1a6908b4)

Resolves: #1664977

6 years agojournal: fix syslog_parse_identifier()
Yu Watanabe [Wed, 8 Aug 2018 06:06:36 +0000 (15:06 +0900)]
journal: fix syslog_parse_identifier()

Fixes #9829.

(cherry-picked from commit a6aadf4ae0bae185dc4c414d492a4a781c80ffe5)

Resolves: #1664978

6 years agoRevert "sysctl.d: switch net.ipv4.conf.all.rp_filter from 1 to 2"
Lukas Nykryn [Fri, 8 Feb 2019 09:54:34 +0000 (10:54 +0100)]
Revert "sysctl.d: switch net.ipv4.conf.all.rp_filter from 1 to 2"

This reverts commit 75c9af80cf3529c76988451e63f98010c86f48f1.

Resolves: #1653824

6 years agoprocess-util: don't use overly large buffer to store process command line
Michal Sekletar [Tue, 22 Jan 2019 13:29:50 +0000 (14:29 +0100)]
process-util: don't use overly large buffer to store process command line

Allocate new string as a return value and free our "scratch pad"
buffer that is potentially much larger than needed (up to
_SC_ARG_MAX).

Fixes #11502

(cherry-picked from commit eb1ec489eef8a32918bbfc56a268c9d10464584d)

Related: #1664976

6 years agojournald: periodically drop cache for all dead PIDs
Zbigniew Jędrzejewski-Szmek [Tue, 22 Jan 2019 16:30:48 +0000 (17:30 +0100)]
journald: periodically drop cache for all dead PIDs

In normal use, this allow us to drop dead entries from the cache and reduces
the cache size so that we don't evict entries unnecessarily. The time limit is
there mostly to serve as a guard against malicious logging from many different
PIDs.

(cherry-picked from commit 91714a7f427a6c9c5c3be8b3819fee45050028f3)

Related: #1664976

6 years agojournal: limit the number of entries in the cache based on available memory
Zbigniew Jędrzejewski-Szmek [Tue, 22 Jan 2019 15:12:52 +0000 (16:12 +0100)]
journal: limit the number of entries in the cache based on available memory

This is far from perfect, but should give mostly reasonable values. My
assumption is that if somebody has a few hundred MB of memory, they are
unlikely to have thousands of processes logging. A hundred would already be a
lot. So let's scale the cache size propritionally to the total memory size,
with clamping on both ends.

The formula gives 64 cache entries for each GB of RAM.

(cherry-picked from commit b12a480829c5ca8f4d4fa9cde8716b5f2f12a3ad)

Related: #1664976

6 years agobasic/prioq: add prioq_peek_item()
Zbigniew Jędrzejewski-Szmek [Sat, 26 Jan 2019 10:27:18 +0000 (11:27 +0100)]
basic/prioq: add prioq_peek_item()

(cherry-picked from commit ef21b3b5bf824e652addf850bcfd9374c7b33ce8)

Related: #1664976

6 years agoprocfs-util: expose functionality to query total memory
Zbigniew Jędrzejewski-Szmek [Tue, 22 Jan 2019 14:43:07 +0000 (15:43 +0100)]
procfs-util: expose functionality to query total memory

procfs_memory_get_current is renamed to procfs_memory_get_used, because
"current" can mean anything, including total memory, used memory, and free
memory, as long as the value is up to date.

No functional change.

(cherry-picked from commit c482724aa5c5d0b1391fcf958a9a3ea6ce73a085)

Related: #1664976

6 years agocoredump: fix message when we fail to save a journald coredump
Zbigniew Jędrzejewski-Szmek [Wed, 5 Dec 2018 20:34:24 +0000 (21:34 +0100)]
coredump: fix message when we fail to save a journald coredump

If creation of the message failed, we'd write a bogus entry:
systemd-coredump[1400]: Cannot store coredump of 416 (systemd-journal): No space left on device
systemd-coredump[1400]: MESSAGE=Process 416 (systemd-journal) of user 0 dumped core.
systemd-coredump[1400]: Coredump diverted to

(cherry-picked from commit f0136e09221364f931c3a3b715da4e4d3ee9f2ac)

Related: #1664976

6 years agobasic/process-util: limit command line lengths to _SC_ARG_MAX
Zbigniew Jędrzejewski-Szmek [Wed, 5 Dec 2018 17:48:23 +0000 (18:48 +0100)]
basic/process-util: limit command line lengths to _SC_ARG_MAX

This affects systemd-journald and systemd-coredump.

Example entry:
$ journalctl -o export -n1 'MESSAGE=Something logged'
__CURSOR=s=976542d120c649f494471be317829ef9;i=34e;b=4871e4c474574ce4a462dfe3f1c37f06;m=c7d0c37dd2;t=57c4ac58f3b98;x=67598e942bd23dc0
__REALTIME_TIMESTAMP=1544035467475864
__MONOTONIC_TIMESTAMP=858200964562
_BOOT_ID=4871e4c474574ce4a462dfe3f1c37f06
PRIORITY=6
_UID=1000
_GID=1000
_CAP_EFFECTIVE=0
_SELINUX_CONTEXT=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
_AUDIT_SESSION=1
_AUDIT_LOGINUID=1000
_SYSTEMD_OWNER_UID=1000
_SYSTEMD_UNIT=user@1000.service
_SYSTEMD_SLICE=user-1000.slice
_SYSTEMD_USER_SLICE=-.slice
_SYSTEMD_INVOCATION_ID=1c4a469986d448719cb0f9141a10810e
_MACHINE_ID=08a5690a2eed47cf92ac0a5d2e3cf6b0
_HOSTNAME=krowka
_TRANSPORT=syslog
SYSLOG_FACILITY=17
SYSLOG_IDENTIFIER=syslog-caller
MESSAGE=Something logged
_COMM=poc
_EXE=/home/zbyszek/src/systemd-work3/poc
_SYSTEMD_CGROUP=/user.slice/user-1000.slice/user@1000.service/gnome-terminal-server.service
_SYSTEMD_USER_UNIT=gnome-terminal-server.service
SYSLOG_PID=4108
SYSLOG_TIMESTAMP=Dec  5 19:44:27
_PID=4108
_CMDLINE=./poc AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA>
_SOURCE_REALTIME_TIMESTAMP=1544035467475848

$ journalctl -o export -n1 'MESSAGE=Something logged' --output-fields=_CMDLINE|wc
      6    2053 2097410

2MB might be hard for some clients to use meaningfully, but OTOH, it is
important to log the full commandline sometimes. For example, when the program
is crashing, the exact argument list is useful.

(cherry-picked from commit 2d5d2e0cc5171c6795d2a485841474345d9e30ab)

Related: #1664976

6 years agojournald: do not store the iovec entry for process commandline on stack
Zbigniew Jędrzejewski-Szmek [Wed, 5 Dec 2018 17:38:39 +0000 (18:38 +0100)]
journald: do not store the iovec entry for process commandline on stack

This fixes a crash where we would read the commandline, whose length is under
control of the sending program, and then crash when trying to create a stack
allocation for it.

CVE-2018-16864
https://bugzilla.redhat.com/show_bug.cgi?id=1653855

The message actually doesn't get written to disk, because
journal_file_append_entry() returns -E2BIG.

(cherry-picked from commit 084eeb865ca63887098e0945fb4e93c852b91b0f)

Resolves: #1664976

6 years agojournald: remove unnecessary {}
Zbigniew Jędrzejewski-Szmek [Wed, 5 Dec 2018 16:53:50 +0000 (17:53 +0100)]
journald: remove unnecessary {}

(cherry-picked from commit bc2762a309132a34db1797d8b5792d5747a94484)

Related: #1664976

6 years agocoredump: remove duplicate MESSAGE= prefix from message
Zbigniew Jędrzejewski-Szmek [Wed, 5 Dec 2018 16:33:15 +0000 (17:33 +0100)]
coredump: remove duplicate MESSAGE= prefix from message

systemd-coredump[9982]: MESSAGE=Process 771 (systemd-journal) of user 0 dumped core.
systemd-coredump[9982]: Coredump diverted to /var/lib/systemd/coredump/core...

log_dispatch() calls log_dispatch_internal() which calls write_to_journal()
which appends MESSAGE= on its own.

(cherry-picked from commit 4f62556d71206ac814a020a954b397d4940e14c3)

Related: #1664976

6 years agotravis: reboot the container before running tests
Frantisek Sumsal [Thu, 17 Jan 2019 11:03:10 +0000 (12:03 +0100)]
travis: reboot the container before running tests

6 years agotravis: fix syntax error in .travis.yml
Frantisek Sumsal [Tue, 15 Jan 2019 13:35:27 +0000 (14:35 +0100)]
travis: fix syntax error in .travis.yml

(cherry picked from commit 7f9d44f527ea214347f7d3b3b067f84df53feed7)