Debian Codegraph @

debian/patches/CVE-2026-17702

raw
1 From 04dbd15284b8b10a72da7636f23db5a077641437 Mon Sep 17 00:00:00 2001
2 From: Greg Daniel <[email protected]>
3 Date: Fri, 17 Jul 2026 13:28:05 -0400
4 Subject: [PATCH] [Ganesh] If a resolve task fails to execute unwind the dirty
5 tracking.
6
7 If a flush fails for some reason then we can get in an inconsistent
8 state with our dirty rect tracking for msaa resolves and mip maps.
9 This happens because we immediately update the proxies tracking of these
10 values when we recording a resolve task. But if that resolve task
11 never executes for some reason then we can end up in a bad state.
12
13 This changes makes it so that if a resolve task is ended without ever
14 executing, then it resets the proxies state to what it was before.
15
16 Technically if the draws before the resolve also never execute we will
17 now be marking a region dirty that isn't neccessarily dirty. This
18 could cause an extra resolve on future draws but is safe. However in
19 practice is flushes fail, clients will usually either tear everything
20 down (and thus it doesn't matter), or repeat the same draws again
21 (which would end up with the same resolve rect anyways). So this
22 possible extra resolve doesn't have a large real world impact.
23
24 Bug: https://issues.chromium.org/issues/517973093
25 Change-Id: Icc54310b87061471631f7a81adcfe661794a4e9c
26 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1297216
27 Reviewed-by: Thomas Smith <[email protected]>
28 Commit-Queue: Greg Daniel <[email protected]>
29 ---
30 src/gpu/ganesh/GrDrawingManager.cpp | 5 +-
31 src/gpu/ganesh/GrTextureResolveRenderTask.cpp | 34 +++-
32 src/gpu/ganesh/GrTextureResolveRenderTask.h | 6 +
33 tests/GrSurfaceResolveTest.cpp | 156 ++++++++++++++++++
34 4 files changed, 194 insertions(+), 7 deletions(-)
35
36 diff --git a/src/gpu/ganesh/GrDrawingManager.cpp b/src/gpu/ganesh/GrDrawingManager.cpp
37 index 55b58d958e..4fa514b1df 100644
38 --- a/src/gpu/ganesh/GrDrawingManager.cpp
39 +++ b/src/gpu/ganesh/GrDrawingManager.cpp
40 @@ -510,8 +510,9 @@ static void resolve_and_mipmap(GrGpu* gpu, GrSurfaceProxy* proxy) {
41 if (auto* textureProxy = proxy->asTextureProxy()) {
42 if (textureProxy->mipmapsAreDirty()) {
43 SkASSERT(textureProxy->peekTexture());
44 - gpu->regenerateMipMapLevels(textureProxy->peekTexture());
45 - textureProxy->markMipmapsClean();
46 + if (gpu->regenerateMipMapLevels(textureProxy->peekTexture())) {
47 + textureProxy->markMipmapsClean();
48 + }
49 }
50 }
51 }
52 diff --git a/src/gpu/ganesh/GrTextureResolveRenderTask.cpp b/src/gpu/ganesh/GrTextureResolveRenderTask.cpp
53 index 76595fa165..0cb2505f67 100644
54 --- a/src/gpu/ganesh/GrTextureResolveRenderTask.cpp
55 +++ b/src/gpu/ganesh/GrTextureResolveRenderTask.cpp
56 @@ -94,24 +94,25 @@ bool GrTextureResolveRenderTask::onExecute(GrOpFlushState* flushState) {
57 // Resolve all msaa back-to-back, before regenerating mipmaps.
58 SkASSERT(fResolves.size() == this->numTargets());
59 for (int i = 0; i < fResolves.size(); ++i) {
60 - const Resolve& resolve = fResolves[i];
61 + Resolve& resolve = fResolves[i];
62 if (GrSurfaceProxy::ResolveFlags::kMSAA & resolve.fFlags) {
63 GrSurfaceProxy* proxy = this->target(i);
64 // peekRenderTarget might be null if there was an instantiation error.
65 if (GrRenderTarget* renderTarget = proxy->peekRenderTarget()) {
66 flushState->gpu()->resolveRenderTarget(renderTarget, resolve.fMSAAResolveRect);
67 + resolve.fFlags &= ~GrSurfaceProxy::ResolveFlags::kMSAA;
68 }
69 }
70 }
71 // Regenerate all mipmaps back-to-back.
72 for (int i = 0; i < fResolves.size(); ++i) {
73 - const Resolve& resolve = fResolves[i];
74 + Resolve& resolve = fResolves[i];
75 if (GrSurfaceProxy::ResolveFlags::kMipMaps & resolve.fFlags) {
76 // peekTexture might be null if there was an instantiation error.
77 GrTexture* texture = this->target(i)->peekTexture();
78 - if (texture && texture->mipmapsAreDirty()) {
79 - flushState->gpu()->regenerateMipMapLevels(texture);
80 - SkASSERT(!texture->mipmapsAreDirty());
81 + if (texture && (!texture->mipmapsAreDirty() ||
82 + flushState->gpu()->regenerateMipMapLevels(texture))) {
83 + resolve.fFlags &= ~GrSurfaceProxy::ResolveFlags::kMipMaps;
84 }
85 }
86 }
87 @@ -119,6 +120,29 @@ bool GrTextureResolveRenderTask::onExecute(GrOpFlushState* flushState) {
88 return true;
89 }
90
91 +void GrTextureResolveRenderTask::endFlush(GrDrawingManager* drawingMgr) {
92 + // Any flags still set here correspond to resolves that were recorded by addProxy() but never
93 + // executed (the flush was dropped before render-task execution, this task was skipped because
94 + // its targets failed to instantiate, or a per-target operation failed). Re-mark those proxies
95 + // dirty so a subsequent flush will re-record the resolve.
96 + SkASSERT(fResolves.size() == this->numTargets());
97 + for (int i = 0; i < fResolves.size(); ++i) {
98 + const Resolve& resolve = fResolves[i];
99 + GrSurfaceProxy* proxy = this->target(i);
100 + if (GrSurfaceProxy::ResolveFlags::kMSAA & resolve.fFlags) {
101 + if (GrRenderTargetProxy* rtProxy = proxy->asRenderTargetProxy()) {
102 + rtProxy->markMSAADirty(resolve.fMSAAResolveRect);
103 + }
104 + }
105 + if (GrSurfaceProxy::ResolveFlags::kMipMaps & resolve.fFlags) {
106 + if (GrTextureProxy* texProxy = proxy->asTextureProxy()) {
107 + texProxy->markMipmapsDirty();
108 + }
109 + }
110 + }
111 + this->GrRenderTask::endFlush(drawingMgr);
112 +}
113 +
114 #ifdef SK_DEBUG
115 void GrTextureResolveRenderTask::visitProxies_debugOnly(const GrVisitProxyFunc&) const {}
116 #endif
117 diff --git a/src/gpu/ganesh/GrTextureResolveRenderTask.h b/src/gpu/ganesh/GrTextureResolveRenderTask.h
118 index 5eee9eddc8..5cd6d02aa6 100644
119 --- a/src/gpu/ganesh/GrTextureResolveRenderTask.h
120 +++ b/src/gpu/ganesh/GrTextureResolveRenderTask.h
121 @@ -44,6 +44,12 @@ private:
122
123 bool onExecute(GrOpFlushState*) override;
124
125 + // addProxy() optimistically marks the proxy resolved/clean at recording time. If the flush
126 + // is dropped before this task executes (or a per-target operation fails) we must restore the
127 + // proxy's dirty state so a later flush will re-record the resolve.
128 + bool requiresExplicitCleanup() const override { return true; }
129 + void endFlush(GrDrawingManager*) override;
130 +
131 #if defined(GPU_TEST_UTILS)
132 const char* name() const final { return "TextureResolve"; }
133 #endif
134 --
135 2.53.0
136