Commit graph

6596 commits

Author SHA1 Message Date
Simon McVittie
079bbf1618 dbus-marshal-validate: Validate length of arrays of fixed-length items
This fast-path previously did not check that the array was made up
of an integer number of items. This could lead to assertion failures
and out-of-bounds accesses during subsequent message processing (which
assumes that the message has already been validated), particularly after
the addition of _dbus_header_remove_unknown_fields(), which makes it
more likely that dbus-daemon will apply non-trivial edits to messages.

Thanks: Evgeny Vereshchagin
Fixes: e61f13cf "Bug 18064 - more efficient validation for fixed-size type arrays"
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/413
Resolves: CVE-2022-42011
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-05 10:24:09 +01:00
Simon McVittie
67800ac5fe test-syntax: Exercise correctly- and incorrectly-nested structs, dicts
Reproduces: https://gitlab.freedesktop.org/dbus/dbus/-/issues/418
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-05 10:24:04 +01:00
Simon McVittie
9d07424e90 dbus-marshal-validate: Check brackets in signature nest correctly
In debug builds with assertions enabled, a signature with incorrectly
nested `()` and `{}`, for example `a{i(u}` or `(a{ii)}`, could result
in an assertion failure.

In production builds without assertions enabled, a signature with
incorrectly nested `()` and `{}` could potentially result in a crash
or incorrect message parsing, although we do not have a concrete example
of either of these failure modes.

Thanks: Evgeny Vereshchagin
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/418
Resolves: CVE-2022-42010
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-05 10:23:28 +01:00
Simon McVittie
1ecbbc3760 Merge branch 'no-abstract-tmpdir-2' into 'master'
dbus-server-socket: Make unix:tmpdir equivalent to unix:dir (while leaving unix:tmpdir as default)

Closes #416

See merge request dbus/dbus!350
2022-10-05 09:21:12 +00:00
Simon McVittie
8246113fb1 NEWS: Describe the behaviour change resulting from fixing dbus#416
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-02 11:43:30 +01:00
Simon McVittie
d1951de9b8 spec: Mention the consequences of abstract sockets when using namespaces
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-02 11:43:11 +01:00
Simon McVittie
4033dc5786 spec: Clarify that unix:tmpdir may create unix:path sockets even on Linux
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-02 11:42:30 +01:00
Simon McVittie
f01382ae31 dbus-server-socket: Make unix:tmpdir equivalent to unix:dir
On Linux, there are two classes of AF_UNIX socket, which D-Bus refers
to as unix:path=... (portable to non-Linux systems) and unix:abstract=...
(not portable).

Back in 2003 when dbus gained support for abstract Unix sockets on Linux,
everyone thought they were better in every way than path-based Unix
sockets: if a DBusServer crashes or is terminated abnormally, there's
no detritus left in the filesystem. What's not to like? As a result,
since commit a70b042f (2003-06-04), when a DBusServer listens on a
unix:tmpdir=... address on Linux, the default is for the result to be
a unix:abstract=... address, with unix:path=... addresses only used on
non-Linux platforms.

