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