Commit graph

5259 commits

Author SHA1 Message Date
Simon McVittie
dd32f6b617 Update NEWS 2020-04-20 19:28:16 +01:00
Simon McVittie
d251fe7850 Merge branch 'cherry-pick-b034b83b' into 'dbus-1.12'
[1.12] bus: Don't explicitly clear BusConnections.monitors

See merge request dbus/dbus!142
2020-02-25 12:59:48 +00:00
Simon McVittie
2c6b0ad7f6 bus: Don't explicitly clear BusConnections.monitors
Each connection that is an active monitor holds a pointer to its own
link in this list, via BusConnectionData.link_in_monitors. We can't
validly free the list while these pointers exist: that would be a
use-after-free, when each connection gets disconnected and tries to
remove itself from the list.

Instead, let each connection remove itself from the list, then assert
that the list has become empty.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/291


(cherry picked from commit b034b83b59)
2020-02-25 12:50:08 +00:00
Simon McVittie
df0c675b93 Merge branch 'cherry-pick-bf71a58e' into 'dbus-1.12'
doc: Fix environment variable name in dbus-daemon(1)

See merge request dbus/dbus!141
2020-02-20 13:23:22 +00:00
Philip Withnall
beb79b94fb doc: Fix environment variable name in dbus-daemon(1)
Spotted by Mubin. This documentation relates to the code in
add_bus_environment() in bus/activation.c.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Fixes: #275


(cherry picked from commit bf71a58e4a)
2020-02-20 13:15:51 +00:00
Simon McVittie
eab5d4a420 Start 1.12.18 development
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 16:29:36 +01:00
Simon McVittie
23cc709db8 Prepare version 1.12.16
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-09 13:09:13 +01:00
Simon McVittie
066aea7728 test: Add basic test coverage for DBUS_COOKIE_SHA1
We don't actually complete successful authentication, because that
would require us to generate a cookie and compute the correct SHA1,
which is difficult to do in a deterministic authentication script.
However, we do assert that dbus#269 (CVE-2019-12749) has been fixed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-09 13:08:49 +01:00
Simon McVittie
47b1a4c410 auth: Reject DBUS_COOKIE_SHA1 for users other than the server owner
The DBUS_COOKIE_SHA1 authentication mechanism aims to prove ownership
of a shared home directory by having the server write a secret "cookie"
into a .dbus-keyrings subdirectory of the desired identity's home
directory with 0700 permissions, and having the client prove that it can
read the cookie. This never actually worked for non-malicious clients in
the case where server uid != client uid (unless the server and client
both have privileges, such as Linux CAP_DAC_OVERRIDE or traditional
Unix uid 0) because an unprivileged server would fail to write out the
cookie, and an unprivileged client would be unable to read the resulting
file owned by the server.

Additionally, since dbus 1.7.10 we have checked that ~/.dbus-keyrings
is owned by the uid of the server (a side-effect of a check added to
harden our use of XDG_RUNTIME_DIR), further ruling out successful use
by a non-malicious client with a uid differing from the server's.

Joe Vennix of Apple Information Security discovered that the
implementation of DBUS_COOKIE_SHA1 was susceptible to a symbolic link
attack: a malicious client with write access to its own home directory
could manipulate a ~/.dbus-keyrings symlink to cause the DBusServer to
read and write in unintended locations. In the worst case this could
result in the DBusServer reusing a cookie that is known to the
malicious client, and treating that cookie as evidence that a subsequent
client connection came from an attacker-chosen uid, allowing
authentication bypass.

This is mitigated by the fact that by default, the well-known system
dbus-daemon (since 2003) and the well-known session dbus-daemon (in
stable releases since dbus 1.10.0 in 2015) only accept the EXTERNAL
authentication mechanism, and as a result will reject DBUS_COOKIE_SHA1
at an early stage, before manipulating cookies. As a result, this
vulnerability only applies to:

* system or session dbus-daemons with non-standard configuration
* third-party dbus-daemon invocations such as at-spi2-core (although
  in practice at-spi2-core also only accepts EXTERNAL by default)
* third-party uses of DBusServer such as the one in Upstart

Avoiding symlink attacks in a portable way is difficult, because APIs
like openat() and Linux /proc/self/fd are not universally available.
However, because DBUS_COOKIE_SHA1 already doesn't work in practice for
a non-matching uid, we can solve this vulnerability in an easier way
without regressions, by rejecting it early (before looking at
~/.dbus-keyrings) whenever the requested identity doesn't match the
identity of the process hosting the DBusServer.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: https://gitlab.freedesktop.org/dbus/dbus/issues/269
Closes: CVE-2019-12749
2019-06-09 13:08:12 +01:00
Simon McVittie
95340593bd Start 1.12.16 development
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-05-17 15:48:14 +01:00
Simon McVittie
a330c6184f Release 1.12.14 2019-05-17 10:41:10 +01:00
Simon McVittie
74e1cfab1a Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-05-13 11:59:03 +01:00
Simon McVittie
94bacc6955 bus: Try to raise soft fd limit to match hard limit
Linux systems have traditionally set the soft limit to 1024 and the hard
limit to 4096. Recent versions of systemd keep the soft fd limit at
1024 to avoid breaking programs that still use select(), but raise the
hard limit to 512*1024, while in recent Debian versions a complicated
interaction between components gives a soft limit of 1024 and a hard
limit of 1024*1024. If we can, we might as well elevate our soft limit
to match the hard limit, minimizing the chance that we will run out of
file descriptor slots.

Unlike the previous code to raise the hard and soft limits to at least
65536, we do this even if we don't have privileges: privileges are
unnecessary to raise the soft limit up to the hard limit.

If we *do* have privileges, we also continue to raise the hard and soft
limits to at least 65536 if they weren't already that high, making
it harder to carry out a denial of service attack on the system bus on
systems that use the traditional limit (CVE-2014-7824).

As was previously the case on the system bus, we'll drop the limits back
to our initial limits before we execute a subprocess for traditional
(non-systemd) activation, if enabled.

systemd activation doesn't involve us starting subprocesses at all,
so in both cases activated services will still inherit the same limits
they did previously.

This change also fixes a bug when the hard limit is very large but
the soft limit is not, for example seen as a regression when upgrading
to systemd >= 240 (Debian #928877). In such environments, dbus-daemon
would previously have changed its fd limit to 64K soft/64K hard. Because
this hard limit is less than its original hard limit, it was unable to
restore its original hard limit as intended when carrying out traditional
activation, leaving activated subprocesses with unintended limits (while
logging a warning).

Reviewed-by: Lennart Poettering <lennart@poettering.net>
[smcv: Correct a comment based on Lennart's review, reword commit message]
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 7eacbfece7)
[smcv: Mention that this also fixes Debian #928877]
2019-05-13 11:50:34 +01:00
Clemens Lang
6e432ed51e cmake: Avoid overwriting PKG_CONFIG_PATH env var
The CMake config file installed by DBus will run in the context of other
projects. Consequently, changing the value of the PKG_CONFIG_DIR,
PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR environment variables will affect
any further calls to pkg-config made by such projects, which can cause
problems.

A common case of this happening are pkg-config files installed in
usr/share/pkgconfig for .pc files that are architecture-independent, as
for example systemd does.

Avoid clobbering the environment variables by saving and restoring their
values. Note that for some of the variables, setting them to an empty
string is different from not setting them at all.

Signed-off-by: Clemens Lang <clemens.lang@bmw-carit.de>
(cherry picked from commit 3525cc045d)
Closes: dbus#267
2019-05-13 10:36:11 +01:00
Simon McVittie
7642acca6d Merge branch 'cherry-pick-14f46d14' into 'dbus-1.12'
build: Don't assume we can set permissions on a directory

See merge request dbus/dbus!112
2019-04-18 16:09:06 +00:00
Simon McVittie
f1737ca1b7 build: Don't assume we can set permissions on a directory
MSYS2 has enough of a Unixish environment to run Autotools, but
apparently not enough of a Unixish environment to have functional
permissions.

Closes: dbus#216


(cherry picked from commit 14f46d14a0)
2019-04-18 15:38:38 +00:00
Simon McVittie
77c650f48b Merge branch '1-12-logical-op' into 'dbus-1.12'
Backport -Wlogical-op fixes to 1.12.x

See merge request dbus/dbus!109
2019-04-17 15:19:01 +00:00
Simon McVittie
177ef29188 Merge branch '1-12-code-coverage' into 'dbus-1.12'
Adapt to API change in AX_CODE_COVERAGE version 28

See merge request dbus/dbus!108
2019-04-17 15:18:42 +00:00
David King
c6c6b423cf _dbus_get_is_errno_eagain_or_ewouldblock: Avoid warning
EAGAIN and EWOULDBLOCK are documented to possibly be numerically equal,
for instance in errno(3), and a simple logical OR check will trigger the
-Wlogical-op warning of GCC. The GCC developers consider the warning to
work as-designed in this case:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602

Avoid such a warning by explicitly checking if the values are identical.

Fixes: https://gitlab.freedesktop.org/dbus/dbus/issues/225
Signed-off-by: David King <dking@redhat.com>
Reviewed-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit a653191342)
2019-04-17 13:38:05 +01:00
David King
2fb62561f0 dbus-send: Avoid duplicated-branches warning
Switch the order of the argument checks to avoid the
-Wduplicated-branches warning.

Signed-off-by: David King <dking@redhat.com>
Reviewed-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit c0bf0d185d)
2019-04-17 13:38:05 +01:00
Simon McVittie
2e4a72ed51 desktop-file: Justify implementation of is_valid_section_name()
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 99580298f3)
2019-04-17 13:38:05 +01:00
David King
2b09942986 is_valid_section_name: Fix logical expression
Group names in desktop files may contain all ASCII characters, except
control characters and '[' and ']'. Rather than accepting all values,
thanks to a logical operator confusion found by GCC warning
-Wlogical-op, instead explicitly reject the invalid values.

Signed-off-by: David King <dking@redhat.com>
Fixes: https://gitlab.freedesktop.org/dbus/dbus/issues/208
(cherry picked from commit 3ef9e789c1)
2019-04-17 13:38:05 +01:00
Simon McVittie
d9ef0226e2 Adapt to API change in AX_CODE_COVERAGE version 28
AX_CODE_COVERAGE recently changed the way it embedded its Makefile rules
in the output file: instead of using @CODE_COVERAGE_RULES@, users
are now meant to include aminclude_static.am.

The new AX_CODE_COVERAGE is only in the latest autoconf-archive release,
version 2019.01.06, which is inconveniently new, so bundle everything
we need for the moment.

This requires us to stop using the deprecated CODE_COVERAGE_LDFLAGS
(which we still used to support older versions of autoconf-archive)
and replace them with CODE_COVERAGE_LIBS.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 2938c2125e)
Closes: dbus#265
2019-04-17 10:19:57 +01:00
Simon McVittie
6ef67cff6b configure.ac: Forbid AX_-prefixed patterns more selectively
We want to make autoconf fail early and with a user-comprehensible
message if autoconf-archive isn't installed, rather than generating
a configure script with syntax errors, or a configure script that runs
successfully but doesn't do what we intended.

However, autoconf-archive doesn't actually guarantee not to use
AX_-prefixed shell variable names without m4_pattern_allow'ing them
(unlike Autoconf, Automake, Libtool and pkg-config, which explicitly use
m4_pattern_allow for variables with AC_, AM_, LT_ and PKG_ prefixes), so
it isn't safe to assume that they won't be used. In particular, recent
versions of AX_CHECK_GNU_MAKE appear to be using
$AX_CHECK_GNU_MAKE_HEADLINE as a shell variable.

Instead, specifically forbid the names of the finite list of macros
that we actually use.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: dbus#249
(cherry picked from commit ee09cc0acd)
2019-01-21 17:56:07 +00:00
Simon McVittie
f921232a0f Start working on dbus 1.12.14
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-12-04 17:26:06 +00:00
Simon McVittie
d4f8423bbf 1.12.12
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-12-04 13:57:58 +00:00
Simon McVittie
e07e6377a1 CI: Start supporting Debian 10 'buster', currently under development
This gives us a way to build on a more recent host OS if we want to.
For Gitlab-CI it's disabled by default.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 28c27349e2)
2018-12-04 12:34:28 +00:00
Simon McVittie
8d34987ef7 CI: Exercise maintainer-only documentation build
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit bcc34caa43)
2018-12-04 12:32:54 +00:00
Simon McVittie
acae9c0643 CI: Stop building on Ubuntu 14.04 'trusty'
The version of gcc in trusty is too old for AddressSanitizer, which we
want to be able to start using, and Travis-CI finally supports Ubuntu
16.04 'xenial' now. This lets us remove some workarounds, but we need
to update others.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 0c553afcd9)
2018-12-04 12:32:45 +00:00
Ralf Habacker
7c00027eb7 ci-build.sh: Show file size in list of files to be able to compare generated file size
(cherry picked from commit bac2fd3aa4)
2018-12-04 12:32:35 +00:00
Simon McVittie
e4ea333fcd CI: Remove unimplemented --with-glib option
dbus has never actually had this option.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit e0a1bfb26a)
2018-12-04 12:28:12 +00:00
Simon McVittie
42b4e7319b CI: List attributes, sizes etc. of installed files, not just names
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit d71049799a)
2018-12-04 12:28:08 +00:00
Simon McVittie
ee1940f307 doc: Remove obsolete message about man2html
We no longer run man2html.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit f134e2d2c7)
2018-12-04 12:28:05 +00:00
Simon McVittie
700cec5485 CONTRIBUTING.md: Update and rewrite
This file hadn't kept up with reality, and needs updating for Gitlab.
Take the opportunity to rewrite it.

Much of the text, particularly about commit messages, was taken from
Wayland's contributing guide (thanks to Ander Conselvan de Oliveira,
Bryce Harrington, Eric Engestrom, Pekka Paalanen and Daniel Stone).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-12-04 11:13:54 +00:00
Simon McVittie
215ebadb90 CONTRIBUTING: Reformat as Markdown
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-12-04 11:13:44 +00:00
Simon McVittie
6d09d6b155 CONTRIBUTING: Remove all trailing whitespace
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-12-04 11:13:28 +00:00
Simon McVittie
64d7fa2713 Rename HACKING to CONTRIBUTING
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-12-04 11:13:05 +00:00
Simon McVittie
dc85541a9b NEWS: Refer to Gitlab
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-12-03 16:35:37 +00:00
Simon McVittie
7f9966ede8 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-12-03 16:32:32 +00:00
Simon McVittie
aa42766340 activation: Don't leak if delivering activation message is forbidden
This is technically a denial of service because the dbus-daemon will
run out of memory eventually, but it's a very slow and noisy one,
because all the rejected messages are also very likely to have
been logged to the system log.

Detected by AddressSanitizer.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/234
Reviewed-by: pwithnall
2018-12-03 16:32:31 +00:00
Simon McVittie
a6bae612ad Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-16 15:09:39 +00:00
Simon McVittie
ffa3bc17a7 dbus-daemon test: Allow much longer for pending fd timeout
The timeout we're using here is 0.5s (500ms), but the actual time taken
is unbounded, because the OS scheduler might not schedule our process
for an arbitrary length of time after we become runnable.

We previously allowed up to 1 second, but in the CI jobs for dbus!9
and dbus!18 we've seen this take up to 3.4 seconds (presumably
because other tests, or other jobs running on the same shared
infrastructure, starved this process). Allow up to 10 seconds to guard
against spurious failures.

The timeout used in the production system.conf is 150 seconds (2½
minutes), and we're only using the shorter 500ms timeout here to make
the test complete more quickly, so ±10 seconds is relatively
insignificant: the main thing is that it's finite.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 20e6eb7cd1)
2018-11-16 15:09:06 +00:00
Simon McVittie
6cb51b22fa build: Never use poll() on Darwin family (macOS, etc.) or Interix
Doing a runtime check in configure.ac (AC_RUN_IFELSE) has several
disadvantages:

* It doesn't work when cross-compiling. For example, if we build macOS
  binaries on a Linux system, we'd assume that poll() works, but in
  fact it won't.

* It checks the build system capabilities, but that is not necessarily
  appropriate if (for example) a macOS 10.10 user builds binaries that
  could be used by macOS 10.12 or macOS 10.9 users.

* It checks for one specific failure mode, but macOS seems to have a
  history of various implementation issues in poll().

* If we want it to work in CMake, we have to duplicate it in the CMake
  build system.

None of these is a showstopper on its own, but the combination of all
of them makes the current approach to avoiding the broken poll() on
macOS look unreliable. libcurl, a widely-portable library making
extensive use of sockets, specifically doesn't use poll() on Darwin
(macOS, iOS, etc.) or on Interix; let's follow their example here.

See also https://bugzilla.gnome.org/show_bug.cgi?id=302672 and
https://daniel.haxx.se/blog/2016/10/11/poll-on-mac-10-12-is-broken/
for some relevant history.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/232
(cherry picked from commit 0414ea65ca)
2018-11-16 15:07:39 +00:00
Simon McVittie
a2a8510e8e Update NEWS 2018-10-05 12:34:38 +01:00
Simon McVittie
c21471dde5 ci: Use a separate ccache for each CI job
This should avoid them overwriting each other.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit e3fb085886)
2018-10-04 18:48:04 +01:00
Simon McVittie
6bae26d314 ci: Mark many Gitlab jobs to be run manually
freedesktop.org Gitlab doesn't currently have enough test runners
available to run all of this every time. For higher-risk changes
(for example those that change the build system) we can run the
complete set through the web UI.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit a2f416c289)
2018-10-04 18:47:43 +01:00
Simon McVittie
f4ce779c46 ci: Reshuffle mingw jobs so we test different combinations
We test the combinations that we don't test on Travis-CI.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit a6d926b805)
2018-10-04 18:47:42 +01:00
Simon McVittie
c5d71a1889 ci: Use ccache to speed up repeated builds
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit d0728fd06e)
2018-10-04 16:58:13 +01:00
Simon McVittie
5c204a9ee5 ci: Add Gitlab-CI configuration
This uses the same shell scripts as Travis-CI, with slightly different
settings. We use Docker containers for all our Gitlab-CI runs, so take
the opportunity to use Debian 9 'stretch' as our baseline, and
relegate Ubuntu 14.04 'trusty' to to a secondary build.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=108177
Acked-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit 60933c09e9)
2018-10-04 16:54:10 +01:00
Simon McVittie
6995c5ea5b ci: Explicitly install cmake
Travis-CI workers have cmake preinstalled, but Gitlab-CI Docker images
typically don't.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=108177
Acked-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit 907832e008)
2018-10-04 16:54:10 +01:00