JSPI shadow stack management

Aperta
#27,364 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
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Tranquilla
Stack tecnologico
javascript, rust, wasm
Ambito
compilers

Direzione di ricerca

Inizia dal punto di ingresso emscripten_stack_get_current() e dal comportamento dello shadow stack di WebAssembly.promising descritto nell’issue. Confronta i due approcci proposti —la gestione da parte del compilatore/toolchain oppure un nuovo primitivo emscripten_stack_get_promising_top()— e il lavoro collegato di Pyodide e wasm-bindgen. Il lavoro è completato quando viene stabilita una convenzione interoperabile e solida per la sospensione e la ripresa dello shadow stack di Rust JSPI.

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

Descrizione

Pyodide implemented JSPI shadow stack suspend/resume semantics quite comprehensively in https://blog.pyodide.org/posts/jspi-with-c-runtime/.

I'm now seeing similar issues for Rust and JSPI, and have been prototyping some (unfinished) ideas in https://github.com/guybedford/jspi - where as far as I can tell Emscripten is not automatically handling the shadow stack save and restore operations, so that JSPI will lead to stack corruption in Rust per Hood's blog post scenario.

In addition, wasm-bindgen is about to land support for JSPI with it's own shadow stack handling in https://github.com/wasm-bindgen/wasm-bindgen/pull/5193 and to get these approaches to interoperate well requires falling on strong conventions.

All conventions come down to needing a stack top though for the shadow stack suspension range. And the stack top is not easy to get since by the time you call emscripten_stack_get_current() you're always deep into the entry point Rust wrapper code.

We can't use the stack base, because WebAssembly.promising functions can be called with arbitrary non-JSPI stack depth, so this core feature missing to integrate this well into Rust seems to me to be a emsripten_stack_get_promising_top() for the current WebAssembly.promising which Emscripten in theory would know about.

Unless I'm missing something, as far as I can tell this leaves us with two options for Rust JSPI soundness:

  1. Either fully implement the shadow stack save/restore work at the compiler / toolchain level (instead of as a library)
  2. Expose a new JSPI-specific emscripten_stack_get_promising_top() primitive

I'd be interested to hear what others think about how to handle the problems here.

Lingua principale
C++
Stelle
27.8k
Fork
3.6k
Merge medio
1g 6h
PR unite (30g)
181

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 emscripten-core/emscripten

Tutte le issue di emscripten-core/emscripten

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.