Skip to content

fix(dpc): wrap the DPC ring indices modulo capacity (#642) - #699

Merged
alexis900 merged 1 commit into
developfrom
fix/642-dpc-ring-wrap
Oct 13, 2026
Merged

alexis900 merged 1 commit into
developfrom
fix/642-dpc-ring-wrap

Conversation

@alexis900

Copy link
Copy Markdown
Collaborator

Fixes #642.

Bug

DpcQueue indexed its 128-entry ring with monotonically increasing u16 head/tail and never reduced them modulo DPC_QUEUE_SIZE. Drains do not reset the indices, so after 128 cumulative enqueues on one CPU the next enqueue/dequeue indexed out of bounds and panicked (bounds check) at DIRQL/DISPATCH.

Fix

Index modulo capacity in enqueue and dequeue, mirroring infra/work_queue.rs. Full-queue false and DPC_DROPPED_COUNT accounting unchanged.

Regression test

dpc_ring_wraparound: 300 single enqueue+dispatch cycles plus 40 full-capacity fill/drain bursts on one queue instance, asserting FIFO order and no panic. The pre-fix code indexes out of bounds at the 129th cumulative enqueue.

Verification

  • QEMU neodev test: 954/954 (was 953).
  • VirtualBox neodev test --backend virtualbox: 954/954, dpc_ring_wraparound PASS.

DpcQueue indexed its 128-entry ring with monotonically increasing u16
head/tail counters and never reduced them modulo DPC_QUEUE_SIZE. After 128
cumulative enqueues (drains do not reset the indices) enqueue/dequeue indexed
out of bounds and the kernel panicked at DIRQL/DISPATCH.

- enqueue/dequeue: index entries[(idx) % DPC_QUEUE_SIZE], mirroring
  infra/work_queue.rs.
- test: dpc_ring_wraparound — 300 single enqueue+dispatch cycles plus 40
  full-capacity fill/drain bursts on one queue, asserting FIFO order and no
  panic (the pre-fix code indexes out of bounds at the 129th enqueue).

Full-queue false return and DPC_DROPPED_COUNT accounting are unchanged.

Verified: QEMU 954/954; VirtualBox 954/954.
@alexis900
alexis900 merged commit ffc3fb6 into develop Oct 13, 2026
3 checks passed
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.

[DPC] Ring-buffer head/tail never wrap modulo capacity → index OOB panic after 128 cumulative enqueues

1 participant