Debian Codegraph @

debian/patches/CVE-2026-78914

raw
1 From e0eb3d588ca59cbe70f1094b6f295d1275f929af Mon Sep 17 00:00:00 2001
2 From: Greg Daniel <[email protected]>
3 Date: Wed, 22 Jul 2026 10:51:38 -0400
4 Subject: [PATCH] [ganesh] Fully clear initial stencil bits when stencil clear
5 is a draw
6
7 There is a driver bug where clearing stencil requires a manual draw
8 (performStencilClearsAsDraws). Previously, we called
9 internalStencilClear() which only zeroed the stencil clip bit
10 (fWriteMask == clipBit). However, the initial stencil clear must also
11 zero the user bits. Otherwise, stencil-then-cover path renderers might
12 read undefined stencil contents on their first use.
13
14 This change records a full-surface draw that zeroes both clip and user
15 bits when clearing as draw.
16
17 Bug: https://issues.chromium.org/issues/536166543
18
19 Change-Id: Ibedb70474a5aeabe8e8c9fc84e403faa256dadc1
20 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1300916
21 Commit-Queue: Greg Daniel <[email protected]>
22 Commit-Queue: Robert Phillips <[email protected]>
23 Reviewed-by: Robert Phillips <[email protected]>
24 ---
25 src/gpu/ganesh/SurfaceDrawContext.cpp | 20 +++++++++++++++++++-
26 1 file changed, 19 insertions(+), 1 deletion(-)
27
28 diff --git a/src/gpu/ganesh/SurfaceDrawContext.cpp b/src/gpu/ganesh/SurfaceDrawContext.cpp
29 index a8339d276c..c6caae4d25 100644
30 --- a/src/gpu/ganesh/SurfaceDrawContext.cpp
31 +++ b/src/gpu/ganesh/SurfaceDrawContext.cpp
32 @@ -830,7 +830,25 @@ void SurfaceDrawContext::setNeedsStencil() {
33 if (this->caps()->performStencilClearsAsDraws()) {
34 // There is a driver bug with clearing stencil. We must use an op to manually clear the
35 // stencil buffer before the op that required 'setNeedsStencil'.
36 - this->internalStencilClear(nullptr, /* inside mask */ false);
37 + // NOTE: internalStencilClear() only zeroes the *clip* bit (gZeroStencilClipBit lowers
38 + // to fWriteMask == clipBit). The initial clear must also zero the user bits, otherwise
39 + // stencil-then-cover path renderers read undefined stencil contents
40 + constexpr static GrUserStencilSettings kZeroAllStencilBits(
41 + GrUserStencilSettings::StaticInit<
42 + 0x0000,
43 + GrUserStencilTest::kAlways,
44 + 0xffff,
45 + GrUserStencilOp::kZeroClipAndUserBits,
46 + GrUserStencilOp::kZeroClipAndUserBits,
47 + 0xffff>());
48 + GrPaint paint;
49 + paint.setXPFactory(GrDisableColorXPFactory::Get());
50 + SkRect rtRect =
51 + SkRect::Make(this->asSurfaceProxy()->backingStoreDimensions());
52 + this->addDrawOp(nullptr,
53 + FillRectOp::MakeNonAARect(fContext, std::move(paint),
54 + SkMatrix::I(), rtRect,
55 + &kZeroAllStencilBits));
56 } else {
57 this->getOpsTask()->setInitialStencilContent(
58 OpsTask::StencilContent::kUserBitsCleared);
59 --
60 2.43.0
61