wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Memory access through wasm-c-api

Open clover2123 opened this issue 2 years ago • 3 comments

Hi About one year ago, I asked about wasm-c-api issue in #677.

It seems like that wamr still isolates objects created by wasm-c-api functions.

Following grow API are not supported either.

wasm_table_grow
wasm_memory_grow

So, current wamr does not allow host-side function(wasm-c-api) to directly handle the internal memory. This approach would be safe in a term of security, but it also restricts users who want to run wasm code through wamr engine. According to the wasm-c-api list, there exist API functions for deletion like wasm_memory_delete. IMHO this api list means that users could exploit wasm engines freely and it should be users who take charge of any error or defect.

Would you enable it or have any plan for supporting this?

clover2123 avatar Jul 20 '22 07:07 clover2123

there is still no plan for growing memories and tables from the host. We will keep you in the loop.

lum1n0us avatar Jul 25 '22 02:07 lum1n0us

Hi @clover2123, we prefer another approach to implement memory.grow:

You can write an export function with __builtin_wasm_memory_grow intrinsic and link with the wasm module, and from the host side you can invoke the exported function to achieve the memory grow, this should be safer than directly expose the wasm-c-api

Hope this can help you, thanks~

xujuntwt95329 avatar Jul 25 '22 02:07 xujuntwt95329

@lum1n0us @xujuntwt95329 Thanks! I'll try it with an export function :)

clover2123 avatar Jul 28 '22 02:07 clover2123