Skip to content

Ensure correct alignment in custom allocator #303

@gurry

Description

@gurry

The custom allocator in wdk_alloc is based on on ExAllocatePool2 which uses a 16 byte alignment on 64 bit systems if the allocation size is < PAGE_SIZE and PAGE_SIZE otherwise. We need to validate that this does not violate alignment requirements of Rust types.

Primitive Rust types should be fine. The biggest alignment requirement is 16 bytes for u128 and i128 which does not conflict with ExAllocatePool2's behaviour.

We just need to check for composite types. As per the Rust reference Rust composite types with standard repr will have an alignment at least as big the maximum alignment of its fields. Types with #[repr(align)] or those with fields of types with #[repr(align)] can have arbitrary alignment requirements. The allocator should work correctly in all these cases.

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