Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(717)

Unified Diff: mojo/edk/system/broker_state.cc

Issue 1537593002: Fix UAF in new Mojo EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: improve comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/broker.h ('k') | mojo/edk/system/child_broker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/broker_state.cc
diff --git a/mojo/edk/system/broker_state.cc b/mojo/edk/system/broker_state.cc
index 739cccd24c1233ecace948fc962ea1480d0958e1..e645e61dd38de87412d6de0be960911978ce07c0 100644
--- a/mojo/edk/system/broker_state.cc
+++ b/mojo/edk/system/broker_state.cc
@@ -102,7 +102,6 @@ void BrokerState::ConnectMessagePipe(uint64_t pipe_id,
void BrokerState::CloseMessagePipe(uint64_t pipe_id,
MessagePipeDispatcher* message_pipe) {
DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread());
- base::AutoLock auto_lock(lock_);
CHECK(connected_pipes_.find(message_pipe) != connected_pipes_.end());
connected_pipes_[message_pipe]->RemoveRoute(pipe_id);
@@ -235,7 +234,9 @@ void BrokerState::AttachMessagePipe(MessagePipeDispatcher* message_pipe,
// then when it's read it returns no messages because it doesn't have the
// channel yet.
message_pipe->GotNonTransferableChannel(raw_channel->channel());
- raw_channel->AddRoute(pipe_id, message_pipe);
+ // The above call could have caused |CloseMessagePipe| to be called.
+ if (connected_pipes_.find(message_pipe) != connected_pipes_.end())
+ raw_channel->AddRoute(pipe_id, message_pipe);
}
} // namespace edk
« no previous file with comments | « mojo/edk/system/broker.h ('k') | mojo/edk/system/child_broker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698