audit 0.21.0: MSC and MTP follow-ups

Aperta
#4,526 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
c
Ambito
embedded-iot

Direzione di ricerca

Read mtp_device.c around lines 185, 468 and 585 to trace how an armed OUT receive survives a Cancel, then mtp_device.c:332,680 with mtp_device.h:88 for the Data-IN early-response path. For item 3, start at msc_device.c:408 and src/device/usbd.c:1640, checking whether usbd_open_edpt_pair() validates descriptor length bounds before the MPS pre-read. Done means a diagnosed contract (toggle-preserving partial-OUT drain, IN cancellation, descriptor size checks) confirmed by raw host or HIL runs, since only source tracing has happened so far.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

follow-up Prio 📌

Deferred defects found in the repository audit of 0.21.0..ad7c83db8 (batch class-msc-mtp). Each was validated against the source at ad7c83db8 and judged real but too large, or too hardware-dependent, for the audit PR's contained fixes.

1. Cancel changes to COMMAND while a partially filled OUT receive remains armed. Its next completion can contain old data followed by the next command.
  • Where: mtp_device.c:185,468,585
  • Verdict: valid causal path; stated timing not reproduced; introduced: New COMMAND transition/live-read reuse; baseline Cancel was also incomplete; severity: medium
  • Hardware/spec dependence: M host-cancel sequence checked; DCD partial-receive/abort behavior lacks variant records
  • Overlap: #3961 covers IN, not this OUT case; #4495/#4107 early rejection are different triggers. No full coverage
  • Remaining work and verification: Needs a toggle-preserving partial-OUT retirement/drain design, not an unconditional fallback abort. Existing raw test cancels after a complete 512-byte write, missing the partial-buffer trigger.
2. Early response from an unfinished Data-IN callback is transmitted as the next data packet, without cancellation handling.
  • Where: mtp_device.c:332,680; mtp_device.h:88
  • Verdict: valid; introduced: Mechanism older; permissive API documentation new; severity: medium
  • Hardware/spec dependence: M pp.31,36 checked: phase termination and device cancellation
  • Overlap: #4040 and PR #4517 address Data-OUT only; partial overlap, not full coverage
  • Remaining work and verification: Extend the early-answer contract deliberately to unfinished IN, preventing response submission before cancellation/phase completion. Test a GetObject callback that answers after the first full chunk; raw host/HIL validation required.
3. New MPS pre-read follows application descriptor lengths without bounds/type validation.
  • Where: msc_device.c:408; src/device/usbd.c:1640
  • Verdict: valid malformed-descriptor hardening; claimed valid-config regression not established; introduced: New pre-read; unsafe descriptor-walk foundation older; severity: low
  • Hardware/spec dependence: Bounds defect is source-level; descriptor legality needs USB lookup
  • Overlap: #4387 related field-read scope; PR #4517 fixes the common helper only and does not protect this pre-read
  • Remaining work and verification: Extend device descriptor hardening with minimum-size and remaining-span checks before either endpoint is inspected/opened. bLength != 7 alone is not proof of invalidity; usbd_open_edpt_pair() itself does not validate length bounds.
Adjudication notes: class-msc-mtp

Claims still needing read-doc:

  • S08-06/C08-01, F2: For each affected DCD, does abort retire DMA/FIFO ownership and partial OUT state without changing the current toggle, and can a completion remain queued afterward? The nRF52840 DTOGGLE register and applicable errata cited by the earlier reviewer need an actual claim record; its citations alone are not one.
  • S08-01/S08-07: Which abort/reset/clear-halt operations preserve an armed receive, and what ISR ordering guarantees make a core generation scheme safe? No all-variant equivalence was established.
  • S08-04/S08-05/S08-15, only if revived: DMA/cache ownership for eliminating writes; permitted bulk MPS values for mask substitution; and per-HCD transfer-length/packet-boundary requirements for moving chunking.
  • F10: USB descriptor minimum sizes, extended-length handling, and class endpoint ordering requirements before defining the accepted descriptor set.

Unverified: no unit suite, build, fuzz execution, or hardware run occurred. F5 arithmetic was executed; other defect triggers were traced in source. No additional independently established runtime defect beyond N08-01 was found in the inspected changes. The checkout remains clean, and no files were changed.

Lingua principale
C
Stelle
7.3k
Fork
1.6k
Merge medio
1g 19h
PR unite (30g)
67

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hathach/tinyusb

Tutte le issue di hathach/tinyusb

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.