Skip to content

widen s_cost * p_cost to usize when sizing parallel memory#905

Open
dxbjavid wants to merge 1 commit into
RustCrypto:masterfrom
dxbjavid:balloon-parallel-memory-overflow
Open

widen s_cost * p_cost to usize when sizing parallel memory#905
dxbjavid wants to merge 1 commit into
RustCrypto:masterfrom
dxbjavid:balloon-parallel-memory-overflow

Conversation

@dxbjavid
Copy link
Copy Markdown

@dxbjavid dxbjavid commented Jun 1, 2026

With the parallel feature, hash_password_into and balloon_m size the per-thread memory as s_cost * p_cost evaluated in u32 and only then cast to usize. Both come from NonZeroU32 params and can be parsed from a hash string, so a product reaching 2^32 wraps: release builds get an undersized (often zero-length) buffer and a passing MemoryTooLittle check, debug builds panic on the multiply. Casting each operand to usize first computes the real size on 64-bit targets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant