`mmap` breaks easily

Aperta
#2,010 1 commento 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à
Ferma
Stack tecnologico
linux, rust

Direzione di ricerca

Inizia esaminando l'implementazione corrente di mmap e munmap e il modo in cui interagiscono con le tabelle delle pagine e le liste delle pagine fisiche libere. Decidi se mmap è un'API di alto livello tracciata o un'operazione di basso livello sulle tabelle delle pagine, quindi documenta il comportamento previsto per protezioni miste, mapping identità, unmapping non validi e qualsiasi syscall aggiuntivo.

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

Descrizione

This looks like an ok fix for the issue at hand to me. However, I think mmap has a bunch of problems and this is more of a band-aid solution. For example, this implementaiton breaks if the affected area contains both pages mapped with PROT_NONE and pages with some access allowed. From my reading of the man pages, it is perfectly fine to use linux mmap like that.

For a proper solution, we should decide on which level mmap should operate on:

If it is a high level api, we should track the state of all pages mapped via mmap. munmap should refuse to unmap pages which have not been allocated via mmap. This could be done via a hashtable or using the extra bits available in the pagetable. As an example of why this is needed, you could use munmap to unmap the identity mappings with the current implementation.

If it is a low level api, it should interact directly with the free lists and the page table. In that case, munmap should just walk the page table and add anything it finds to the physical free list. We should specify incorrect use of mmap to be UB, as we can not really detect it reliably. This would make our mmap incompatible with the linux one.

I would prefer mmap to be an optional high level feature and to have an additional set of syscalls that allows direct access to the free lists.

Originally posted by @m-mueller678 in https://github.com/hermit-os/kernel/issues/2008#issuecomment-3432646702

Lingua principale
Rust
Stelle
1.5k
Fork
135
Merge medio
13h 8m
PR unite (30g)
8

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 hermit-os/kernel

Tutte le issue di hermit-os/kernel

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.