| 1 |
From 04ff0203681d3e21a201084d39c29e6d44ef8358 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Robert Phillips <[email protected]> |
| 3 |
Date: Thu, 23 Apr 2026 12:57:10 -0400 |
| 4 |
Subject: [PATCH] [graphite] Fix a security issue in |
| 5 |
GlobalCache::findGraphicsPipeline |
| 6 |
|
| 7 |
Bug: https://issues.chromium.org/issues/500393328 |
| 8 |
Change-Id: I35ad93eaba08fcb4c0896993ff857902622581a0 |
| 9 |
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1217456 |
| 10 |
Commit-Queue: Robert Phillips <[email protected]> |
| 11 |
Reviewed-by: Michael Ludwig <[email protected]> |
| 12 |
--- |
| 13 |
src/gpu/graphite/GlobalCache.cpp | 29 +++++++++++++++-------------- |
| 14 |
1 file changed, 15 insertions(+), 14 deletions(-) |
| 15 |
|
| 16 |
--- a/src/gpu/graphite/GlobalCache.cpp |
| 17 |
+++ b/src/gpu/graphite/GlobalCache.cpp |
| 18 |
@@ -177,31 +177,33 @@ |
| 19 |
[[maybe_unused]] bool forPrecompile = |
| 20 |
SkToBool(pipelineCreationFlags & PipelineCreationFlags::kForPrecompilation); |
| 21 |
|
| 22 |
- sk_sp<GraphicsPipeline>* entry = nullptr; |
| 23 |
+ sk_sp<GraphicsPipeline> result; |
| 24 |
{ |
| 25 |
SkAutoSpinlock lock{fSpinLock}; |
| 26 |
|
| 27 |
- entry = fGraphicsPipelineCache.find(key); |
| 28 |
+ sk_sp<GraphicsPipeline>* entry = fGraphicsPipelineCache.find(key); |
| 29 |
if (entry) { |
| 30 |
- if ((*entry)->didAsyncCompilationFail()) SK_UNLIKELY { |
| 31 |
+ result = *entry; |
| 32 |
+ |
| 33 |
+ if (result->didAsyncCompilationFail()) SK_UNLIKELY { |
| 34 |
// If the pipeline failed, remove it from the cache and let it be regenerated. |
| 35 |
- this->removeGraphicsPipeline((*entry).get()); |
| 36 |
+ this->removeGraphicsPipeline(result.get()); |
| 37 |
return nullptr; |
| 38 |
} |
| 39 |
#if defined(GPU_TEST_UTILS) |
| 40 |
++fStats.fGraphicsCacheHits; |
| 41 |
#endif |
| 42 |
|
| 43 |
- if ((*entry)->epoch() != fEpochCounter) { |
| 44 |
- (*entry)->markEpoch(fEpochCounter); // update epoch due to use in a new epoch |
| 45 |
+ if (result->epoch() != fEpochCounter) { |
| 46 |
+ result->markEpoch(fEpochCounter); // update epoch due to use in a new epoch |
| 47 |
++fStats.fPipelineUsesInEpoch; |
| 48 |
} |
| 49 |
- if (!forPrecompile && (*entry)->fromPrecompile() && !(*entry)->wasUsed()) { |
| 50 |
+ if (!forPrecompile && result->fromPrecompile() && !result->wasUsed()) { |
| 51 |
++fStats.fNormalPreemptedByPrecompile; |
| 52 |
} |
| 53 |
|
| 54 |
- (*entry)->updateAccessTime(); |
| 55 |
- (*entry)->markUsed(); |
| 56 |
+ result->updateAccessTime(); |
| 57 |
+ result->markUsed(); |
| 58 |
|
| 59 |
#if defined(SK_PIPELINE_LIFETIME_LOGGING) |
| 60 |
static const char* kNames[2] = { "CacheHitForN", "CacheHitForP" }; |
| 61 |
@@ -209,7 +211,7 @@ |
| 62 |
TRACE_STR_STATIC(kNames[forPrecompile]), |
| 63 |
TRACE_EVENT_SCOPE_THREAD, |
| 64 |
"key", key.hash(), |
| 65 |
- "compilationID", (*entry)->getPipelineInfo().fCompilationID); |
| 66 |
+ "compilationID", result->getPipelineInfo().fCompilationID); |
| 67 |
#endif |
| 68 |
} else { |
| 69 |
#if defined(GPU_TEST_UTILS) |
| 70 |
@@ -234,12 +236,11 @@ |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
- if (entry) { |
| 75 |
- this->invokePipelineCallback(ContextOptions::PipelineCacheOp::kPipelineFound, entry->get()); |
| 76 |
- return *entry; |
| 77 |
+ if (result) { |
| 78 |
+ this->invokePipelineCallback(ContextOptions::PipelineCacheOp::kPipelineFound, result.get()); |
| 79 |
} |
| 80 |
|
| 81 |
- return nullptr; |
| 82 |
+ return result; |
| 83 |
} |
| 84 |
|
| 85 |
#if SK_HISTOGRAMS_ENABLED |