You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, we (Rust group @sslab-gatech) are scanning crates on crates.io for potential soundness bugs. We noticed a few soundness issues with the StaticMut type.
We noticed you pointed out some of these issues in the documentation, maybe it would be better to mark these methods as unsafe or restrict the visibility of StaticMut, otherwise this allows for safety violations from Rust without using unsafe. For example:
#![forbid(unsafe_code)]use stderr::StaticMut;// A simple tagged union used to demonstrate problems with aliasing.#[derive(Debug,Clone,Copy)]enumRefOrInt{Ref(&'static u64),Int(u128)}fnmain(){let ptr = StaticMut::new(RefOrInt::Ref(&42));let mutable_ref_one = ptr.as_mut();let mutable_ref_two = ptr.as_mut();println!("Pointer points to: {:?}", mutable_ref_one);ifletRefOrInt::Ref(ref addr) = mutable_ref_one {*mutable_ref_two = RefOrInt::Int(0xdeadbeef);println!("Pointer now points to: {:p}",*addr);println!("Dereferencing addr will now segfault: {}",**addr);}}
causes:
Pointer points to: Ref(42)
Pointer now points to: 0xdeadbeef
Terminated with signal 11 (SIGSEGV)
The text was updated successfully, but these errors were encountered:
Hi there, we (Rust group @sslab-gatech) are scanning crates on crates.io for potential soundness bugs. We noticed a few soundness issues with the
StaticMut
type.There is an aliasing violation with
as_mut
stderr/src/static_mut.rs
Lines 78 to 80 in 2fd8eb8
It implements
Sync
for all typesT
, this should be restricted toT: Sync
stderr/src/static_mut.rs
Line 62 in 2fd8eb8
We noticed you pointed out some of these issues in the documentation, maybe it would be better to mark these methods as unsafe or restrict the visibility of
StaticMut
, otherwise this allows for safety violations from Rust without usingunsafe
. For example:causes:
The text was updated successfully, but these errors were encountered: