Skip to content

misaligned pointer in queue::Queue::get #3795

@shinmao

Description

@shinmao

The source of unsoundness

fn get<T>(data: &[u8], ptr: com::BufferSlice) -> &[T] {
let u32_size = mem::size_of::<T>();
assert_eq!(ptr.size % u32_size as u32, 0);
let raw = Self::get_raw(data, ptr);
unsafe { slice::from_raw_parts(raw.as_ptr() as *const _, raw.len() / u32_size) }

We consider that queue::Queue::get is unsound because the program tried to cast u8 slice to f32/f64/i32 and created a unaligned pointer. The unaligned pointer was passed to slice::from_raw_parts which requires the guarantee of pointer's alignment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions