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
add marker trait to help check safety of guest memory reads (#794)
* add marker trait to help check safety of guest memory reads
we noted that a pointer into guest memory must point to a
properly-initialized T when read into Propolis, but there was no way to
actually check that was a case. for example, it may be tempting to write
an enum describing states of a guest device like:
```
enum MyCoolDevicePower {
Off = 0,
On = 1,
}
```
and read/write to guest memory using the convenient read/write helpers.
but a devious guest could put a `2` at that address, where reading that
into Propolis would be UB.
zerocopy::FromBytes happens to have the same requirements about its implementors
as we need, that they're always valid to view from bytes, so use it to check
that we can safely read a type out of guest memory. in our case we'll always
copy those bytes to our own buffer, but zerocopy::FromBytes also comes with a
great proc macro so we can #[derive(FromBytes)] on structs to be copied out.
0 commit comments