microsoft / microsoft/openvmm

nvme_driver: add timeout to controller ready/reset wait loops

Open
#3,022 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug storage
Dominant language
Rust
Stars
1.9k
Forks
238
Avg merge
1d 15h
Merged PRs (30d)
100

Description

Summary

The NVMe driver's enable() and reset() functions poll CSTS.RDY in infinite loops using Backoff, with no upper bound on iterations. If the controller never reaches the expected state, the driver hangs forever.

Affected code

Both use Backoff::new(driver) which yields 250 times, then sleeps 1ms × 250, then 15ms forever — never giving up.

NVMe spec reference

NVMe spec section 3.5.2 defines CAP.TO (offset 0x00, bits 31:24) as the maximum time the host should wait for CSTS.RDY to change after CC.EN transitions, in 500ms units. The driver should read CAP.TO and bail after that duration.

Impact

  • Fuzzing: the NVMe driver fuzzer (fuzz_nvme_driver) cannot fuzz setup-time parameters (nsid, bounce_buffer, msix_count) because the fuzzed emulated device may return CSTS values that prevent the controller from reaching ready state, causing the fuzzer to hang.
  • Production: a misbehaving physical device or malicious VF could hang the driver thread forever.

Suggested fix

Add a max iteration count or deadline to both loops, based on CAP.TO. Bail with an error if the timeout expires.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the enable() loop in vm/devices/storage/disk_nvme/nvme_driver/src/driver.rs and the reset() loop in registers.rs, then inspect how Backoff and CAP.TO are represented. Done means both loops stop waiting and return an error after the CAP.TO-based timeout, including when CSTS.RDY never reaches the expected state.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.