Skip to content

MemoryRegion<T> is completely unsound as a concept #58

@BGR360

Description

@BGR360

The current MemoryRegion<T> allows you to store any arbitrary data type T inside a region of memory registered with libibverbs.

This allows two machines to copy the raw byte contents of that type T between them.

This is completely unsound and unsafe. The data type T could contain pointers to memory that is not registered with libibverbs:

struct MyType {
    data: Vec<u64>, // THIS DATA LIVES ON THE HEAP, IS NOT MANAGED BY RDMA LIBRARY
}

// Try to receive one instance of MyType from a remote machine.
let mut mr: MemoryRegion<MyType> = pd.allocate::<MyType>(1).unwrap();
unsafe { qp.post_receive(&mut mr, 0, 1) }.unwrap();

// This is completely unsafe!! We read some arbitrary pointer from the remote machine's address space.
// That pointer doesn't point to anything reasonable in the local machine's address space.
// Not to mention, the remote machine could have a different endianness than the local machine.
println!("{:?}", mr[0].data);

The only safe interface that you can expose for MemoryRegion is MemoryRegion<u8>. Technically, you could allow any type T that is "plain old data", but then you still have to worry about endianness, and it's just not worth it.

The only safe interface for RDMA is bytes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions