mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWasm: Use AK::StackInfo to track stack size
This way, we can make sure that it doesn't overflow when ASAN is enabled.
This commit is contained in:
parent
8ae425cec8
commit
65355c388b
Notes:
sideshowbarker
2024-07-18 09:11:04 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/65355c388b4 Pull-request: https://github.com/SerenityOS/serenity/pull/8633 Issue: https://github.com/SerenityOS/serenity/issues/7158 Issue: https://github.com/SerenityOS/serenity/issues/8629
3 changed files with 5 additions and 2 deletions
|
@ -32,6 +32,7 @@ namespace Wasm {
|
|||
|
||||
void BytecodeInterpreter::interpret(Configuration& configuration)
|
||||
{
|
||||
m_stack_info = {};
|
||||
m_trap.clear();
|
||||
auto& instructions = configuration.frame().expression().instructions();
|
||||
auto max_ip_value = InstructionPointer { instructions.size() };
|
||||
|
@ -129,7 +130,7 @@ void BytecodeInterpreter::store_to_memory(Configuration& configuration, Instruct
|
|||
|
||||
void BytecodeInterpreter::call_address(Configuration& configuration, FunctionAddress address)
|
||||
{
|
||||
TRAP_IF_NOT(configuration.depth() <= Constants::max_allowed_call_stack_depth);
|
||||
TRAP_IF_NOT(m_stack_info.size_free() >= Constants::minimum_stack_space_to_keep_free);
|
||||
|
||||
auto instance = configuration.store().get(address);
|
||||
TRAP_IF_NOT(instance);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/StackInfo.h>
|
||||
#include <LibWasm/AbstractMachine/Configuration.h>
|
||||
#include <LibWasm/AbstractMachine/Interpreter.h>
|
||||
|
||||
|
@ -57,6 +58,7 @@ protected:
|
|||
}
|
||||
|
||||
Optional<Trap> m_trap;
|
||||
StackInfo m_stack_info;
|
||||
};
|
||||
|
||||
struct DebuggerBytecodeInterpreter : public BytecodeInterpreter {
|
||||
|
|
|
@ -38,7 +38,7 @@ static constexpr auto page_size = 64 * KiB;
|
|||
|
||||
// Implementation-defined limits
|
||||
// These are not concretely defined by the spec, so the values are only defined by us.
|
||||
static constexpr auto max_allowed_call_stack_depth = 512;
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue