1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00
Commit Graph

37914 Commits

Author SHA1 Message Date
Yu Watanabe
8f44e0f419
Merge pull request #11361 from yuwata/follow-up-11352
core/socket: two follow-ups for #11352
2019-01-10 14:25:58 +09:00
Yu Watanabe
943179fe2a
Merge pull request #11366 from keszybz/a-few-unrelated-cleanups
A few unrelated cleanups
2019-01-10 14:25:25 +09:00
Zbigniew Jędrzejewski-Szmek
65641b3cdc logind: do not pass negative number to strerror 2019-01-10 14:22:28 +09:00
Zbigniew Jędrzejewski-Szmek
a685c049c0
Merge pull request #11374 from keszybz/journal-fixes
Journal/journal-remote/coredump fixes
2019-01-10 01:12:22 +01:00
Zbigniew Jędrzejewski-Szmek
ef4d6abe7c 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).
2019-01-09 23:44:17 +01:00
Zbigniew Jędrzejewski-Szmek
7fdb237f54 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
2019-01-09 23:44:17 +01:00
Zbigniew Jędrzejewski-Szmek
d101fb24eb µhttpd: use a cleanup function to call MHD_destroy_response 2019-01-09 23:44:17 +01:00
Zbigniew Jędrzejewski-Szmek
6670c9de19 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.
2019-01-09 23:41:53 +01:00
Zbigniew Jędrzejewski-Szmek
964ef920ea 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.
2019-01-09 23:41:53 +01:00
Zbigniew Jędrzejewski-Szmek
052c57f132 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.
2019-01-09 23:41:53 +01:00
Zbigniew Jędrzejewski-Szmek
f0136e0922 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
2019-01-09 23:41:53 +01:00
Zbigniew Jędrzejewski-Szmek
2d5d2e0cc5 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.
2019-01-09 23:41:53 +01:00
Zbigniew Jędrzejewski-Szmek
084eeb865c 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.
2019-01-09 23:41:53 +01:00
Zbigniew Jędrzejewski-Szmek
bc2762a309 journald: remove unnecessary {} 2019-01-09 23:41:53 +01:00
Zbigniew Jędrzejewski-Szmek
4f62556d71 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.
2019-01-09 23:41:53 +01:00
Yu Watanabe
d253a45e1c core/mount: make mount_setup_existing_unit() not drop MOUNT_PROC_JUST_MOUNTED flag from units
This fixes a bug introduced by ec88d1ea05.

Fixes #11362.
2019-01-09 12:51:00 +01:00
Zbigniew Jędrzejewski-Szmek
690f02f4b8 timesyncd,resolved,machinectl: drop calls to sd_event_get_exit_code()
In all three cases, sd_event_loop() will return the exit code anyway.
If sd_event_loop() returns negative, failure is logged and results in an
immediate return. Otherwise, we don't care if sd_event_loop() returns 0
or positive, because the return value feeds into DEFINE_MAIN_FUNCTION(), which
doesn't make the distinction.
2019-01-08 23:26:07 +01:00
Zbigniew Jędrzejewski-Szmek
1b2a7d92af Fix a few comments 2019-01-08 23:11:26 +01:00
Zbigniew Jędrzejewski-Szmek
2cfb197890 sd-device: modernize code a bit
Empty line between setting the output parameter and return is removed. I like
to think about both steps as part of returning from the function, and there's
no need to separate them.

Similarly, if we need to unset a pointer after successfully passing ownership,
use TAKE_PTR and do it immediately after the ownership change, without an empty
line inbetween.
2019-01-08 22:14:06 +01:00
Yu Watanabe
82d9ac23fd udev-node: make link_find_prioritized() return negative value when nothing found
Fixes a bug introduced by a2554acec6.

Fixes RHBZ#1662303.
2019-01-08 19:21:44 +01:00
Yu Watanabe
d501e52bf1 core/socket: drop unnecessary assignment to 'r'
Follow-up for e541734528.

As suggested in #11352.
2019-01-09 02:11:19 +09:00
Yu Watanabe
6548603235 core/socket: use macro to define log_address_error_errno()
Then, it is not necessary to suppress warnings.

Follow-up for ae05e1b658.
2019-01-09 02:09:36 +09:00
dana
c501ecd70c zsh completion: Prevent functions from clobbering each other, &c.
- Don't redefine helpers on every call
- Prefix helper names with main function name
- Adjust some helper names for consistency and convention adherance
2019-01-08 15:23:37 +01:00
marvelousblack
f047466041 Add Teclast X80 PLUS (H5C5) accel mount matrix 2019-01-08 15:09:08 +01:00
Zbigniew Jędrzejewski-Szmek
f0560c7453
Merge pull request #11355 from yuwata/rfe-11343
conf-parse: accept whitespaces before comments
2019-01-08 15:07:33 +01:00
Lennart Poettering
3f1af087a9
Merge pull request #11352 from yuwata/rfe-11348
core/socket: logs address or path which fails to be initialized
2019-01-08 11:43:35 +01:00
Claudius Ellsel
0919362b31 Unchain not related mice in 70-mouse.hwdb 2019-01-08 10:40:09 +01:00
Michael Sloan
a08c3e8f25 cat: add --stderr-priority option 2019-01-08 10:37:20 +01:00
Zbigniew Jędrzejewski-Szmek
c64715b5cb
Merge pull request #11344 from poettering/various-fixes
multiple trivial fixlets, across the tree
2019-01-08 10:33:09 +01:00
Yu Watanabe
c494b739a4 udevadm: refuse to run trigger, control, settle and monitor commands in chroot
Closes #11333.
2019-01-08 10:31:19 +01:00
Yu Watanabe
787a133f2d NEWS: also mention that clock file for timesyncd may need to move
Follow-up for aa2437e2ae.

Closes #11329.
2019-01-08 10:20:33 +01:00
Yu Watanabe
ff650ffe34 test: add testcases for the lines prefixed with whitespaces 2019-01-08 14:12:22 +09:00
Yu Watanabe
b41dd0d2db conf-parser: accept whitespaces before comments
Closes #11343.
2019-01-08 14:05:15 +09:00
Yu Watanabe
71b21730d4 conf-parser: mention that unknown lvalue is ignored 2019-01-08 12:50:58 +09:00
Yu Watanabe
bca3222cd6
Merge pull request #11351 from yuwata/ethtool-port-table
ethtool: cleanups for port_table
2019-01-08 12:23:11 +09:00
Yu Watanabe
c226800996
Merge pull request #11232 from yuwata/fix-9130-alternative
network: always check link is ready when address is updated
2019-01-08 12:22:21 +09:00
Yu Watanabe
ae05e1b658 core/socket: logs address or path which fails to be initialized
Closes #11348.
2019-01-08 04:40:46 +09:00
Yu Watanabe
e541734528 core/socket: use _cleanup_ attribute for closing fds on error 2019-01-08 04:11:59 +09:00
Yu Watanabe
fc2d74ab05 core/socket: use log_unit_*() 2019-01-08 04:11:45 +09:00
Yu Watanabe
44909f1c9f ethtool: minimize the size of port_table
Note that `_NET_DEV_PORT_MAX` is 0x100.
2019-01-08 03:30:15 +09:00
Yu Watanabe
1637c3575b ethtool: use kernel defined values for NET_DEV_PORT_* 2019-01-08 03:28:47 +09:00
Zbigniew Jędrzejewski-Szmek
a75211421f udev: rework how we handle the return value from spawned programs
When running PROGRAM="...", we would log
systemd-udevd[447]: Failed to wait spawned command '...': Input/output error
no matter why the program actually failed, at error level.

The code wouldn't distinguish between an internal failure and a failure in the
program being called and run sd_event_exit(..., -EIO) on any kind of error. EIO
is rather misleading here, becuase it suggests a serious error.

on_spawn_sigchld is updated to set the return code to distinguish failure to
spawn, including the program being killed by a signal (a negative return value),
and the program failing (positive return value).

The logging levels are adjusted, so that for PROGRAM= calls, which are
essentially "if" statements, we only log at debug level (unless we get a
timeout or segfault or another unexpected error).
2019-01-07 18:36:04 +01:00
Lennart Poettering
be0b7a1a66 tree-wide: always declare bitflag enums the same way
let's always use the 1 << x syntax. No change of behaviour or even of
the compiled binary.
2019-01-07 17:50:39 +01:00
Lennart Poettering
f8c186c9ec json: handle NULL explicitly in json_variant_has_type() 2019-01-07 17:50:39 +01:00
Lennart Poettering
6af022fedd json: fix typo 2019-01-07 17:50:39 +01:00
Lennart Poettering
fc0f6fbffc json: teach json_log() the new SYNTHETIC_ERRNO() logic 2019-01-07 17:50:39 +01:00
Lennart Poettering
16420be1fd loop-util: tweak codepath when a loopback file is "created" from an existing block device
Be more careful with initialized of the 'relinquished' boolean field,
and let's return the fd, like we do for the regular codepath, too.
2019-01-07 17:50:39 +01:00
Lennart Poettering
26c1be0fdc loop-util: minor simplification 2019-01-07 17:50:39 +01:00
Lennart Poettering
cbf13087cc fsck: use symbolic names where we have them 2019-01-07 17:50:39 +01:00
Lennart Poettering
aebfc8f090 stat-util: remove spurious newline 2019-01-07 17:50:39 +01:00