Commit graph

4118 commits

Author SHA1 Message Date
Simon McVittie
3d1426ac72 Add a regression test for making systemd activation appear to fail 2015-02-09 11:06:38 +00:00
Simon McVittie
a3c1b66b7a Merge branch '1.8-cve-2015-0245' into cve-2015-0245
Conflicts:
	NEWS
	bus/system.conf.in
	configure.ac
2015-02-09 11:06:32 +00:00
Simon McVittie
239fa20812 Add test-fdpass to the build, and make it compile again
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88998
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-05 15:23:22 +00:00
Simon McVittie
03c5e16175 CVE-2015-0245: discard forged ActivationFailure messages
Without this code change, non-systemd processes can make dbus-daemon
think systemd failed to activate a system service, resulting in an
error reply back to the requester. In practice we can address this in
system.conf by only allowing root to forge these messages, but this
check is the real solution, particularly on systems where root is
not all-powerful.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88811
Reviewed-by: Alban Crequy
Reviewed-by: David King
Reviewed-by: Philip Withnall
2015-02-05 14:54:31 +00:00
Simon McVittie
aaea599163 bus_driver_get_owner_of_name: factor out from bus_driver_get_conn_helper
We need this, or something equivalent, to address CVE-2015-0245 via
code changes.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88811
Reviewed-by: Alban Crequy
Reviewed-by: David King
Reviewed-by: Philip Withnall
2015-02-05 14:54:28 +00:00
Simon McVittie
dfc53a221f 1.8.17 2015-02-05 14:54:10 +00:00
Simon McVittie
4f99a694b5 tests: make installable metadata Windows-friendly by using EXEEXT
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88980
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-05 14:14:34 +00:00
Simon McVittie
3f762bef24 tests: make sure to specify CPPFLAGS where needed
test-marshal and test-syntax need the
$(testutils_shared_if_possible_cppflags), so that they will get the
$(static_cflags) when we are not linking to dbus-glib.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88980
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-05 14:14:17 +00:00
Simon McVittie
7ae9b3c974 bus_driver_check_caller_is_privileged: correct the DBUS_WIN case
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88964
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-04 20:15:00 +01:00
Ralf Habacker
e6bece4498 _dbus_listen_tcp_socket: Keep windows code to fetch port from tcp listening socket in sync with unix.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=87999
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-04 19:30:38 +01:00
Simon McVittie
8628ed6132 NEWS for 1.9 2015-02-04 17:44:05 +00:00
Simon McVittie
94610d7de6 Add a common test_init() for GLib tests which prevents hanging forever
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:36 +00:00
Simon McVittie
1a28f82926 dbus-monitor: add options to log binary data with or without pcap framing
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:34 +00:00
Simon McVittie
8a621b8f77 dbus-monitor: add support for using BecomeMonitor to be a read-only monitor
Move the dbus_connection_add_filter() call further up as a precaution,
because it isn't safe for a monitor to not have a filter that
swallows all messages.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:31 +00:00
Simon McVittie
81e9e4e078 Allow root to monitor the system bus by default
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:28 +00:00
Simon McVittie
a650bd055f Add a regression test for being a new-style monitor
This includes most of the situations I could think of:

* method call on dbus-daemon and response
* NameOwnerChanged
* NameAcquired, NameLost (although I'm not 100% sure these should
  get captured, since they're redundant with NameOwnerChanged)
* unicast message is allowed through
* unicast message is rejected by no-sending or no-receiving policy
* broadcast is allowed through
* broadcast is rejected by no-sending policy (the error reply
  is also captured)
* broadcast is rejected by no-receiving policy (there is no error
  reply)
* message causing service activation, and the message telling systemd
  to do the actual activation
* systemd reporting that activation failed

It does not cover:

* sending a message to dbus-daemon, then provoking a reply, then
  dbus-daemon does not allow itself to send the reply due to its
  own security policy

This is such an obscure corner case that I'm not even convinced it's
testable without dropping down into lower-level socket manipulation:
dbus-daemon's replies are always assumed to be requested replies,
and replies contain so little other metadata that I think we can
only forbid them by forbidding all method replies. If we do that,
the reply to Hello() won't arrive and the client-side connection will
not become active.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:24 +00:00
Simon McVittie
1acedfdde7 Capture a fake reply if a broadcast cannot be delivered
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:22 +00:00
Simon McVittie
9fce738033 Capture all messages received or sent, and send them to monitors
Unlike eavesdropping, the point of capture is when the message is
received, except for messages originating inside the dbus-daemon.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:17 +00:00
Simon McVittie
00af6389be Add support for morphing a D-Bus connection into a "monitor"
This is a special connection that is not allowed to send anything,
and loses all its well-known names.

In future commits, it will get a new set of match rules and the
ability to eavesdrop on messages before the rest of the bus daemon
has had a chance to process them.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:08 +00:00
Simon McVittie
4a0f1849be Merge branch 'dbus-1.8' 2015-02-04 17:07:25 +00:00
Simon McVittie
af6e170d8e Prepare embargoed 1.8.16 release 2015-02-04 16:51:10 +00:00
Simon McVittie
6dbd09fedc CVE-2015-0245: prevent forged ActivationFailure from non-root processes
Without either this rule or better checking in dbus-daemon, non-systemd
processes can make dbus-daemon think systemd failed to activate a system
service, resulting in an error reply back to the requester.

This is redundant with the fix in the C code (which I consider to be
the real solution), but is likely to be easier to backport.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88811
Reviewed-by: Alban Crequy
Reviewed-by: David King
Reviewed-by: Philip Withnall
2015-02-04 16:45:16 +00:00
Simon McVittie
3a78d91694 NEWS for 1.8 branch 2015-02-04 16:44:31 +00:00
Simon McVittie
1f05dc9744 _dbus_listen_tcp_socket: comment on another reason to ignore EADDRINUSE
Not being aware of the second reason described here caused bug #87999
in the equivalent code on Windows.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=87999
2015-02-04 15:19:43 +00:00
Simon McVittie
d70675e940 _dbus_listen_tcp_socket: use NI_NUMERICSERV to determine port number
If we happen to have been given (say) port 30865, we want to
represent that as host=localhost,port=30865 and not
host=localhost,port=csync2.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=87999
2015-02-04 15:19:42 +00:00
Ralf Habacker
ffa69bcb55 Provide appropriate DBUS_USER and DBUS_TEST_USER under CMake
[separated out from a larger commit -smcv]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88964
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-04 15:14:00 +00:00
Ralf Habacker
b36747519a Link tests to test-utils-glib.c under CMake too
[Separated out from a larger commit -smcv]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88964
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-04 15:11:48 +00:00
Simon McVittie
9806240b78 dbus-monitor: use common code from dbus-test-tool
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall
[also sync up the cmake build system -smcv]
2015-02-04 14:18:39 +00:00
Simon McVittie
ca63ef7133 1.9.9 2015-02-03 23:13:51 +00:00
Simon McVittie
d7b3dba1bd 1.9.8 development release 2015-02-03 19:36:07 +00:00
Simon McVittie
3cf71c2707 Treat root as a valid candidate for TEST_USER_ME
If spawn_dbus_daemon() can fail for TEST_USER_ME, then we'd have to
go through all the tests adding the ability to skip tests after
it fails, which is a fairly extensive change.

The tests have historically all run as whatever uid is supplied, and
if the tests are being run as root for some reason - perhaps in a CI
framework for an embedded platform that doesn't have non-root users,
or in an environment where you can be root or non-root but not both -
there is no particular reason to skip them.
2015-02-03 19:35:39 +00:00
Simon McVittie
b1c54b5a75 NEWS 2015-02-03 16:25:56 +00:00
Simon McVittie
cf35dad25a Add a regression test for systemd activation
4.5 years after it was implemented, here is the regression test.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=57952
Reviewed-by: Philip Withnall
2015-02-03 16:20:01 +00:00
Simon McVittie
652a324fb6 bus_context_log_and_set_error: add and use
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:24 +00:00
Simon McVittie
c6e024834b _dbus_set_error_valist: add
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:20 +00:00
Simon McVittie
3861a42655 bus_context_log_literal: add simplified version of bus_context_log
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:17 +00:00
Simon McVittie
5b89e2a839 bus: put the printf attribute in the header where it will do more good
Now we can actually notice incorrect format strings in other
translation units.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:14 +00:00
Simon McVittie
1f716452e7 bus driver: factor out bus_driver_check_caller_is_privileged, and allow root
Unlike the initial mitigation for CVE-2014-8148, we now allow
uid 0 to call UpdateActivationEnvironment. There's no point in root
doing that, but there's also no reason why it's particularly bad -
if an attacker is uid 0 we've already lost - and it simplifies
use of this function for future things that do want to be callable
by root, like BecomeMonitor for #46787.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:11 +00:00
Simon McVittie
98ae1149ad Add a test for uid-controlled permissions
This is technical debt from mitigating CVE-2014-8148, which should
really have had a regression test at the time.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:08 +00:00
Simon McVittie
6a49ced2dd Add infrastructure to run bits of tests under an alternative uid
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:05 +00:00
Simon McVittie
1e21cc86bf test: implement GLib-style "installed tests"
We run each test twice:

* once with the system's session.conf, as an integration test
  (test-cases that need a special configuration are automatically
  skipped)
* once with our special test configuration files, which provide better
  coverage

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:01 +00:00
Simon McVittie
ee032f5a11 Generate test configuration files via build-time sed, not configure
This means we can generate a version that works when installed,
from the same source files.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:19:00 +00:00
Simon McVittie
8b238f3f0d Factor out some utility functions from test/dbus-daemon*
In the process, make test_kill_pid() safer: do not try to terminate
more than one pid, or the NULL handle.

Also stop leaking the address_fd in spawn_dbus_daemon, a pre-existing
bug that was spotted by Philip Withnall during review.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:18:57 +00:00
Simon McVittie
6976a7f199 Bump required GLib version to 2.36
This is for g_close(), which the next commit will use. It also lets us
rely on g_type_init() being a no-op (since 2.32 the type system is
always initialized by a global constructor).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:18:47 +00:00
Lukasz Skalski
9668c61726 Update .gitignore files
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88943
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-03 15:40:01 +00:00
Simon McVittie
9e0f5ae7d3 NEWS 2015-02-02 18:52:08 +00:00
Simon McVittie
1acc7b09ed lcov: use builddir, not srcdir
It seems lcov (or gcc?) has changed its paths since last time this
worked.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88808
Reviewed-by: Philip Withnall
2015-02-02 18:38:07 +00:00
Simon McVittie
7cf5d2fac4 Enable subdir-objects Automake option
It has been supported since at least 1.10, and its absence is
deprecated since 1.14.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88808
Reviewed-by: Philip Withnall
2015-02-02 18:38:07 +00:00
Simon McVittie
ef06f2a233 bus: exit on fatal errors even if not syslogging
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88808
Reviewed-by: Philip Withnall
2015-02-02 18:38:07 +00:00
Ralf Habacker
795ea3007e Fix 'dbus-daemon on Windows: Failed to bind socket "localhost:xxxx": Address already in use'.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=87999
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-01-30 22:07:10 +01:00