Skip to content

Commit 13e84c6

Browse files
DCastagnamibrunin
authored andcommitted
[Backport] Security bug 1152645
Manual backport of patch originally reviewed on https://chromium-review.googlesource.com/c/chromium/src/+/2563077: viz: Destroy |gpu_memory_buffer_factory_| on IOThread |gpu_memory_buffer_factory_| weak pointers are checked on the IOThread. Weak pointers should be invalidated on the same thread that checks them. This CL moves the destruction of |gpu_memory_buffer_factory_| on the IOThread to avoid possible use after free issues. Bug: 1152645 Change-Id: I0d42814f0e435a3746728515da1f32d08a1252cf Commit-Queue: Daniele Castagna <[email protected]> Reviewed-by: Andres Calderon Jaramillo <[email protected]> Cr-Commit-Position: refs/heads/master@{#836827} Reviewed-by: Allan Sandfeld Jensen <[email protected]>
1 parent dba42bf commit 13e84c6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

chromium/components/viz/service/gl/gpu_service_impl.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,26 @@ GpuServiceImpl::~GpuServiceImpl() {
207207

208208
media_gpu_channel_manager_.reset();
209209
gpu_channel_manager_.reset();
210+
211+
// Destroy |gpu_memory_buffer_factory_| on the IO thread since its weakptrs
212+
// are checked there.
213+
{
214+
base::WaitableEvent wait;
215+
auto destroy_gmb_factory = base::BindOnce(
216+
[](std::unique_ptr<gpu::GpuMemoryBufferFactory> gmb_factory,
217+
base::WaitableEvent* wait) {
218+
gmb_factory.reset();
219+
wait->Signal();
220+
},
221+
std::move(gpu_memory_buffer_factory_), base::Unretained(&wait));
222+
if (io_runner_->PostTask(FROM_HERE, std::move(destroy_gmb_factory))) {
223+
// |gpu_memory_buffer_factory_| holds a raw pointer to
224+
// |vulkan_context_provider_|. Waiting here enforces the correct order
225+
// of destruction.
226+
wait.Wait();
227+
}
228+
}
229+
210230
owned_sync_point_manager_.reset();
211231

212232
// Signal this event before destroying the child process. That way all

0 commit comments

Comments
 (0)