bytecodealliance / bytecodealliance/endive
Document how to set memory limits
- Dominant language
- Java
- Stars
- 296
- Forks
- 21
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 29
Description
If possible, could you please extend the documentation regarding how to set memory limits? Currently the documentation just says "set limits" but without telling how exactly.
- Describe it and add an example to the [Resource Limits page](https://endive.run/docs/security/best-practices#resource-limits)
- Link to it from the [Security Model page](https://endive.run/docs/security/overview#what-the-sandbox-does-not-guarantee) ("Memory growth limits"), similar to the existing "CPU Limits" link
- Possibly extend the [Advanced Wasm Memory Customization page](https://endive.run/docs/advanced/memory-customization)
The documentation regarding CPU limits is already pretty good, but for memory limits it is not directly clear how to apply them.
If I understand it correctly the main class is `MemoryLimits`, and it can be applied with `Instance.Builder#withMemoryLimits`. But what I don't fully understand yet is:
- Are there other places to consider?
E.g. there is `ImportMemory` and `MemoryImport`, but I assume they are only relevant when you are actually importing memory?
- There is also `TableLimits`; is that relevant here as well?
- The limit specified using `withMemoryLimits` only [seems to apply to memory index 0](https://github.com/bytecodealliance/endive/blob/75057984f851fd2b13fb04db42f66ab5600585ae/runtime/src/main/java/run/endive/runtime/Instance.java#L1118-L1126), is that intentional and does that mean the other memories are not restricted (besides the `limit` which is specified in the Wasm code itself)?
- The instructions `array.new`, `array.new_default`, `array.new_fixed`, `array.new_data` and `array.new_elem` create a `new long[len]` and don't seem to be restricted at all?
Contributor guide
Assessment
This issue has not been assessed yet.