Potential soundness issue in `bitpacking` 0.9.3
还没有人认领这个 Issue。
评估
调研方向
Start with the safe wrappers in src/bitpacker1x.rs:161 and the unsafe implementation in src/macros_simple.rs:424-438. Run the provided short-slice reproducer under Miri, then inspect the corresponding sorted variants. Done means the public sorted APIs reject invalid block lengths or otherwise avoid undefined behavior, with the reproducer no longer reporting the dangling-pointer access.
由索引模型根据 Issue 内容生成。
描述
Hello, and thank you for maintaining this crate.
I found a sanitizer/Miri failure reachable through public crate APIs using safe Rust code. I may be missing crate-specific preconditions, but the behavior looks worth checking because safe callers should not be able to trigger undefined behavior.
Summary
- Crate:
bitpacking - Version tested:
0.9.3 - API paths with similar failures observed:
BitPacker1x::num_bits_sortedBitPacker1x::num_bits_strictly_sortedBitPacker4x::num_bits_sortedBitPacker4x::num_bits_strictly_sorted
Observed diagnostics
Miri undefined behavior: error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
Reproduction
The snippets below are minimal readable reproducers. Each PoC also includes the source location most relevant to the reported failure.
PoC 1: test_bitpacking3::generated_test_3
Relevant source location:
src/bitpacker1x.rs:161: the safe wrapper callsUnsafeBitPackerImpl::num_bits_sorted.src/macros_simple.rs:424-438: the unsafe implementation loads a full fixed block fromdecompressed.
Readable equivalent PoC:
use bitpacking::{BitPacker, BitPacker1x};
#[test]
fn poc() {
let packer = BitPacker1x::new();
let short_block: Vec<u32> = Vec::new();
let _ = packer.num_bits_sorted(0, &short_block);
}
Observed diagnostic:
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
Source review and suggested fix
Brief reasoning:
- The public
num_bitspath already checks for the exact block length. - The sorted variants skip that check and still load a full block from the slice.
- That makes the length precondition caller-visible through a safe API.
Suggested fix:
- Validate the exact block length before calling the unsafe routine, or make the precondition explicit in an
unsafeAPI.
Thanks again for taking a look.
- 主要语言
- Rust
- 星标
- 346
- 派生
- 37
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
quickwit-oss/bitpacking 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
quickwit-oss/bitpacking#60 ·
-
Remove simd bitpacking implementations for high bit width可能重新可做 @trinity-1686a 于 1172 天前认领,目前没有进行中的 PR。 未关闭good first issue
quickwit-oss/bitpacking#47 · 2 条评论 · 已指派 1 人 ·
-
难度 5/5 一周以上 新手友好度 15/100
quickwit-oss/bitpacking#44 · 2 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
quickwit-oss/bitpacking#21 · 6 条评论 ·
-
Hacktoberfest
难度 4/5 3-5 天 新手友好度 45/100
quickwit-oss/bitpacking#20 · 2 条评论 ·
查看 quickwit-oss/bitpacking 的全部 Issue
相似的 Issue
-
[M09] Silence parser misreads ffmpeg times in scientific notation (6.25e-05 → 6.25 s)可能已有人在做 @G-darshan-32 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
clipy-recorder/clipy#164 · 1 条评论 ·
-
p2 ready-mac
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
quickwit-oss/tantivy#3299 ·
维护者通常 1 天内回复
-
P2
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
`stream enable` fails with "already enabled" on every fresh session since streaming became always-on未关闭
难度 2/5 1-3 小时 新手友好度 70/100
vercel-labs/agent-browser#2797 ·
维护者通常 1 天内回复