Skip to content

Miri failure in simple::Message::alloc #3092

Description

@varies-rust

Problem:

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.

  • Crate: s2n-quic-platform

  • Version tested: 0.79.0

  • API paths with similar failures observed:

    • message::simple::Message::alloc
    • message::Storage::new
  • src/message/simple.rs:122: alloc(entries, payload_len, offset) builds the message storage layout.

  • src/message.rs:42: Storage::new calls alloc_zeroed(layout) and expects a non-null allocation pointer.

Readable equivalent PoC:

#[test]
fn poc() {
    let _ = s2n_quic_platform::message::simple::Message::alloc(0, 0, 0);
}
Miri undefined behavior: error: Undefined Behavior: creating allocation with size 0

Need By Date:

This is a potential soundness issue of low priority.

Solution:

Brief reasoning:

  • The constructor can reach a zero-size layout and then forces it through NonNull::new(...).expect(...).
  • Zero-sized message layouts need an explicit representation, not a raw non-null allocation assumption.

Suggested fix:

  • Reject zero-sized combinations or use a dangling non-null sentinel and skip deallocation for that case.

Out of scope:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions