chore: cherry-pick da11d71a0227 from chromium (#32183)

Co-authored-by: Electron Bot <electron@github.com>
This commit is contained in:
Pedro Pontes
2022-01-12 08:42:57 +01:00
committed by GitHub
parent 4ef201c2c6
commit 9232088894
2 changed files with 61 additions and 0 deletions

View File

@@ -170,6 +170,7 @@ use_weakptrs_for_the_threadediconloader_s_background_tasks.patch
show_the_origin_of_the_last_redirecting_server_in_external_protocol.patch
cachestorage_store_partial_opaque_responses.patch
cherry-pick-a5f54612590d.patch
mojo_ipc_drop_messages_targeting_invalid_task_runner.patch
sandbox_fix_sandbox_inheritance_m96_merge.patch
cherry-pick-dbde8795233a.patch
cherry-pick-6bb320d134b1.patch

View File

@@ -0,0 +1,60 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ken Rockot <rockot@google.com>
Date: Fri, 10 Dec 2021 01:03:53 +0000
Subject: mojo/ipc: Drop messages targeting invalid task runner
If the endpoint's task runner does not match the current task runner (or
an equivalent main-thread task runner for the ChannelProxy) when a
executing a message dispatch task for that endpoint, this ignores the
message instead of dispatching it on the wrong sequence.
(cherry picked from commit 0747c9405e1098c0bbbc5593183696eafb45b72c)
Fixed: 1263457
Change-Id: I4f6ba22de3ff8cf3994b748e1ffd0f0aabb17b70
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3318601
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#949140}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3328403
Auto-Submit: Ken Rockot <rockot@google.com>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/branch-heads/4664@{#1269}
Cr-Branched-From: 24dc4ee75e01a29d390d43c9c264372a169273a7-refs/heads/main@{#929512}
diff --git a/ipc/ipc_mojo_bootstrap.cc b/ipc/ipc_mojo_bootstrap.cc
index 1fc3b955bf828db3d07ef1d43196b6b78b292813..1d770b57a9ce23471346a8632201706c323ef9f4 100644
--- a/ipc/ipc_mojo_bootstrap.cc
+++ b/ipc/ipc_mojo_bootstrap.cc
@@ -931,10 +931,14 @@ class ChannelAssociatedGroupController
if (!client)
return;
+ if (!endpoint->task_runner()->RunsTasksInCurrentSequence() &&
+ !proxy_task_runner_->RunsTasksInCurrentSequence()) {
+ return;
+ }
+
// Using client->interface_name() is safe here because this is a static
// string defined for each mojo interface.
TRACE_EVENT0("mojom", client->interface_name());
- DCHECK(endpoint->task_runner()->RunsTasksInCurrentSequence());
// Sync messages should never make their way to this method.
DCHECK(!message.has_flag(mojo::Message::kFlagIsSync));
@@ -965,10 +969,14 @@ class ChannelAssociatedGroupController
if (!client)
return;
+ if (!endpoint->task_runner()->RunsTasksInCurrentSequence() &&
+ !proxy_task_runner_->RunsTasksInCurrentSequence()) {
+ return;
+ }
+
// Using client->interface_name() is safe here because this is a static
// string defined for each mojo interface.
TRACE_EVENT0("mojom", client->interface_name());
- DCHECK(endpoint->task_runner()->RunsTasksInCurrentSequence());
MessageWrapper message_wrapper = endpoint->PopSyncMessage(message_id);
// The message must have already been dequeued by the endpoint waking up