Skip to content

LeWrapper is unsound #15

@qwandor

Description

@qwandor

Several unsafe zerocopy traits are implemented unconditionally for LeWrapper, without any guarantee that the contents of the wrapper actually fulfils the requirements of these traits. Safe code somewhere else could implement VmediaType for some arbitrary type which isn't safe to convert to bytes (e.g. because it has padding), wrap an instance of the type in LeWrapper and then convert it to bytes with not unsafe block. This allows undefined behaviour in safe code, so is unsound.

The best solution is for LeWrapper<T> to only implement zerocopy traits if T implements the corresponding trait. This may require a change to v4l2r to implement the required traits on its bindgen-generated types. Alternatively VmediaType could be made an unsafe trait, with a safety requirement corresponding to those of the various zerocopy traits. Then it is up to the implementer of VmediaType to guarantee the requirements.

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