Commit e79c319a authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Fix missing lock annotation errors in mach_port_rendezvous_fuzzer.cc.

This target was missed in 2585915c. The
CL also adds additional locking annotations to MachPortRendezvousServer.

Bug: 1106353, 1013082
Change-Id: Id2fe4f707dc90efd79c0354de73e5066b8715713
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302942Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789183}
parent 1d7dff33
......@@ -20,6 +20,7 @@
#include "base/mac/scoped_mach_port.h"
#include "base/macros.h"
#include "base/synchronization/lock.h"
#include "base/thread_annotations.h"
namespace base {
......@@ -90,7 +91,8 @@ class BASE_EXPORT MachPortRendezvousServer {
// until the process known by |pid| has either acquired the ports or died.
//
// This must be called with the lock from GetLock() held.
void RegisterPortsForPid(pid_t pid, const MachPortsForRendezvous& ports);
void RegisterPortsForPid(pid_t pid, const MachPortsForRendezvous& ports)
EXCLUSIVE_LOCKS_REQUIRED(GetLock());
// Returns a lock on the internal port registration map. The parent process
// should hold this lock for the duration of launching a process, including
......@@ -98,7 +100,7 @@ class BASE_EXPORT MachPortRendezvousServer {
// cannot race acquiring ports before they are registered. The lock should
// be released after the child process is launched and the ports are
// registered.
Lock& GetLock() { return lock_; }
Lock& GetLock() LOCK_RETURNED(lock_) { return lock_; }
private:
friend class MachPortRendezvousServerTest;
......
......@@ -25,7 +25,8 @@ struct MachPortRendezvousFuzzer {
server_send_right.reset(port);
}
void ClearClientData() {
void ClearClientData() EXCLUSIVE_LOCKS_REQUIRED(
base::MachPortRendezvousServer::GetInstance()->GetLock()) {
base::MachPortRendezvousServer::GetInstance()->client_data_.clear();
}
......@@ -38,10 +39,10 @@ DEFINE_BINARY_PROTO_FUZZER(const mach_fuzzer::MachMessage& message) {
static base::MachPortRendezvousFuzzer environment;
{
auto* server = base::MachPortRendezvousServer::GetInstance();
base::AutoLock lock(server->GetLock());
base::AutoLock lock(
base::MachPortRendezvousServer::GetInstance()->GetLock());
environment.ClearClientData();
server->RegisterPortsForPid(
base::MachPortRendezvousServer::GetInstance()->RegisterPortsForPid(
getpid(), {std::make_pair(0xbadbeef, base::MachRendezvousPort{
mach_task_self(),
MACH_MSG_TYPE_COPY_SEND})});
......
......@@ -292,9 +292,10 @@ Process LaunchProcess(const std::vector<std::string>& argv,
&argv_cstr[0], new_environ);
if (has_mach_ports_for_rendezvous) {
auto* rendezvous = MachPortRendezvousServer::GetInstance();
if (rv == 0) {
rendezvous->RegisterPortsForPid(pid, options.mach_ports_for_rendezvous);
MachPortRendezvousServer::GetInstance()->GetLock().AssertAcquired();
MachPortRendezvousServer::GetInstance()->RegisterPortsForPid(
pid, options.mach_ports_for_rendezvous);
} else {
// Because |options| is const-ref, the collection has to be copied here.
// The caller expects to relinquish ownership of any strong rights if
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment