You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from_raw_parts converts the pointer addr and the len into a slice without validation and that memory block would be dumped.
Thus, the 'safe' function dump_code_load_record is actually 'unsafe' since it requires the caller to guarantee that the addr is valid and len must not overflow.
POC
Here follows a simple POC written in safe Rust code.
Hi, we have found an unsound problem caused by the unsafe call
std::slice::from_raw_parts
inwasmtime/crates/jit-debug/src/perf_jitdump.rs
Line 252 in 842fa76
from_raw_parts
converts the pointeraddr
and thelen
into a slice without validation and that memory block would be dumped.Thus, the 'safe' function
dump_code_load_record
is actually 'unsafe' since it requires the caller to guarantee that theaddr
is valid andlen
must not overflow.POC
Here follows a simple POC written in safe Rust code.
Suggestion
There are two possible action choices could be taken:
dump_code_load_record
as unsafe and write Safety requirement.addr
andlen
into a single parametercode_buffer: &[u8]
, so the compiler would guarantee the buffer is valid.The text was updated successfully, but these errors were encountered: