|
124 | 124 | //! [these remarks have been removed] and the specific usage pattern in this
|
125 | 125 | //! crate is considered to be well-defined.
|
126 | 126 | //!
|
127 |
| -//! To help mitigate concerns about reordering of operations executed by the |
128 |
| -//! CPU potentially exposing values after they have been zeroed, this crate |
129 |
| -//! leverages the [core::sync::atomic] memory fence functions including |
130 |
| -//! [compiler_fence] and [fence] (which uses the CPU's native fence |
131 |
| -//! instructions). These fences are leveraged with the strictest ordering |
132 |
| -//! guarantees, [Ordering::SeqCst], which ensures no accesses are reordered. |
| 127 | +//! Additionally this crate leverages [compiler_fence] from |
| 128 | +//! [core::sync::atomic] with the strictest ordering ([Ordering::SeqCst]) |
| 129 | +//! as a precaution to help ensure reads are not reordered before memory has |
| 130 | +//! been zeroed. |
133 | 131 | //!
|
134 | 132 | //! All of that said, there is still potential for microarchitectural attacks
|
135 |
| -//! (ala Spectre/Meltdown) to leak "zeroized" secrets through covert channels |
136 |
| -//! (e.g. the memory fences mentioned above have previously been used as a |
137 |
| -//! covert channel in the Foreshadow attack). This crate makes no guarantees |
138 |
| -//! that zeroized values cannot be leaked through such channels, as they |
139 |
| -//! represent flaws in the underlying hardware. |
| 133 | +//! (ala Spectre/Meltdown) to leak "zeroized" secrets through covert channels. |
| 134 | +//! This crate makes no guarantees that zeroized values cannot be leaked |
| 135 | +//! through such channels, as they represent flaws in the underlying hardware. |
140 | 136 | //!
|
141 | 137 | //! ## Stack/Heap Zeroing Notes
|
142 | 138 | //!
|
|
196 | 192 | //! [core::sync::atomic]: https://doc.rust-lang.org/stable/core/sync/atomic/index.html
|
197 | 193 | //! [Ordering::SeqCst]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html#variant.SeqCst
|
198 | 194 | //! [compiler_fence]: https://doc.rust-lang.org/stable/core/sync/atomic/fn.compiler_fence.html
|
199 |
| -//! [fence]: https://doc.rust-lang.org/stable/core/sync/atomic/fn.fence.html |
200 | 195 | //! [memory-model]: https://github.com/nikomatsakis/rust-memory-model
|
201 | 196 | //! [unordered]: https://llvm.org/docs/Atomics.html#unordered
|
202 | 197 | //! [llvm-atomic]: https://github.com/rust-lang/rust/issues/58599
|
@@ -305,11 +300,9 @@ where
|
305 | 300 |
|
306 | 301 | /// Implement `Zeroize` on slices of types that can be zeroized with `Default`.
|
307 | 302 | ///
|
308 |
| -/// This impl can eventually be optimized using an atomic memset intrinsic, |
309 |
| -/// such as `llvm.memset.element.unordered.atomic`. For that reason the blanket |
310 |
| -/// impl on slices is bounded by `DefaultIsZeroes`. See: |
311 |
| -/// |
312 |
| -/// <https://github.com/rust-lang/rust/issues/58599> |
| 303 | +/// This impl can eventually be optimized using an memset intrinsic, |
| 304 | +/// such as `core::intrinsics::volatile_set_memory`. For that reason the blanket |
| 305 | +/// impl on slices is bounded by `DefaultIsZeroes`. |
313 | 306 | ///
|
314 | 307 | /// To zeroize a mut slice of `Z: Zeroize` which does not impl
|
315 | 308 | /// `DefaultIsZeroes`, call `iter_mut().zeroize()`.
|
@@ -404,7 +397,6 @@ where
|
404 | 397 | /// see zeroes after this point.
|
405 | 398 | #[inline]
|
406 | 399 | fn atomic_fence() {
|
407 |
| - atomic::fence(atomic::Ordering::SeqCst); |
408 | 400 | atomic::compiler_fence(atomic::Ordering::SeqCst);
|
409 | 401 | }
|
410 | 402 |
|
|
0 commit comments