However, the world has changed in the last 19 years, and namespace-based
Linux containers (which didn't exist in 2003) are now very popular. This
makes abstract sockets problematic.

Abstract sockets are tied to the network namespace, which is
all-or-nothing: if a container is to access the Internet without using
some sort of proxy or intermediary (like slirp4netns) then it needs to
share the network namespace with the host system, and that implies
sharing all abstract sockets with the host system. If the well-known
session bus is listening on an abstract socket, then it's a sandbox
escape route for any sandboxed or containerized app running under the
same uid. Conversely, if a container is *not* sharing the network
namespace with the host system, then it cannot access a session bus that
is listening on an abstract socket without using some sort of proxy
(like xdg-dbus-proxy), even if it isn't intended to impose a security
boundary and giving it direct access to the session bus would have been
more desirable.

Path-based sockets do not have this problem because they exist in the
filesystem (part of the "everything is a file" Unix philosophy),
allowing mount namespaces and bind-mounts to be used to share or
unshare them selectively.

On systems with `systemd --user` where dbus has been configured with
`--enable-user-session`, in general the session bus will already be
using a path-based socket for the "user bus", disregarding the listening
address specified in /usr/share/dbus-1/session.conf. The default in many
recent Linux distributions is either to use dbus-daemon in this way, or
to use dbus-broker, a reimplementation of the message bus service which
has similar "user bus" behaviour.

However, the <listen> address in session.conf is used when dbus-launch(1)
or dbus-run-session(1) is used to start a session bus, either manually,
via autolaunching, or via system integration glue in operating systems
that are not using `systemd --user`. This will occur particularly often
in operating systems that boot using a non-systemd init system.

Making unix:tmpdir=/tmp equivalent to unix:dir=/tmp ensures that the
well-known session bus listens on a path-based socket, allowing container
and sandboxing frameworks to mediate access to it in the same way they
would for the user bus. The D-Bus Specification already allows (but does
not require) this behaviour, because it is the only thing that was
implementable on non-Linux systems such as *BSD.

This change has the potential to cause regressions. If a container
framework enters a chroot or unshares the mount namespace but does not
unshare the network namespace, and is relying on the ability for a
process inside a container to access the session bus outside the
container via its abstract socket, then that assumption will be broken
by this change. Some use cases of schroot(1) are likely to suffer from
this. However, container frameworks with that assumption would already
have found that it does not hold when using the user bus, and it is
necessary to break that assumption if we want it to be possible to apply
application-level sandboxing in a secure way.

Another potential regression from this change is that if a dbus-daemon
is terminated abnormally, it will leave a socket in /tmp. Distributors
of operating systems where heavy use of dbus-launch(1) is expected might
wish to run dbus-cleanup-sockets(1) periodically.

This partially reverts commit a70b042f.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/416
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-30 10:42:11 +01:00
Simon McVittie
b5172c3be1 Post-release version bump
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-22 13:53:25 +01:00
Simon McVittie
c4c521d37f maint: Make maintainer-upload-docs.sh executable
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-22 13:52:38 +01:00
Simon McVittie
79aae57357 maint: Make update-authors.sh executable when not going via a shell
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-22 13:52:24 +01:00
Simon McVittie
2770215f6c AUTHORS: Update
Result of:
./maint/update-authors.sh

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-22 12:27:57 +01:00
Simon McVittie
628e97d62d Prepare v1.15.0 (development-branch release)
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-22 12:17:27 +01:00
Simon McVittie
28e0a57262 Prepare spec v0.39
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-22 12:16:40 +01:00
Simon McVittie
361ecd7dc0 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-22 12:11:15 +01:00
Simon McVittie
ffbf053e2a Merge branch 'morello-support' into 'master'
Add support for building for Arm Morello

See merge request dbus/dbus!335
2022-09-21 11:52:02 +00:00
Alex Richardson
c5686f0c24 DBusMessageIter: ensure contiguous layout with 128-bit pointers
I am building DBus targeting the Arm Morello board and the "no padding"
layout assertion fails here since pointers require 16-byte alignment, and
therefore we have to add two additional ints to the DBusMessageIter struct.
As this is a new architecture, where DBus previously failed to compiled
we do not have any layout backwards compatibility requirements, so we can
simplify the DBusMessageIter structure to allocate space for 16 pointers
(which should give us a lot of space for any further changes).
2022-09-21 11:35:05 +00:00
Alex Richardson
6933a9263e dbus-message.c: skip 1.10 layout compatibility test on new architectures
These static assertions fail on CHERI-enabled architectures such as Arm
Morello, where pointers are 128 bits. Architectures with 128-bit pointers
were not supported in DBus 1.10, so we can skip the checks for DBus 1.10
structure layout compatibility for architectures with pointer size > 64 bit.
2022-09-21 11:35:05 +00:00
Alex Richardson
91f4ac9cf6 dbus-marshal-recursive.h: reduce padding in DBusType{Reader,Writer}
When building for Arm Morello (where pointers are 16 bytes), I hit the
static assertion that sizeof (DBusMessageRealIter) <= sizeof (DBusMessageIter)
inside _dbus_message_iter_init_common() otherwise. This can be fixed by
moving the pointers to the beginning of the struct to remove padding.
2022-09-21 11:35:05 +00:00
Alex Richardson
33dbeb5ebe dbus-mempool.c: ensure that all alignments are aligned to max_align_t
This is required e.g. for CHERI-enabled targets such as Arm Morello where
aligning to sizeof(long) is not sufficient to load/store pointers (which
need 16 byte alignment instead of 8 bytes).

As we can't depend on C11 yet, this commit adds a max_align_t emulation
to dbus-internals.h.
2022-09-21 11:35:05 +00:00
Alex Richardson
c4a8c2d920 dbus-mempool.c: use size_t for variables holding object sizes 2022-09-21 11:35:05 +00:00
Alex Richardson
464b51acde dbus-internals: use size_t in _DBUS_ALIGN_VALUE()
When targeting CHERI-enabled architectures such as Arm Morello, performing
a bitwise and with uintptr_t values can result in an ambiguous operation
compiler warning. Fix this warning by telling  compiler which operand is
(potentially) a pointer and which one is an integer by changing the
boundary type to size_t. This change has no functional effect on other
architectures but is required to build with -Werror for Morello.

Example warning message:
```
warning: binary expression on capability types 'unsigned __intcap' and 'unsigned __intcap'; it is not clear which should be used as the source of provenance; currently provenance is inherited from the left-hand side [-Wcheri-provenance]
  _dbus_assert (_DBUS_ALIGN_VALUE (insert_at, 8) == (unsigned) insert_at);
```
2022-09-21 11:35:05 +00:00
Alex Richardson
8c0d9709f3 clang-format: don't align escaped newlines in macro definitions 2022-09-21 11:35:05 +00:00
Alex Richardson
e2f3f0123c clang-format: add spaces before parens
Previously, clang-format was not adding a space after sizeof.
2022-09-21 11:35:05 +00:00
Simon McVittie
a225a9c41a Merge branch 'fix-freebsd-ci' into 'master'
gitlab-ci: update FreeBSD CI image to 13.1

See merge request dbus/dbus!347
2022-09-21 11:31:43 +00:00
Alex Richardson
93203e9524 gitlab-ci: update FreeBSD CI image to 13.1
FreeBSD 13.0 has reached EOL and it appears packages
are built against a newer baseline now, so we end up
with missing symbol errors:
ld-elf.so.1: /lib/libc.so.7: version FBSD_1.7 required by /usr/local/lib/libpython3.9.so.1.0 not found

It also appears that the fdpass test still fails on 13.1, so update the
condition to less than 14.0
2022-09-21 09:01:56 +00:00
Simon McVittie
546617d23c Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-19 10:45:01 +01:00
Simon McVittie
1c53a181ee Merge branch 'test-socket-dir' into 'master'
test: Use DBUS_TEST_SOCKET_DIR to create the test socket

See merge request dbus/dbus!334
2022-09-15 19:13:21 +00:00
Alex Richardson
e1ff3c09d7 test: Use DBUS_TEST_SOCKET_DIR to create the test socket
I am trying to run cross-compiled tests in QEMU with the build directory
mounted via smbfs, and therefore creating the sockets in the CWD does not
work. Using DBUS_TEST_SOCKET_DIR (/tmp by default) allows me to run the
tests successfully.
2022-09-15 18:58:20 +00:00
Alex Richardson
3b605a5a6d cmake: define DBUS_TEST_SOCKET_DIR in the config header
This matches autotools.
2022-09-15 18:22:49 +00:00
Alex Richardson
feff0333d5 meson: define DBUS_TEST_SOCKET_DIR in the config header
This matches autotools
2022-09-15 18:22:49 +00:00
Simon McVittie
6c9b4846b9 Merge branch 'mempool-flex-array-followup' into 'master'
mempool: Require C99 flexible arrays

See merge request dbus/dbus!344
2022-09-15 17:02:35 +00:00
Simon McVittie
57c9f99d78 mempool: Require C99 flexible arrays
dbus 1.15.x officially requires C99, so we can do this unconditionally
on the 1.15.x branch.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-15 16:46:59 +00:00
Simon McVittie
e2f7256bbe Merge branch 'mempool-flex-array' into 'master'
dbus-mempool: Use flexible or zero-length arrays if possible

See merge request dbus/dbus!343
2022-09-15 16:46:46 +00:00
Simon McVittie
374087124c dbus-mempool: Use flexible or zero-length arrays if possible
If the elements field has a fixed nonzero size, accessing elements
beyond that size is technically undefined behaviour, which is caught
by some options of the undefined behaviour sanitizer. Try to use a C99
flexible array, or failing that, a zero-length array (which is a popular
non-standard syntax to achieve the same thing).

dbus 1.15.x has C99 as a requirement, but this commit avoids assuming
C99 in order to make this change backportable to 1.14.x if it becomes
necessary to do so (for example to be able to run tests or fuzzers
against 1.14.x, or if compilers' defaults become more strict).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-15 15:26:58 +01:00
Simon McVittie
2ea6bdcab8 Update NEWS for 1.15.x branch
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-12 21:45:50 +01:00
Simon McVittie
9127b8ffa5 Merge branch 'msys2-packages' into 'master'
CI: Don't pin msys2 packages to a specific version at all

See merge request dbus/dbus!338
2022-09-12 19:19:49 +00:00
Simon McVittie
bb38fb361e CI: Don't pin msys2 packages to a specific version at all
Similar to dbus/dbus!286, but more so: just use the package names,
ignoring their version numbers completely.

pcre2 is not strictly needed at the moment, but it'll be a dependency
for GLib >= 2.73.x (older versions used pcre). For a bit of
future-proofing, download both pcre and pcre2.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-12 20:01:50 +01:00
Simon McVittie
9f9a01b1da Merge branch 'windows-no-tap' into 'master'
TAP-related workarounds in Meson build system

Closes #414

See merge request dbus/dbus!340
2022-09-12 19:00:27 +00:00
Simon McVittie
52a8adf901 test: Don't use strict TAP parsing on Windows
Debug messages in a background thread can corrupt the machine-readable
TAP output, and in particular GWin32AppInfo emits debug messages from
a background thread when we link to libgio.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/414
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-12 19:36:16 +01:00
Simon McVittie
c9d0f7968f build: Only work around Meson 0.63.0 bugs for version 0.63.0
mesonbuild/meson#10577 was fixed in 0.63.1.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-12 19:23:54 +01:00
Simon McVittie
031c2b1332 Merge branch 'fix/412' into 'master'
_dbus_message_iter_append_check: Fix ifdef check

Closes #412

See merge request dbus/dbus!336
2022-08-18 13:25:16 +00:00
Johannes Kauffmann
eb195d70d0 _dbus_message_iter_append_check: Fix ifdef check
With internal DBus checks disabled, but with assertions enabled, the
function would be ifdef'ed out. This is problematic, since the function
is called from within an assertion statement in _dbus_variant_write().

Fixes #412.

Co-authored-by: Simon McVittie <smcv@collabora.com>
2022-08-18 12:34:24 +00:00
Simon McVittie
7e0c51d800 Merge branch 'add-freebsd-ci' into 'master'
Add a FreeBSD CI job

See merge request dbus/dbus!280
2022-08-10 11:33:11 +00:00
Alex Richardson
468cc3e8ba Update NEWS to mention FreeBSD CI 2022-08-10 11:18:20 +00:00
Alex Richardson
31fd3822c3 Add myself to AUTHORS 2022-08-10 11:18:20 +00:00
Alex Richardson
82d5ee848d gitlab-ci: Add a FreeBSD meson job
Also bump the FDO_DISTRIBUTION_TAG to ensure the disk images
include meson.
2022-08-10 11:18:20 +00:00
Alex Richardson
ee880ef811 tools/ci-install.sh: Install meson build dependencies on FreeBSD
Python is already installed, but we need the python3 package to get the
/usr/local/bin/python3 symlink rather than the one with the version suffix.
2022-08-10 11:18:20 +00:00
Alex Richardson
932b740826 test/fdpass.c: skip test that fails on FreeBSD 13.0
The /odd-limit/at test passes on 13.1 and 14.0 images, but fails on 13.1.
Debugging has not given me any useful hints why this may be the case, so
disable this test on 13.0 for now.

This allows us to drop the ci_test_fatal: "no" override which will ensure
that any FreeBSD regressions are caught.
2022-08-10 11:18:20 +00:00
Alex Richardson
1378e8e37e gitlab-ci: Add a FreeBSD autotools CI job
Now that the underlying issues with FreeBSD autotools CI have been fixed,
we can add a CI job to prevent future regressions.
2022-08-10 11:18:20 +00:00