summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShahbaz Youssefi <syoussefi@chromium.org>2024-03-25 14:46:56 -0400
committerMichael BrĂ¼ning <michael.bruning@qt.io>2024-04-16 07:35:29 +0000
commit20eddf6037712f677235f6048d43bf5e384bed53 (patch)
tree06d53b6962008ee195da0c30f43f5c4f9afd6be7
parentf13765b71eeed1903c30db82a76bb31930662949 (diff)
[Backport] CVE-2024-3516: Heap buffer overflow in ANGLE112-based
Cherry-pick of patch originally reviewed on https://chromium-review.googlesource.com/c/angle/angle/+/5391986: Translator: Disallow samplers in structs in interface blocks As disallowed by the spec: > Types and declarators are the same as for other uniform variable > declarations outside blocks, with these exceptions: > > * opaque types are not allowed Bug: chromium:328859176 Change-Id: Ib94977860102329e520e635c3757827c93ca2163 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5391986 Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/554664 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--chromium/third_party/angle/src/compiler/translator/ParseContext.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/chromium/third_party/angle/src/compiler/translator/ParseContext.cpp b/chromium/third_party/angle/src/compiler/translator/ParseContext.cpp
index 5a4352b51ae..56852ad422a 100644
--- a/chromium/third_party/angle/src/compiler/translator/ParseContext.cpp
+++ b/chromium/third_party/angle/src/compiler/translator/ParseContext.cpp
@@ -34,27 +34,39 @@ namespace
const int kWebGLMaxStructNesting = 4;
-bool ContainsSampler(const TStructure *structType);
+struct IsSamplerFunc
+{
+ bool operator()(TBasicType type) { return IsSampler(type); }
+};
+struct IsOpaqueFunc
+{
+ bool operator()(TBasicType type) { return IsOpaqueType(type); }
+};
+
+template <typename OpaqueFunc>
+bool ContainsOpaque(const TStructure *structType);
-bool ContainsSampler(const TType &type)
+template <typename OpaqueFunc>
+bool ContainsOpaque(const TType &type)
{
- if (IsSampler(type.getBasicType()))
+ if (OpaqueFunc{}(type.getBasicType()))
{
return true;
}
if (type.getBasicType() == EbtStruct)
{
- return ContainsSampler(type.getStruct());
+ return ContainsOpaque<OpaqueFunc>(type.getStruct());
}
return false;
}
-bool ContainsSampler(const TStructure *structType)
+template <typename OpaqueFunc>
+bool ContainsOpaque(const TStructure *structType)
{
for (const auto &field : structType->fields())
{
- if (ContainsSampler(*field->type()))
+ if (ContainsOpaque<OpaqueFunc>(*field->type()))
return true;
}
return false;
@@ -1047,7 +1059,7 @@ bool TParseContext::checkIsNotOpaqueType(const TSourceLoc &line,
{
if (pType.type == EbtStruct)
{
- if (ContainsSampler(pType.userDef))
+ if (ContainsOpaque<IsSamplerFunc>(pType.userDef))
{
std::stringstream reasonStream = sh::InitializeStream<std::stringstream>();
reasonStream << reason << " (structure contains a sampler)";
@@ -4861,12 +4873,9 @@ TIntermDeclaration *TParseContext::addInterfaceBlock(
{
TField *field = (*fieldList)[memberIndex];
TType *fieldType = field->type();
- if (IsOpaqueType(fieldType->getBasicType()))
+ if (ContainsOpaque<IsOpaqueFunc>(*fieldType))
{
- std::string reason("unsupported type - ");
- reason += fieldType->getBasicString();
- reason += " types are not allowed in interface blocks";
- error(field->line(), reason.c_str(), fieldType->getBasicString());
+ error(field->line(), "Opaque types are not allowed in interface blocks", blockName);
}
const TQualifier qualifier = fieldType->getQualifier();