Skip to content

LinkedPerCore::get uses an out-of-bounds pointer offset for secondary cores #48

Description

@balint-dobszay-arm

let percore_ptr = unsafe { NonNull::from_ref(&self.0).byte_offset(percore_local_offset()) };

In this line the NonNull always points to the primary core's copy of the static, even when calling this function on a secondary core. However, the safety requirement of offset() mandates that the pointer which is the result of the offsetting should still point within the bounds of the allocation of which the original pointer was derived from. This can never be true in the current scenario, because the secondary core's copy of the static must not overlap the primary core's copy, so the offset pointer will always point to outside of the primary core's allocation.

https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.offset

Note: Codex gave me the hint for this, while I was reviewing the integration of the new percore-derive feature in RF-A

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