Skip to content

Commit

Permalink
Crash when sending oversized legacy IPC messages
Browse files Browse the repository at this point in the history
We have a clear indication that some renderer code paths are sending
oversized IPC messages (https://crbug.com/766032), but because of
thread-hopping via IPC::ChannelProxy the details remain unclear.

This adds a message size CHECK earlier in the stack, before (if) any
task is posted to the IPC thread to do the Send.

BUG=766032

Change-Id: I68e3962076a97b5774d12d971039b303fc755f4d
Reviewed-on: https://chromium-review.googlesource.com/671446
Commit-Queue: Ken Rockot <rockot@chromium.org>
Reviewed-by: Yuzhu Shen <yzshen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502641}
  • Loading branch information
krockot authored and Commit Bot committed Sep 18, 2017
1 parent 7e8dcc0 commit 8b8c906
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ipc/ipc_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ base::AtomicSequenceNumber g_last_id;

namespace IPC {

// static
constexpr size_t Channel::kMaximumMessageSize;

// static
std::string Channel::GenerateUniqueRandomChannelID() {
// Note: the string must start with the current process id, this is how
Expand Down
2 changes: 1 addition & 1 deletion ipc/ipc_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class IPC_EXPORT Channel : public Sender {

// The maximum message size in bytes. Attempting to receive a message of this
// size or bigger results in a channel error.
static const size_t kMaximumMessageSize = 128 * 1024 * 1024;
static constexpr size_t kMaximumMessageSize = 128 * 1024 * 1024;

// Amount of data to read at once from the pipe.
static const size_t kReadBufferSize = 4 * 1024;
Expand Down
3 changes: 3 additions & 0 deletions ipc/ipc_channel_nacl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ bool ReadDataOnReaderThread(int pipe, MessageContents* contents) {

} // namespace

// static
constexpr size_t Channel::kMaximumMessageSize;

class ChannelNacl::ReaderThreadRunner
: public base::DelegateSimpleThread::Delegate {
public:
Expand Down
4 changes: 4 additions & 0 deletions ipc/ipc_channel_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ void ChannelProxy::SendInternal(Message* message) {
Logging::GetInstance()->OnSendMessage(message);
#endif

// See https://crbug.com/766032. This is to ensure that senders of oversized
// messages can be caught more easily in the wild.
CHECK_LE(message->size(), Channel::kMaximumMessageSize);

context_->Send(message);
}

Expand Down

0 comments on commit 8b8c906

Please sign in to comment.