Commit graph

5294 commits

Author SHA1 Message Date
Ralf Habacker
331e05dc5d Move installing packages into tools/ci-install.sh
In tools/ci-build.sh the cross compile setup has to be moved further up
to match the correct subdirectory.

(cherry picked from commit 1e3d82d85e)
2022-02-25 13:16:55 +00:00
Simon McVittie
99523f3535 CI: Do the CMake native debug build from an Autotools make dist
We officially release dbus in the form of Autotools `make dist` tarballs,
but people who have downloaded those tarballs should be able to choose
the CMake build system. Our CI should assert that they can.

(The Autotools debug build already does a `make distcheck`, which
asserts that tarball releases can be used for an Autotools build.)

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: dbus#255
(cherry picked from commit 1063bba06b)
[backport for 1.12.x: in 1.12.x, `make dist` produces .tar.gz]
2022-02-25 13:16:52 +00:00
Simon McVittie
47018f5c3c CI: Install yelp-tools, for yelp-build, in recent distros
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 78efbb6c0d)
2022-02-25 13:04:20 +00:00
Simon McVittie
074934f18d CI: Make adduser properly non-interactive
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 52fcc82379)
2022-02-25 13:04:20 +00:00
Simon McVittie
52c881487d CI: Don't install weak dependencies (Recommends)
In particular this avoids installing the TeX toolchain.

However, this also means we don't install dbus, which broke some tests
in minimal containers where dbus wasn't already installed, because the
messagebus user wouldn't have been created. Make sure that user exists,
using the same adduser call as the Debian dbus package.

CMake really wants to find a C++ compiler (even though we only use C++
when compiling for Windows), so explicitly install the default
version of the GNU C++ compiler, g++.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit cb6abc6391)
2022-02-25 13:04:20 +00:00
Simon McVittie
787b9e9633 ci: Teach ci-install.sh to install wine on Debian 9 'stretch'
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 408b222a9f)
2022-02-25 13:04:20 +00:00
Simon McVittie
d1799f782b ci-build: Update required MSYS packages
The older versions we were previously building against are no longer
available on mirrors.

Based on changes proposed in !189 by Arnout Engelen, and the package
list gathered by Ralf Habacker in #318.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/318
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 053238254e)
2022-02-25 13:04:20 +00:00
Simon McVittie
38f77d4ebe CI: Add ci_variant parameter
Originally part of commit 23e1f044 "Install qhelpgenerator for native
production build on buster". Later CI fixes rely on having this
available.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-25 13:04:16 +00:00
Simon McVittie
9c1c573041 Belatedly bump version number to 1.12.21 for development
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-12-17 13:01:10 +00:00
Simon McVittie
f6e894efd5 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-12-17 13:00:49 +00:00
Simon McVittie
b44e0cc9f4 internals: Use Standard C offsetof macro if available
clang 13 fails to compile our current implementation with:

.../dbus/dbus-message.c:2070:3: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]
  _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (DBusMessageRealIter) <=
  ^
.../dbus/dbus-internals.h:460:25: note: expanded from macro '_DBUS_STATIC_ASSERT'
  typedef struct { char _assertion[(expr) ? 1 : -1]; } \

This appears to be because the "traditional" definition of
offsetof(), which we're hard-coding here, does not qualify as a constant
expression under C rules due to its use of pointer casts.

Modern compilers like gcc and clang have a built-in implementation
of offsetof that *is* a constant expression.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit a24cf746e2)
2021-12-17 12:57:42 +00:00
Jean-Louis Fuchs
d13349f25c disable fork-malloc-exec for non-glibc-systems
Calling malloc() after fork is undefined behaviour if the process is
multi-threaded. locks held by a thread on fork() will never be released.
malloc() is usally protected by a lock and can therefore deadlock. glibc
is known not to deadlock in this case.

