How can mprotect be used soundly?

Aperta
#580 8 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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à
Ferma
Stack tecnologico
c, rust

Direzione di ricerca

Start by reading the Miri native-lib/FFI handling described in the issue, including its mprotect and ptrace mechanisms. Investigate the soundness constraints around compiler reordering and Rust-visible memory access; done means reaching a documented, agreed account of which mprotect uses are sound.

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

Descrizione

A-missing

Miri now contains some quite cursed hacks in native-lib / FFI mode where it will mprotect(PROT_NONE) a bunch of memory before invoking native C code, and some cursed ptrace magic then kicks in when the program actually accesses those pages. That got me to wonder, which ways of using mprotect are actually sound?

What Miri does could be sound because the cursed ptrace logic conspires to make all memory accesses still work as normal. We just run some extra code on each access. So even if LLVM decided to move some memory accesses around the mprotect calls, that would just confuse our tracing, but the accesses should work as excpected.

Is that the only way mprotect can be used soundly? Just taking away memory that Rust thinks it can access cannot work in general, so it seems quite tricky to use mprotect correctly.

Lingua principale
Nessun dato sulla lingua
Stelle
760
Fork
68
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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 rust-lang/unsafe-code-guidelines

Tutte le issue di rust-lang/unsafe-code-guidelines

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.