PluginVC::process_write_side reads the peer's read VIO before locking it

Aperta
#14,202 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp

Direzione di ricerca

Read src/proxy/PluginVC.cc, especially process_write_side() around lines 517–590 and the VIO setup in do_io_read() around lines 266–273. Check how the peer read VIO mutex protects op, closed, shutdown, nbytes, and ndone, then verify the transfer size is calculated under that lock. Done means the peer state is rechecked after locking and the read completion behavior remains correct.

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

Descrizione

Bug PluginVC

PluginVC::process_write_side() moves data from this side's write VIO into the other side's read VIO. The other side's read VIO is owned by a different continuation, so its fields are protected by that VIO's mutex, which the function try-locks at PluginVC.cc#L542. Before taking that lock, it already reads the peer's VIO state:

  • other_side->read_state.vio.op (PluginVC.cc#L517)
  • other_side->read_state.vio.ntodo(), i.e. nbytes and ndone (PluginVC.cc#L532). The result caps act_on and is reused after the lock is taken.

Those fields are written by the peer's consumer under its own mutex, not the PluginVC core mutex: do_io_read() sets them (PluginVC.cc#L266-L273), and the consumer may change nbytes at any time. The comments there say op is "set last" so that process_*_side can read it as an activity flag. That ordering is not guaranteed for plain fields, so the unlocked reads are data races when the peer's consumer runs on another thread, such as an intercept or TSHttpConnect plugin. In that case, an nbytes lowered concurrently by the peer can be overrun, because the transfer size was computed from the pre-lock value. The peer then ends up with ndone > nbytes and never gets VC_EVENT_READ_COMPLETE from the ntodo() == 0 check at PluginVC.cc#L590.

process_read_side() doesn't have this problem: it takes the peer write VIO lock and then calls other_side->process_write_side(), which re-reads everything.

Suggested fix: after the try-lock succeeds, re-check op/closed/shutdown and compute other_ntodo. Only the mutex pointer itself has to be read before locking.


generated with Claude Opus 5.5 by Josiah VanderZee

Lingua principale
C++
Stelle
2k
Fork
903
Merge medio
4g 4h
PR unite (30g)
135

Preparare l'ambiente

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 apache/trafficserver

Tutte le issue di apache/trafficserver

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.