New issue
Advanced search Search tips

Issue 874978 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Aug 17
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug



Sign in to add a comment

Chrome takes ownership of D-Bus service names before exporting methods

Project Member Reported by derat@chromium.org, Aug 16

Issue description

As discussed in http://b/112468968#comment17, it looks like Chrome's chromeos::CrosDBusService class's Start method calls dbus::Bus::RequestOwnership before giving ServiceProviderInterface implementations a chance to export methods:

chromeos/dbus/services/cros_dbus_service.cc:

 42   // Starts the D-Bus service.
 43   void Start() {
...
 57     bus_->RequestOwnership(
 58         service_name_, dbus::Bus::REQUIRE_PRIMARY_ALLOW_REPLACEMENT,
 59         base::Bind(&CrosDBusServiceImpl::OnOwnership, base::Unretained(this)));
 60 
 61     exported_object_ = bus_->GetExportedObject(object_path_);
 62     for (size_t i = 0; i < service_providers_.size(); ++i)
 63       service_providers_[i]->Start(exported_object_);

This creates a window where the service name is owned but the methods are not yet exported. If other D-Bus clients try to call methods in response to the ownership change, their calls may fail due to the methods not existing. powerd made this mistake at one point too ( issue 331431 ).

I think that this method should be changed so that methods are exported before RequestOwnership is called.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Aug 17

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c269f2e60425aa21c6f32c20f496095b3bc27330

commit c269f2e60425aa21c6f32c20f496095b3bc27330
Author: Daniel Erat <derat@chromium.org>
Date: Fri Aug 17 21:18:10 2018

chromeos: Export D-Bus methods before owning services.

Update chromeos::CrosDBusService::Start to call
ServiceProviderInterface::Start methods (which export
methods) before calling dbus::Bus::RequestOwnership.
Otherwise, there's a brief window of time where other D-Bus
clients may attempt to call methods before they're
available.

Bug:  874978 
Change-Id: I69bc36e465e8086921b67122514f2607399ea33d
Reviewed-on: https://chromium-review.googlesource.com/1178757
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Commit-Queue: Dan Erat <derat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584190}
[modify] https://crrev.com/c269f2e60425aa21c6f32c20f496095b3bc27330/chromeos/dbus/services/cros_dbus_service.cc
[modify] https://crrev.com/c269f2e60425aa21c6f32c20f496095b3bc27330/chromeos/dbus/services/cros_dbus_service_unittest.cc

Status: Fixed (was: Started)

Sign in to add a comment