summaryrefslogtreecommitdiff
path: root/include/wabt/shared-validator.h
diff options
context:
space:
mode:
authorKeith Winstein <keithw@cs.stanford.edu>2023-06-12 12:37:13 -0700
committerGitHub <noreply@github.com>2023-06-12 19:37:13 +0000
commit5edb24126ed5183d35b317478fc5a7f8ca831ac9 (patch)
tree2aa2afeb559a575bdc2b83760a51d809b6907895 /include/wabt/shared-validator.h
parent4247346029a7c4697df884590c6385561e772b97 (diff)
downloadwabt-5edb24126ed5183d35b317478fc5a7f8ca831ac9.tar.gz
wabt-5edb24126ed5183d35b317478fc5a7f8ca831ac9.tar.bz2
wabt-5edb24126ed5183d35b317478fc5a7f8ca831ac9.zip
memory64: when enabled, check offset range at validation-time (#2253)
* memory64: when enabled, offset range check is at validation-time Before memory64, the "offset" in a load/store expression was a u32, and we enforced this in the WastParser and BinaryReader. After memory64, the "offset" becomes a u64 syntactically, and the validator checks that it's <= UINT32_MAX for i32 memories. We hadn't been correctly allowing these very large offsets in the text format (even when memory64 was enabled and the memory was i64). (This change also eliminates the "memories" member in the BinaryReader. The BinaryReader no longer needs to keep track of the memories and their types to check well-formedness.)
Diffstat (limited to 'include/wabt/shared-validator.h')
-rw-r--r--include/wabt/shared-validator.h59
1 files changed, 49 insertions, 10 deletions
diff --git a/include/wabt/shared-validator.h b/include/wabt/shared-validator.h
index 8c1f3988..37927802 100644
--- a/include/wabt/shared-validator.h
+++ b/include/wabt/shared-validator.h
@@ -104,12 +104,36 @@ class SharedValidator {
Result OnLocalDecl(const Location&, Index count, Type type);
Result OnAtomicFence(const Location&, uint32_t consistency_model);
- Result OnAtomicLoad(const Location&, Opcode, Var memidx, Address align);
- Result OnAtomicNotify(const Location&, Opcode, Var memidx, Address align);
- Result OnAtomicRmwCmpxchg(const Location&, Opcode, Var memidx, Address align);
- Result OnAtomicRmw(const Location&, Opcode, Var memidx, Address align);
- Result OnAtomicStore(const Location&, Opcode, Var memidx, Address align);
- Result OnAtomicWait(const Location&, Opcode, Var memidx, Address align);
+ Result OnAtomicLoad(const Location&,
+ Opcode,
+ Var memidx,
+ Address align,
+ Address offset);
+ Result OnAtomicNotify(const Location&,
+ Opcode,
+ Var memidx,
+ Address align,
+ Address offset);
+ Result OnAtomicRmwCmpxchg(const Location&,
+ Opcode,
+ Var memidx,
+ Address align,
+ Address offset);
+ Result OnAtomicRmw(const Location&,
+ Opcode,
+ Var memidx,
+ Address align,
+ Address offset);
+ Result OnAtomicStore(const Location&,
+ Opcode,
+ Var memidx,
+ Address align,
+ Address offset);
+ Result OnAtomicWait(const Location&,
+ Opcode,
+ Var memidx,
+ Address align,
+ Address offset);
Result OnBinary(const Location&, Opcode);
Result OnBlock(const Location&, Type sig_type);
Result OnBr(const Location&, Var depth);
@@ -133,9 +157,17 @@ class SharedValidator {
Result OnGlobalGet(const Location&, Var);
Result OnGlobalSet(const Location&, Var);
Result OnIf(const Location&, Type sig_type);
- Result OnLoad(const Location&, Opcode, Var memidx, Address align);
- Result OnLoadSplat(const Location&, Opcode, Var memidx, Address align);
- Result OnLoadZero(const Location&, Opcode, Var memidx, Address align);
+ Result OnLoad(const Location&, Opcode, Var memidx, Address align, Address offset);
+ Result OnLoadSplat(const Location&,
+ Opcode,
+ Var memidx,
+ Address align,
+ Address offset);
+ Result OnLoadZero(const Location&,
+ Opcode,
+ Var memidx,
+ Address align,
+ Address offset);
Result OnLocalGet(const Location&, Var);
Result OnLocalSet(const Location&, Var);
Result OnLocalTee(const Location&, Var);
@@ -159,14 +191,20 @@ class SharedValidator {
Opcode,
Var memidx,
Address align,
+ Address offset,
uint64_t lane_idx);
Result OnSimdStoreLane(const Location&,
Opcode,
Var memidx,
Address align,
+ Address offset,
uint64_t lane_idx);
Result OnSimdShuffleOp(const Location&, Opcode, v128 lane_idx);
- Result OnStore(const Location&, Opcode, Var memidx, Address align);
+ Result OnStore(const Location&,
+ Opcode,
+ Var memidx,
+ Address align,
+ Address offset);
Result OnTableCopy(const Location&, Var dst_var, Var src_var);
Result OnTableFill(const Location&, Var table_var);
Result OnTableGet(const Location&, Var table_var);
@@ -280,6 +318,7 @@ class SharedValidator {
Result CheckDataSegmentIndex(Var data_segment_var);
Result CheckAlign(const Location&, Address align, Address natural_align);
+ Result CheckOffset(const Location&, Address offset, const Limits& limits);
Result CheckAtomicAlign(const Location&,
Address align,
Address natural_align);