Bug 1332772 - Baldr: tweak memory/table limits

1332772 - Baldr: tweak memory/table limits
This commit is contained in:
win7-7 2025-12-29 15:26:32 +02:00 committed by wuggy
commit e75935a793
5 changed files with 10 additions and 7 deletions

View file

@ -1854,7 +1854,7 @@ class MOZ_STACK_CLASS ModuleValidator
bool declareFuncPtrTable(Sig&& sig, PropertyName* name, uint32_t firstUse, uint32_t mask,
uint32_t* index)
{
if (mask > MaxTableLength)
if (mask > MaxTableInitialLength)
return failCurrentOffset("function pointer table too big");
uint32_t sigIndex;
if (!newSig(Move(sig), &sigIndex))

View file

@ -358,11 +358,12 @@ static const unsigned MaxExports = 100000;
static const unsigned MaxGlobals = 1000000;
static const unsigned MaxDataSegments = 100000;
static const unsigned MaxElemSegments = 10000000;
static const unsigned MaxTableLength = 10000000;
static const unsigned MaxTableInitialLength = 10000000;
static const unsigned MaxStringBytes = 100000;
static const unsigned MaxLocals = 50000;
static const unsigned MaxParams = 1000;
static const unsigned MaxBrTableElems = 1000000;
static const unsigned MaxMemoryInitialBytes = 1024 * 1024 * 1024;
static const unsigned MaxModuleBytes = 1024 * 1024 * 1024;
static const unsigned MaxFunctionBytes = 128 * 1024;

View file

@ -1024,7 +1024,7 @@ ModuleGenerator::initSigTableLength(uint32_t sigIndex, uint32_t length)
{
MOZ_ASSERT(isAsmJS());
MOZ_ASSERT(length != 0);
MOZ_ASSERT(length <= MaxTableLength);
MOZ_ASSERT(length <= MaxTableInitialLength);
MOZ_ASSERT(env_->asmJSSigToTableIndex[sigIndex] == 0);
env_->asmJSSigToTableIndex[sigIndex] = numTables_;

View file

@ -149,7 +149,7 @@ Table::grow(uint32_t delta, JSContext* cx)
CheckedInt<uint32_t> newLength = oldLength;
newLength += delta;
if (!newLength.isValid() || newLength.value() > MaxTableLength)
if (!newLength.isValid())
return -1;
if (maximum_ && newLength.value() > maximum_.value())

View file

@ -859,7 +859,7 @@ DecodeTableLimits(Decoder& d, TableDescVector* tables)
if (!DecodeLimits(d, &limits))
return false;
if (limits.initial > MaxTableLength)
if (limits.initial > MaxTableInitialLength)
return d.fail("too many table elements");
if (tables->length())
@ -919,7 +919,7 @@ DecodeMemoryLimits(Decoder& d, ModuleEnvironment* env)
CheckedInt<uint32_t> initialBytes = memory.initial;
initialBytes *= PageSize;
if (!initialBytes.isValid() || initialBytes.value() > uint32_t(INT32_MAX))
if (!initialBytes.isValid() || initialBytes.value() > MaxMemoryInitialBytes)
return d.fail("initial memory size too big");
memory.initial = initialBytes.value();
@ -1400,7 +1400,7 @@ DecodeElemSection(Decoder& d, ModuleEnvironment* env)
if (!d.readVarU32(&numElems))
return d.fail("expected segment size");
if (numElems > MaxTableLength)
if (numElems > MaxTableInitialLength)
return d.fail("too many table elements");
Uint32Vector elemFuncIndices;
@ -1547,6 +1547,8 @@ DecodeDataSection(Decoder& d, ModuleEnvironment* env)
if (!d.readVarU32(&seg.length))
return d.fail("expected segment size");
if (seg.length > MaxMemoryInitialBytes)
return d.fail("segment size too big");
seg.bytecodeOffset = d.currentOffset();
if (!d.readBytes(seg.length))