Skip to content

Commit 11fc420

Browse files
yoshisatoyanagisawaMichal Klocek
authored andcommitted
[backport] CVE-2025-5068 (1/2)
Ensure ParentObjectDestroyed() is in the same sequence of initialization To understand if crbug.com/409059706#comment19 is true, let me add a sequence checker to ensure DedicatedWorker::Dispose() is executed with the same sequence with the worker thread initialization. Bug: 409059706 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6456965 Change-Id: If4deff0e510bb050efef1b5901e7545bbc59fcc6 Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/650559 Reviewed-by: Anu Aliyas <anu.aliyas@qt.io>
1 parent 906b190 commit 11fc420

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

chromium/third_party/blink/renderer/core/workers/threaded_messaging_proxy_base.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void ThreadedMessagingProxyBase::InitializeWorkerThread(
6666
const std::optional<const blink::DedicatedWorkerToken>& token,
6767
std::unique_ptr<WorkerDevToolsParams> client_provided_devtools_params) {
6868
DCHECK(IsParentContextThread());
69+
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
6970

7071
KURL script_url = global_scope_creation_params->script_url;
7172

@@ -111,6 +112,7 @@ void ThreadedMessagingProxyBase::ReportConsoleMessage(
111112
const String& message,
112113
std::unique_ptr<SourceLocation> location) {
113114
DCHECK(IsParentContextThread());
115+
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
114116
if (asked_to_terminate_)
115117
return;
116118
execution_context_->AddConsoleMessage(MakeGarbageCollected<ConsoleMessage>(
@@ -119,6 +121,7 @@ void ThreadedMessagingProxyBase::ReportConsoleMessage(
119121

120122
void ThreadedMessagingProxyBase::ParentObjectDestroyed() {
121123
DCHECK(IsParentContextThread());
124+
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
122125
if (worker_thread_) {
123126
// Request to terminate the global scope. This will eventually call
124127
// WorkerThreadTerminated().
@@ -130,6 +133,7 @@ void ThreadedMessagingProxyBase::ParentObjectDestroyed() {
130133

131134
void ThreadedMessagingProxyBase::WorkerThreadTerminated() {
132135
DCHECK(IsParentContextThread());
136+
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
133137

134138
// This method is always the last to be performed, so the proxy is not
135139
// needed for communication in either side any more. However, the parent
@@ -160,6 +164,7 @@ void ThreadedMessagingProxyBase::WorkerThreadTerminated() {
160164

161165
void ThreadedMessagingProxyBase::TerminateGlobalScope() {
162166
DCHECK(IsParentContextThread());
167+
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
163168

164169
if (asked_to_terminate_)
165170
return;
@@ -197,6 +202,7 @@ ThreadedMessagingProxyBase::GetParentAgentGroupTaskRunner() const {
197202

198203
WorkerThread* ThreadedMessagingProxyBase::GetWorkerThread() const {
199204
DCHECK(IsParentContextThread());
205+
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
200206
return worker_thread_.get();
201207
}
202208

chromium/third_party/blink/renderer/core/workers/threaded_messaging_proxy_base.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <optional>
99

10+
#include "base/sequence_checker.h"
1011
#include "third_party/blink/public/common/tokens/tokens.h"
1112
#include "third_party/blink/public/mojom/devtools/console_message.mojom-blink-forward.h"
1213
#include "third_party/blink/renderer/core/core_export.h"
@@ -118,6 +119,7 @@ class CORE_EXPORT ThreadedMessagingProxyBase
118119
parent_execution_context_task_runners_;
119120
scoped_refptr<base::SingleThreadTaskRunner> parent_agent_group_task_runner_;
120121

122+
SEQUENCE_CHECKER(sequence_checker_);
121123
std::unique_ptr<WorkerThread> worker_thread_;
122124

123125
bool asked_to_terminate_ = false;

0 commit comments

Comments
 (0)