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

Report a possible bug related to address validation

Open AuYang261 opened this issue 1 year ago • 3 comments

I think there might be a bug in tensor_data_app_native function in core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.c file: the last parameter passed to wasm_runtime_validate_app_addr should be total_elements * size of each element, which depending on input_tensor_wasm->type.

Because the parameter total_elements is the number of the elements in array pointed by input_tensor_wasm->data_offset, while the length of the array in bytes should be the number of elements * size of each element.

I wonder if my understanding is wrong. Thanks.

AuYang261 avatar Mar 13 '24 07:03 AuYang261

@tonibofarull I am not sure whether it is a bug, could you help look into it? Thanks a lot.

wenyongh avatar Mar 14 '24 06:03 wenyongh

You are right, in fact, currently the only input and output tensor datatype that supports is fp32. Will fix this and return an error if the datatype is wrong. Thanks for reporting!

tonibofarull avatar Mar 14 '24 09:03 tonibofarull