Commit graph

6296 commits

Author SHA1 Message Date
Simon McVittie
7e196cad5a Merge branch '1.14-issue343' into 'dbus-1.14'
[1.14] bus: Don't crash if bus_context_create_client_policy() fails

See merge request dbus/dbus!437
2023-08-18 15:58:47 +00:00
Peter Benie
1c06c16bd5 bus: Don't crash if bus_context_create_client_policy() fails
If policy creation fails, we can't usefully leave a NULL policy in the
BusConnectionData. If we did, the next attempt to reload policy would
crash with a NULL dereference when we tried to unref it, or with
an assertion failure.

One situation in which we can legitimately fail to create a client policy
is an out-of-memory condition. Another is if we are unable to look up a
connection's supplementary groups with SO_PEERGROUPS, and also unable to
look up the connection's uid's groups in the system user database, for
example because it belongs to a user account that has been deleted (which
is sysadmin error, but can happen, particularly in automated test systems)
or because a service required by a Name Service Switch plugin has failed.

Keeping the last known policy is consistent with what happens to all
the connections that are after this one in iteration order: after we
early-return, all of those connections retain their previous policies
(which doesn't seem ideal either, but that's how this has always worked).

[smcv: Add commit message]
Co-authored-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/343

(cherry picked from commit 63522f2887)
2023-08-18 15:58:20 +01:00
Simon McVittie
8bd071a911 Merge branch '1.14-empty-group-list' into 'dbus-1.14'
Backport dbus!422 to 1.14.x

See merge request dbus/dbus!434
2023-08-18 12:35:32 +00:00
Simon McVittie
43ffc79df8 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-16 11:31:27 +01:00
cptpcrd
fa7eaefe7c dbus-sysdeps-unix: Check socklen_t is unsigned when getting group list
After the change to handle an empty list properly, the function now
assumes that is true.

(cherry picked from commit 49dd4aba42)
2023-08-16 11:29:50 +01:00
cptpcrd
8a98ef62b0 dbus-sysdeps-unix: Handle empty supplementary group list
It is valid for getsockopt(SO_PEERGROUPS) to return len=0; that
indicates the process has no supplementary groups. Rather than failing,
simply use the returned empty list (and add the primary GID to it).

Without this change, calling GetConnectionCredentials on a bus name
owned by a process with no supplementary groups does not return the
UnixGroupIDs field, even though it is easy to determine that the process
only has one GID (the primary GID).

(cherry picked from commit f8a7bffd5e)
2023-08-16 11:29:45 +01:00
Simon McVittie
f9b5bf68ab Start towards dbus 1.14.10
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-06 17:56:41 +01:00
Simon McVittie
f90d4f1693 Release v1.14.8
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-06 13:57:58 +01:00
Simon McVittie
21414587d5 AUTHORS: Update
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-06 13:47:50 +01:00
Simon McVittie
f99e5de1ac Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 05367daa10)
2023-06-06 12:03:38 +01:00
Simon McVittie
39b5c61701 monitor test: Reproduce dbus/dbus#457
The exact failure mode reported in dbus/dbus#457 is quite difficult
to achieve in a reliable way in a unit test, because we'd have to send
enough messages to a client to fill up its queue, then stop that client
from draining its queue, while still triggering a message that gets a
reply from the bus driver. However, we can trigger the same crash in a
slightly different way by not allowing the client to receive a
particular message. I chose NameAcquired.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 986611ad0f)
2023-06-06 12:03:17 +01:00
hongjinghao
a70c8f2fbc bus: Assign a serial number for messages from the driver
Normally, it's enough to rely on a message being given a serial number
by the DBusConnection just before it is actually sent. However, in the
rare case where the policy blocks the driver from sending a message
(due to a deny rule or the outgoing message quota being full), we need
to get a valid serial number sooner, so that we can copy it into the
DBUS_HEADER_FIELD_REPLY_SERIAL field (which is mandatory) in the error
message sent to monitors. Otherwise, the dbus-daemon will crash with
an assertion failure if at least one Monitoring client is attached,
because zero is not a valid serial number to copy.

This fixes a denial-of-service vulnerability: if a privileged user is
monitoring the well-known system bus using a Monitoring client like
dbus-monitor or `busctl monitor`, then an unprivileged user can cause
denial-of-service by triggering this crash. A mitigation for this
vulnerability is to avoid attaching Monitoring clients to the system
bus when they are not needed. If there are no Monitoring clients, then
the vulnerable code is not reached.

Co-authored-by: Simon McVittie <smcv@collabora.com>
Resolves: dbus/dbus#457
(cherry picked from commit b159849e03)
2023-06-06 12:03:17 +01:00
Simon McVittie
40c0802f0b monitor test: Log the messages that we monitored
This is helpful while debugging test failures.

Helps: dbus/dbus#457
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 8ee5d3e044)
2023-06-06 12:03:17 +01:00
Simon McVittie
e1ffce1767 Revert "CI: Remove an obsolete workaround"
It appears some freedesktop CI runners still have /builds/dbus/dbus
owned by a different user ID.
This reverts commit 3f6400b8b9.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-06 11:01:49 +01:00
Simon McVittie
8e45729621 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-05 20:01:19 +01:00
Barnabás Pőcze
5c3a4e81f2 dbus-spawn-win: use _DBUS_FUNCTION_NAME instead of __FUNCTION__
dbus-internals.h already defines a macro which expands to the name
of the current function based on C standard version, etc. So use
that instead of hard-coding `__FUNCTION__`.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
2023-06-05 19:58:49 +01:00
Barnabás Pőcze
8df1b8be83 dbus-sysdeps-win: do not log function name twice
`_dbus_verbose()` already logs the function name,
do not log it again in the message.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
2023-06-05 19:58:41 +01:00
Barnabás Pőcze
0bb1942ef6 dbus-internals: use _DBUS_FUNCTION_NAME in _dbus_verbose()
dbus-internals.h already defines a macro which expands to the name
of the current function based on C standard version, etc. So use
that instead of hard-coding `__FUNCTION__`.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
2023-06-05 19:58:29 +01:00
Barnabás Pőcze
45e6e93e30 dbus_message_iter_get_signature: Fix two memory leaks on OOM
Previously,  `retstr` would not be freed when `_dbus_string_append_len()`
or `_dbus_string_steal_data()` failed.

Fix those by:
 * jumping to `_dbus_string_free()` when `_dbus_string_append_len()` fails
 * ignoring the return value of `_dbus_string_free()`.

The latter works because in case of failure, `ret` will be set
to NULL by `_dbus_string_steal_data()`.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
2023-06-05 19:57:25 +01:00
Simon McVittie
ec708d5509 CI: Avoid using a no-op download location that gives a 403 error
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-05 19:56:51 +01:00
Simon McVittie
07fe44f4c2 CI: Update Windows runners
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-05 19:54:20 +01:00
Simon McVittie
077f7e43f8 CI: Remove an obsolete workaround
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-05 19:52:50 +01:00
Simon McVittie
9e0477fc17 CI: Only run for pushes to dbus
In practice the pipeline is going to fail for namespaces other than
dbus, so don't waste time on trying to run it there; only run the
detached pipeline for the MR.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-05 19:52:15 +01:00
Simon McVittie
a96f417fe5 CI: Run a detached pipeline for merge requests
After abuses of fdo infrastructure were mitigated in
freedesktop/freedesktop#540, contributors cannot usually run pipelines
in their own forks of dbus.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-05 19:52:08 +01:00
Yen-Chin, Lee
55d11f579d doc/dbus-api-design: fix wrong closing tag
The original code of 'ProgressNotification' had a wrong closing tag,
which should use '</signal>' instead of '</method>'

Signed-off-by: Yen-Chin, Lee <coldnew.tw@gmail.com>
2023-06-05 19:51:09 +01:00
Simon McVittie
d3e33728c2 Start 1.14.8
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-08 16:53:00 +00:00
Simon McVittie
ab6d0f50be Update AUTHORS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-08 16:51:47 +00:00
Simon McVittie
d4942f417b Prepare v1.14.6
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-08 12:04:12 +00:00
Simon McVittie
a2cda736e4 NEWS: Add #421
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-08 12:04:12 +00:00
Ralf Habacker
27581805e1 _dbus_string_skip_blank(): Let the final assert follow the previous search
This appears to have been a copy/paste mistake. If only blanks (defined as
spaces or tabs) were removed, then it cannot be right to check for white
space (defined as spaces, tabs, carriage return or linefeed) afterwards.

If libdbus was compiled with assertions enabled, then this is a
denial-of-service issue for dbus-daemon or other users of DBusServer:
an unauthenticated user with access to the server's socket can send
whitespace that triggers this assertion failure. We recommend that
production versions of dbus, for example in OS distributions, should be
compiled with checks but without assertions.

[smcv: expanded commit message]

