Skip to content

Use MaybeUninit in memory manager and Pod-related code #2555

@stevenengler

Description

@stevenengler

The memory manager allows you to copy data to/from the managed process, and uses the Pod trait to restrict what types can be copied through the memory manager. While any initialized byte representation is valid for a "pod" type, that doesn't mean we can cast a pod type to a &[u8] since the type may have padding bytes that will invoke UB when read. For example MemoryCopier::copy_to_ptr() takes a &[T: Pod] as an argument and converts it to a &[u8], which if read may invoke UB if T has padding bytes. There are other cases such as socket addresses where we have a pointer and length to copy to the plugin, but shouldn't cast them to a &[u8] since there may be padding bytes in the socket address. So it would be nice if the memory manager accepted a &[MaybeUninit<u8>] or more generally a &[MaybeUninit<T: Pod>] to copy to the managed process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugError or flaw producing unexpected results

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions