Skip to content

std::os::rand::imp::is_getrandom_available atomics use is racy #21538

Closed
@talchas

Description

@talchas

is_getrandom_available relies on the ordering of reads and writes that use Ordering::Relaxed to prevent races, which is incorrect. The failure mode would be reading the initial false value of GETRANDOM_AVAILABLE, and thus not using getrandom(2) when it is actually available. Either GETRANDOM_CHECKED should use an acquire load and a release store, or it could just use Once.

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