Thanks: Evgeny Vereshchagin
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/421
2023-02-08 12:04:12 +00:00
Ralf Habacker
fb08b875e8 Add test for _dbus_string_skip_blank()
[smcv: Fix a memory leak]

Reproduces: https://gitlab.freedesktop.org/dbus/dbus/-/issues/421
2023-02-08 12:04:09 +00:00
Simon McVittie
2e42fd18af Merge branch 'dbus-1.14' into 'dbus-1.14'
[1.14.x] Backport more fixes from 1.15.x

See merge request dbus/dbus!393
2023-02-08 10:47:08 +00:00
Simon McVittie
e8d25bdcdf Update NEWS for 1.14.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-08 10:32:12 +00:00
Dave Jones
849382fe6d Permit access to /tmp dbus socket
After 6e48c317 the test-apparmor-activation test fails as it can no
longer access the dbus socket in /tmp. This commit updates the apparmor
profile used within the test

(cherry picked from commit 9950464761)
2023-02-08 10:31:30 +00:00
Marco Trevisan (Treviño)
b5638c9882 cleanup: Use gitlab URI for bug reporting
Bugzilla is dead for long time now.

(cherry picked from commit dc59aa5df2)
2023-02-08 10:30:57 +00:00
Simon McVittie
cecb222d1a m4: Stop shipping our own copy of pkg.m4
The canonical way to find these macro is to run autogen.sh or autoreconf
while pkg-config (or pkgconf) is installed, which will copy an up-to-date
version of the macros from /usr/share/aclocal. The `make dist` archive
will include a bundled copy of those macros, but the git repository
doesn't need them.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-08 10:11:50 +00:00
Jeremi Piotrowski
c7ab8552ad bus/selinux: Move vsnprintf call to avoid va_list reuse
In log_callback() the same va_list is reused for a call to vsnprintf and
vsyslog. A va_list can't be reused in this manner, such use is undefined
behavior that changes depending on glibc version.

In current glibc versions a segfault can be observed from the callsite at
bus/selinux.c:412. When trying to log a non-auditable event, the segfault
happens in strlen inside vsyslog.

Moving the call to vsnprintf closer to audit_log_user_avc_message (which is
followed by a 'goto out') avoids the reuse and segfault.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
(cherry picked from commit 52b73d511b)
2023-02-08 10:09:44 +00:00
Simon McVittie
ff71375661 CI: Re-run some tests as root or as non-root, as appropriate
On Gitlab-CI we're always running the overall script as root (and
therefore we'll only enter the code path to re-run as non-root),
but when using these scripts for manual testing they might be run as
non-root to begin with.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 25e1512c17)
2023-02-08 10:05:20 +00:00
Simon McVittie
e5ac506ccd CI: Remove vestigial support for re-running tests in a Docker container
Travis CI needed this, but Gitlab-CI always runs our tests in a Docker
container of our choice, so there's never any need to enter another
(and it's not allowed anyway).

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit dfa7eede44)
2023-02-08 10:05:14 +00:00
Simon McVittie
fef150bbe4 CI: Re-clone the git repository every time
This cleans up checkouts that were subjected to `chown -R` prior to this.

Resolves: dbus/dbus#447
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit ce6af6721f)
2023-02-08 10:04:12 +00:00
Simon McVittie
5e49913450 CI: Don't change ownership of source directory
These CI scripts were originally used on Travis-CI, which starts all
builds as an ordinary user that has the ability to become root via `sudo`.
On Gitlab-CI, we don't need that: we start as uid 0, and can do the
whole CI run like that. This also means we get somewhat better test
coverage, because some of our unit tests benefit from being run as uid 0.

The only test coverage we lose by being uid 0 is that
test_pending_fd_timeout() in test/dbus-daemon.c is skipped, because
uid 0 bypasses the limit that's under test there.

(cherry picked from commit 88dd9d5cc7)
2023-02-08 10:03:47 +00:00
Khem Raj
e2aa409219 Define _DBUS_ALIGNOF using _Alignof when using C11 or newer
WG14 N2350 made very clear that it is an UB having type definitions
within "offsetof" [1]. This patch changes the implementation of macro
_DBUS_ALIGNOF to builtin "_Alignof" to avoid undefined behavior.

clang 16+ has started to diagnose this [2]

Fixes build when using -std >= gnu11 and using clang16+

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm
[2] https://reviews.llvm.org/D133574

Signed-off-by: Khem Raj <raj.khem@gmail.com>
(cherry picked from commit c3e2c873ff)
2023-02-08 10:03:39 +00:00
Simon McVittie
c422950a31 Update NEWS for 1.14.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-01-30 10:00:47 +00:00
Simon McVittie
d9fcc508f2 Merge branch '1.14-backports' into 'dbus-1.14'
[1.14.x] Backport: Fix data race with members of struct DBusCounter

See merge request dbus/dbus!384
2023-01-09 12:45:44 +00:00
Ralf Habacker
68bd64d63c Fix data race in multithreaded application
This commit fixes a data race condition discovered by the
gcc thread sanitizer by also locking the associated mutex
when reading the corresponding counter.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/426
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
(cherry picked from commit 1741df3b97)
2023-01-07 10:31:45 +01:00
Ralf Habacker
9155d36905 Add multithreaded unit test for DBusCounter to available build systems
The mentioned test is build on unix like platforms when embedded tests
are enabled.

(cherry picked from commit 20febb522b)
[backport to 1.14.x: adjust included header]
2023-01-07 10:30:59 +01:00
Simon McVittie
79f7fcab69 Merge branch '1.14-backports' into 'dbus-1.14'
[1.14.x] Backport fixes from master

See merge request dbus/dbus!362
2022-10-11 15:58:07 +00:00
Simon McVittie
dbb1b8f5e6 Update NEWS for 1.14.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-11 14:36:22 +01:00
Evgeny Vereshchagin
de9e130207 config-parser: no longer get past the last NULL passed to locate_attributes
Fixes: bc86794f23
Fixes:
```
==302818==ERROR: AddressSanitizer: stack-buffer-underflow on address 0x7ffd6ac253c0 at pc 0x000000534d0b bp 0x7ffd6ac24e10 sp 0x7ffd6ac24e08
READ of size 8 at 0x7ffd6ac253c0 thread T0
    #0 0x534d0a in locate_attributes /home/vagrant/dbus/build/../bus/config-parser.c:658:16
    #1 0x52ea3f in start_busconfig_child /home/vagrant/dbus/build/../bus/config-parser.c:1080:12
    #2 0x52cca4 in bus_config_parser_start_element /home/vagrant/dbus/build/../bus/config-parser.c:2039:14
    #3 0x52b82b in expat_StartElementHandler /home/vagrant/dbus/build/../bus/config-loader-expat.c:107:8
    #4 0x7f2179f2d2bd  (/lib64/libexpat.so.1+0xd2bd) (BuildId: 0165eed77c910f6ef2227d21afa9c5c5ed5849c2)
    #5 0x7f2179f2aed3  (/lib64/libexpat.so.1+0xaed3) (BuildId: 0165eed77c910f6ef2227d21afa9c5c5ed5849c2)
    #6 0x7f2179f2c9ec  (/lib64/libexpat.so.1+0xc9ec) (BuildId: 0165eed77c910f6ef2227d21afa9c5c5ed5849c2)
    #7 0x7f2179f30a8e in XML_ParseBuffer (/lib64/libexpat.so.1+0x10a8e) (BuildId: 0165eed77c910f6ef2227d21afa9c5c5ed5849c2)
    #8 0x52b040 in bus_config_load /home/vagrant/dbus/build/../bus/config-loader-expat.c:259:9
    #9 0x523c8a in bus_context_new /home/vagrant/dbus/build/../bus/bus.c:828:12
    #10 0x521056 in main /home/vagrant/dbus/build/../bus/main.c:716:13
    #11 0x7f2179a2954f in __libc_start_call_main (/lib64/libc.so.6+0x2954f) (BuildId: 9c5863396a11aab52ae8918ae01a362cefa855fe)
    #12 0x7f2179a29608 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x29608) (BuildId: 9c5863396a11aab52ae8918ae01a362cefa855fe)
    #13 0x42a914 in _start (/home/vagrant/dbus/build/bus/dbus-daemon+0x42a914) (BuildId: df5369f85137975aff9bd398ae859706cc3c52ff)

Address 0x7ffd6ac253c0 is located in stack of thread T0 at offset 0 in frame
    #0 0x52cfaf in start_busconfig_child /home/vagrant/dbus/build/../bus/config-parser.c:733
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
(cherry picked from commit ae03bcdb11)
2022-10-11 14:35:22 +01:00
Simon McVittie
7a0f050a54 dbus-message: Report OOM as OOM, not InvalidArgs
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/420
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 3c0e63c10a)
2022-10-11 14:35:22 +01:00