MAP_FIXED shared mapping of a read-only fd fails with EACCES

Aperta
#486 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, macos

Direzione di ricerca

Start by reading sys_mmap, mmap_fixed_commit, and hvf_apply_file_overlay to follow how read-only file descriptors are handled in fixed and non-fixed mappings. Reproduce the issue with the supplied mmap sequence and compare it with Linux 6.12. Done when the fixed shared read-only mapping succeeds, including MAP_FIXED_NOREPLACE into a free hole, while existing behavior remains covered.

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

Descrizione

bug

On 170b5df, mmap(addr, len, PROT_READ, MAP_SHARED | MAP_FIXED, fd, 0) with fd opened O_RDONLY fails with EACCES; MAP_FIXED_NOREPLACE into a free hole fails the same way. Linux 6.12 maps both. Without MAP_FIXED, the same call succeeds under elfuse.

The non-fixed path in sys_mmap checks overlay_fd_writable and falls back to the pread snapshot for a read-only fd. mmap_fixed_commit calls hvf_apply_file_overlay without that check, and hvf_apply_file_overlay returns EACCES for a read-only fd.

Repro: create a 4 MiB file, open it O_RDONLY, reserve 36 MiB with an anonymous PROT_NONE mapping, then mmap(reserve, 4 MiB, PROT_READ, MAP_SHARED | MAP_FIXED, fd, 0).

Lingua principale
C
Stelle
287
Fork
33
Merge medio
2g 17h
PR unite (30g)
18

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 sysprog21/elfuse

Tutte le issue di sysprog21/elfuse

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.