mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
LibWasm: Limit the number of function locals
It's possible for the module to request too many locals, we now reject such modules instead of trying to allocate space for them. The value itself is chosen arbitrarily, so future tweaks _might_ be necessary. Found by OSS-Fuzz: https://oss-fuzz.com/testcase?key=4755809098661888
This commit is contained in:
parent
05c65f9b5d
commit
b64d6bb3a3
Notes:
sideshowbarker
2024-07-18 05:01:32 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/b64d6bb3a3e Pull-request: https://github.com/SerenityOS/serenity/pull/9694 Reviewed-by: https://github.com/awesomekling
2 changed files with 5 additions and 1 deletions
|
@ -40,5 +40,6 @@ static constexpr auto page_size = 64 * KiB;
|
|||
// These are not concretely defined by the spec, so the values are only defined by us.
|
||||
static constexpr auto minimum_stack_space_to_keep_free = 256 * KiB; // Note: Value is arbitrary and chosen by testing with ASAN
|
||||
static constexpr auto max_allowed_executed_instructions_per_call = 256 * 1024 * 1024;
|
||||
static constexpr auto max_allowed_function_locals_per_type = 420; // Note: VERY arbitrary.
|
||||
|
||||
}
|
||||
|
|
|
@ -1091,7 +1091,10 @@ ParseResult<Locals> Locals::parse(InputStream& stream)
|
|||
size_t count;
|
||||
if (!LEB128::read_unsigned(stream, count))
|
||||
return with_eof_check(stream, ParseError::InvalidSize);
|
||||
// TODO: Disallow too many entries.
|
||||
|
||||
if (count > Constants::max_allowed_function_locals_per_type)
|
||||
return with_eof_check(stream, ParseError::HugeAllocationRequested);
|
||||
|
||||
auto type = ValueType::parse(stream);
|
||||
if (type.is_error())
|
||||
return type.error();
|
||||
|
|
Loading…
Reference in a new issue