You're also missing a #[repr(transparent)], which rustc also warns about:
warning: `extern` block uses type `CStrPtr`, which is not FFI-safe
--> src/lib.rs:12:31
|
12 | unsafe extern "C" { fn f(str: CStrPtr); }
| ^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
Interaction with FFI is already quite unsafe, but you could make it slightly safer by adding a lifetime to your newtype. You can add PhantomData field that pretends to borrow the CStr. it's a zero-sized field so it won't affect ABI compatibility.