This commit does not rule out other problems on glibc-systems, but fixes an
issue on musl-libc-systems. Only restricting to async-signal safe functions
between fork() and exec() prevents undefined behaviour for sure. See
signal-safety(7).

(cherry picked from commit 3fab06d68f)
2021-12-17 12:55:33 +00:00
Simon McVittie
ac6e6cb68a doc: Don't include TODO list in API documentation
This is sorted non-deterministically, which is undesired for reproducible
builds, and is not really part of the API in any case.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit ce8d7759a2)
2021-12-17 12:54:40 +00:00
Arnout Engelen
91e0c5f0cc docs: generate reproducible ids
With this parameter, docbook will generate the same id's when generating the
same docs. This is helpful to get bit-by-bit 'reproducible' output, which
makes auditing the package easier.

(cherry picked from commit 43e0188dbf)
2021-12-17 12:54:28 +00:00
William Earley
73aa7f9739 dbus-launch: Replace slashes in DISPLAY if present
dbus-daemon fails to autolaunch with X11 on macOS 10.8+ because XQuartz
(the X11 package for macOS) provides a value for `$DISPLAY` that is
not expected by dbus, in that it contains `/` characters. This is
addressed by replacing the invalid path character `/` with `_`.

Resolves: #8
Resolves: #311
(cherry picked from commit 3545d0f4de)
2021-12-17 12:53:26 +00:00
William Earley
7dc84fd22b sysdeps: Don't raise RLIMIT_NOFILE beyond OPEN_MAX on macOS
dbus-daemon fails to launch on macOS 10.5 and above because of a breaking
change in setrlimit, in which RLIM_INFINITY is no longer supported
for RLIMIT_NOFILE. Instead we must use OPEN_MAX.

Resolves: #309
(cherry picked from commit 691946dabc)
2021-12-17 12:53:06 +00:00
Simon McVittie
2c5c9a750d Reference CVE-2020-35512 in NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-07 11:56:04 +00:00
Simon McVittie
c634f085f7 Merge branch 'cherry-pick-f0e526bc' into 'dbus-1.12'
tests: On Unix, include <netinet/in.h> for IPPROTO_TCP

See merge request dbus/dbus!168
2020-08-14 16:14:32 +00:00
Simon McVittie
c9281ef5a9 tests: On Unix, include <netinet/in.h> for IPPROTO_TCP
Otherwise, dbus doesn't compile on FreeBSD if the GLib-based tests
are enabled (which suggests that no FreeBSD user has run those tests
successfully).

We already include <netinet/in.h> in other places with no conditions
or checks other than "is Unix", so apparently it's portable enough that
specifically testing for its presence is not necessary. POSIX requires it
to exist.

Signed-off-by: Simon McVittie <smcv@collabora.com>


(cherry picked from commit f0e526bca8)
2020-08-14 16:03:51 +00:00
Simon McVittie
ab88811768 v1.12.20
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-07-02 11:10:00 +01:00
Simon McVittie
5757fd5480 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-07-02 10:25:04 +01:00
Simon McVittie
f3b2574f0c userdb: Reference-count DBusUserInfo, DBusGroupInfo
Previously, the hash table indexed by uid (or gid) took ownership of the
single reference to the heap-allocated struct, and the hash table
indexed by username (or group name) had a borrowed pointer to the same
struct that exists in the other hash table.

However, this can break down if you have two or more distinct usernames
that share a numeric identifier. This is generally a bad idea, because
the user-space model in such situations does not match the kernel-space
reality, and in particular there is no effective kernel-level security
boundary between such users, but it is sometimes done anyway.

In this case, when the second username is looked up in the userdb, it
overwrites (replaces) the entry in the hash table that is indexed by
uid, freeing the DBusUserInfo. This results in both the key and the
value in the hash table that is indexed by username becoming dangling
pointers (use-after-free), leading to undefined behaviour, which is
certainly not what we want to see when doing access control.

An equivalent situation can occur with groups, in the rare case where
a numeric group ID has two names (although I have not heard of this
being done in practice).

Solve this by reference-counting the data structure. There are up to
three references in practice: one held temporarily while the lookup
function is populating and storing it, one held by the hash table that
is indexed by uid, and one held by the hash table that is indexed by
name.

Closes: dbus#305
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 2b7948ef90)
2020-07-02 10:08:49 +01:00
Simon McVittie
37b36d49a6 userdb: Make lookups return a const pointer
This makes it more obvious that the returned pointer points to a
struct owned by the userdb, which must not be freed or have its
contents modified, and is only valid to dereference until the next
modification to the userdb's underlying hash tables (which in practice
means until the lock is released, because after that we have no
guarantees about what might be going on in another thread).

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 6ee66ff7bc)
2020-07-02 10:08:45 +01:00
Andy Fiddaman
732284d530 Solaris and derivatives do not adjust cmsg_len on MSG_CTRUNC
(cherry picked from commit b96ef23e40)
2020-07-02 10:08:39 +01:00
Simon McVittie
1f8c42c7cd Start 1.12.20 development
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-02 20:57:39 +01:00
Simon McVittie
a0926ef86f Prepare 1.12.18
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-02 12:18:39 +01:00
Simon McVittie
8bc1381819 fdpass test: Assert that we don't leak file descriptors
This version is for the dbus-1.12 branch, and doesn't rely on dbus!153
or dbus!120.

Reproduces: dbus#294
Reproduces: CVE-2020-12049
Reproduces: GHSL-2020-057
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-02 10:43:39 +01:00
Simon McVittie
272d484283 sysdeps-unix: On MSG_CTRUNC, close the fds we did receive
MSG_CTRUNC indicates that we have received fewer fds that we should
have done because the buffer was too small, but we were treating it
as though it indicated that we received *no* fds. If we received any,
we still have to make sure we close them, otherwise they will be leaked.

On the system bus, if an attacker can induce us to leak fds in this
way, that's a local denial of service via resource exhaustion.

Reported-by: Kevin Backhouse, GitHub Security Lab
Fixes: dbus#294
Fixes: CVE-2020-12049
Fixes: GHSL-2020-057
2020-06-02 10:43:16 +01:00
Simon McVittie
31297172f1 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-05-15 11:24:14 +01:00
Simon McVittie
041d579139 dbus-daemon test: Don't test fd limits if in an unprivileged container
In an unprivileged container, uid 0 doesn't have CAP_SYS_RESOURCE, so
we can't expect the dbus-daemon to be able to escalate its fd limit.

This can be reproduced using bubblewrap:

    sudo bwrap \
        --cap-drop CAP_SYS_RESOURCE \
        --ro-bind / / \
        --dev /dev \
    env \
        DBUS_TEST_DAEMON=.../bus/dbus-daemon \
        DBUS_TEST_DATA=.../test/data \
    .../test/test-dbus-daemon \
        -p /fd-limit \
        --verbose

Bug-Debian: https://bugs.debian.org/908092
2020-05-15 11:23:15 +01:00
Simon McVittie
55b3f71376 Update NEWS 2020-04-20 20:40:02 +01:00
Felipe Franciosi
ced04aabc7 doxygen: fix example for dbus_message_append_args
Commit 724adb2f6 mangled the dbus_message_append_args() code example.
This fixes it by breaking the lines and aligning at the right places.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2020-04-20 20:06:41 +01:00
Simon McVittie
3e40637b10 Update NEWS 2020-04-20 20:05:28 +01:00
Tuomo Rinne
3e0ea34966 cmake: Add X11 include path for tools
Fixes compilation issues for case when X11 is not in a standard location
2020-04-20 19:34:29 +01:00
Christopher Morin
d0992805d7 doc: replace dbus-send's --address with --peer and --bus
See merge request dbus/dbus!115

(cherry picked from commit fd41caa366)
2020-04-20 19:29:37 +01:00
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