Skip to content

Possible unsound safe API #31

Description

@charlesxsh

the prefetch is public accessible, and the offset does not have the appropriate check, which can cause user/developer might causing memory issue by merely using safe API.

halo2curves/src/lib.rs

Lines 33 to 40 in ee35b4e

pub fn prefetch<T>(data: &[T], offset: usize) {
use core::arch::x86_64::_mm_prefetch;
unsafe {
_mm_prefetch(
data.as_ptr().add(offset) as *const i8,
core::arch::x86_64::_MM_HINT_T0,
);
}

Suggestion:

  1. notify rustsec for this issue
  2. mark it as unsafe to notify developer that this function might have memory risks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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