Debian Codegraph @

debian/patches/CVE-2026-19160

raw
1 From cee83412c5b59f9406ddc2e7147290ea9ac9d9aa Mon Sep 17 00:00:00 2001
2 From: Michael Ludwig <[email protected]>
3 Date: Thu, 23 Jul 2026 16:23:44 -0400
4 Subject: [PATCH] [ganesh] Check results of internal flushes for
5 internalWritePixels success
6
7 This moves the caps' dependent pre-flush out of newWritePixelsTask and
8 performs the flush inside internalWritePixels. Also checks for the
9 success of the flush at the end of internalWritePixels when the source
10 pixel data isn't owned. These use a shared helper function.
11
12 Adds a unit test that can trigger writing stale scratch texture contents
13 if the internalWritePixels' flush failed when performing an upload to
14 the scratch texture when taking a write-as-draw path for the primary
15 writePixels target.
16
17 Bug: https://issues.chromium.org/issues/536068737
18 Fixed: 536068737
19 Change-Id: I75c01c1db94c3c38ba302473a0ba502e5cff2c94
20 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1302397
21 Reviewed-by: Thomas Smith <[email protected]>
22 Commit-Queue: Michael Ludwig <[email protected]>
23 Reviewed-by: Nathan Sanchez <[email protected]>
24 ---
25 src/gpu/ganesh/GrDrawingManager.cpp | 10 ----
26 src/gpu/ganesh/SurfaceContext.cpp | 20 ++++++-
27 tests/ReadWritePixelsGpuTest.cpp | 84 +++++++++++++++++++++++++++++
28 3 files changed, 103 insertions(+), 11 deletions(-)
29
30 diff --git a/src/gpu/ganesh/GrDrawingManager.cpp b/src/gpu/ganesh/GrDrawingManager.cpp
31 index 0b986ebff2..689f673602 100644
32 --- a/src/gpu/ganesh/GrDrawingManager.cpp
33 +++ b/src/gpu/ganesh/GrDrawingManager.cpp
34 @@ -995,16 +995,6 @@ bool GrDrawingManager::newWritePixelsTask(sk_sp<GrSurfaceProxy> dst,
35 SkASSERT(fContext);
36
37 this->closeActiveOpsTask();
38 - const GrCaps& caps = *fContext->priv().caps();
39 -
40 - // On platforms that prefer flushes over VRAM use (i.e., ANGLE) we're better off forcing a
41 - // complete flush here.
42 - if (!caps.preferVRAMUseOverFlushes()) {
43 - this->flushSurfaces(SkSpan<GrSurfaceProxy*>{},
44 - SkSurfaces::BackendSurfaceAccess::kNoAccess,
45 - GrFlushInfo{},
46 - nullptr);
47 - }
48
49 GrRenderTask* task = this->appendTask(GrWritePixelsTask::Make(this,
50 std::move(dst),
51 diff --git a/src/gpu/ganesh/SurfaceContext.cpp b/src/gpu/ganesh/SurfaceContext.cpp
52 index 32475beb1b..8f2e415591 100644
53 --- a/src/gpu/ganesh/SurfaceContext.cpp
54 +++ b/src/gpu/ganesh/SurfaceContext.cpp
55 @@ -585,6 +585,22 @@ bool SurfaceContext::internalWritePixels(GrDirectContext* dContext,
56 }
57 pt.fY = flip ? dstSurface->height() - pt.fY - src[0].height() : pt.fY;
58
59 + auto flushSurfaceAndCheckSuccess = [dContext](GrSurfaceProxy* dstProxy, bool expectsTasks) {
60 + const bool hasPendingTasks =
61 + dContext->priv().drawingManager()->getLastRenderTask(dstProxy) != nullptr;
62 + SkASSERT(!expectsTasks || hasPendingTasks);
63 + GrSemaphoresSubmitted flushResult = dContext->priv().flushSurface(dstProxy);
64 + return flushResult == GrSemaphoresSubmitted::kYes || !hasPendingTasks;
65 + };
66 +
67 + // On platforms that prefer flushes over VRAM use (i.e., ANGLE) we're better off forcing a
68 + // complete flush here.
69 + if (!caps->preferVRAMUseOverFlushes()) {
70 + if (!flushSurfaceAndCheckSuccess(dstProxy, /*expectsTasks=*/false)) {
71 + return false;
72 + }
73 + }
74 +
75 if (!dContext->priv().drawingManager()->newWritePixelsTask(
76 sk_ref_sp(dstProxy),
77 SkIRect::MakePtSize(pt, src[0].dimensions()),
78 @@ -600,7 +616,9 @@ bool SurfaceContext::internalWritePixels(GrDirectContext* dContext,
79 if (!ownAllStorage) {
80 // If any pixmap doesn't own its pixels then we must flush so that the pixels are pushed to
81 // the GPU before we return.
82 - dContext->priv().flushSurface(dstProxy);
83 + if (!flushSurfaceAndCheckSuccess(dstProxy, /*expectsTasks=*/true)) {
84 + return false;
85 + }
86 }
87 return true;
88 }
89 --
90 2.53.0
91