zeroize: possible UB in `Zeroize` implementation for `Option<T>`
還沒有人認領這個 Issue。
- 主要語言
- Rust
- 星號
- 674
- 分支
- 170
- 平均合併
- 1 天 12 小時
- 30 天內合併 PR
- 10
描述
Originally filed by @jessa0 as https://github.com/iqlusioninc/crates/issues/782:
It seems the
Zeroizeimplementation forOption<T> where T: Zeroizehas language-level UB here:I believe, as a
repr(Rust)enum, the memory layout and set of valid bit-patterns forOptionis not defined, and that setting an enum's storage to an invalid bit-pattern while a reference to it exists, even if the value is never read, is instant language-level UB. The documentation forOptiondoes mention guarantees for several special cases, but theNonecase still isn't defined for many of those cases, and theZeroizeimplementation is more generic than that. Here's an example of a miri error in such a situation, that scottmcm came up with on URLO here.
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 zeroize/src/lib.rs 約第 330 行開始,使用連結的 Rust Playground 或 Miri 範例重現回報的行為。確定 Option 實作的健全方法,並驗證所得的行為不再觸發回報的未定義行為錯誤。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- rust
- 領域
- security
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100