SWContext raw pointer usage in extensions is potentially race-y |
||
Issue description
In extensions code, we retrieve a raw ServiceWorkerContext pointer
through //content and pass it to IO thread to work with the context.
This seems troublesome as the underlying ref-counted SWContextWrapper
doesn't add ref in this scenario.
Example:
void ServiceWorkerTaskQueue::RunTaskAfterStartWorker(
LazyContextId* context_id,
LazyContextTaskQueue::PendingTask task) {
...
content::StoragePartition* partition =
BrowserContext::GetStoragePartitionForSite(
context_id->browser_context(), context_id->service_worker_scope());
content::ServiceWorkerContext* service_worker_context =
partition->GetServiceWorkerContext();
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::BindOnce(
&GetServiceWorkerInfoOnIO, context_id->service_worker_scope(),
context_id->extension_id(), service_worker_context, std::move(task)));
}
void GetServiceWorkerInfoOnIO(.., content::ServiceWorkerContext* context, ..) {
// No guarantee that |context| is valid at this point.
}
The issue here is that the ref-counted class ServiceWorkerContextWrapper
is internal to //content and isn't expose.
Current plan is to expose a //content method to run a task while keeping
a ServiceWorkerContext* alive.
,
Sep 7
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/2c6f64dd7e4e27783d48f09129f20fcd12374994 commit 2c6f64dd7e4e27783d48f09129f20fcd12374994 Author: Istiaque Ahmed <lazyboy@chromium.org> Date: Fri Sep 07 22:18:09 2018 [Extensions] Fix potential UAF access of ServiceWorkerContext. Use ServiceWorkerContext::RunTask() to make sure that ServiceWorkerContext* is kept alive while transitioning from UI thread to IO thread. Bug: 875376 Change-Id: Ib961931260b453e8a99828b8598d77c7821cff06 Reviewed-on: https://chromium-review.googlesource.com/1211971 Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org> Reviewed-by: Devlin <rdevlin.cronin@chromium.org> Cr-Commit-Position: refs/heads/master@{#589686} [modify] https://crrev.com/2c6f64dd7e4e27783d48f09129f20fcd12374994/extensions/browser/events/event_ack_data.cc
,
Sep 8
|
||
►
Sign in to add a comment |
||
Comment 1 by bugdroid1@chromium.org
, Aug 22